MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to define a polyfunction?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27409] Re: [mg27389] How to define a polyfunction?
  • From: BobHanlon at aol.com
  • Date: Sun, 25 Feb 2001 00:53:32 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Clear[golf, Key1, Key2, Key3, Key4];

golf[t_] := t^2-t;

Key1[t_] := t^4+3t /; golf'[t] > 0;
Key1[t_] := t^2.5-t /; golf'[t] <= 0;

Key2[t_] := If[golf'[t] > 0, (t^4+t*3), (t^2.5-t)];

Key3[t_] := If[(D[golf[x], x] /. x -> t) > 0, (t^4+t*3), (t^2.5-t)];

Key4[t_] := Evaluate[If[D[golf[t], t] > 0, (t^4+t*3), (t^2.5-t)]];

Key1 does not evaluate for non-numeric arguments

Key1[t]

Key1[t]

The other three give the same If statement for a non-numeric argument

Key2[t]

If[2*t - 1 > 0, t^4 + 3*t, t^2.5 - t]

Key2[t] === Key3[t]=== Key4[t]

True

All are equivalent for numeric arguments

And @@ Table[
    Key1[t] == Key2[t] == Key3[t] == Key4[t], {t, 0, 1, .01}]

True

Plot[{t^4+3t, t^2.5-t, Key1[t], golf'[t]}, {t, 0, 1}, 
    PlotStyle \[Rule] {
        {RGBColor[0, 1, 0], AbsoluteDashing[{5, 5}]}, 
        {RGBColor[0, .7, .5], AbsoluteDashing[{6, 3}]}, 
        {RGBColor[0, 0, 1], AbsoluteThickness[2]}, 
        {RGBColor[1, 0, 0], AbsoluteDashing[{3, 3}]}}, 
    ImageSize \[Rule] {400, 250}];


Bob Hanlon

In a message dated 2001/2/23 2:52:12 AM, gzgear at yahoo.com writes:

>Now I encounter a problem that I
>can not solve for a long time .
>It can be express simplely as how to define a
>polyfunction,for example,a simple polyfunction may be
>defined as that:
>
>Key[t_]:=If[(t>0),1,0];
>
>It is easy to define.However,it will be more difficult
>when the condition turns more complicate.For instance:
>golf=t^2-t;
>Key[t_]:=If[(D[golf[t],t]>0),(t^4+t*3),(t^2.5-t)];
>


  • Prev by Date: Re: How to define a polyfunction?
  • Next by Date: Re: export eps with fonts 4.01?
  • Previous by thread: Re: How to define a polyfunction?
  • Next by thread: Re: Re:How to define a polyfunction?