       RE: Equivalent functions generate different plots

• To: mathgroup at smc.vnet.net
• Subject: [mg26159] RE: [mg26112] Equivalent functions generate different plots
• From: "David Park" <djmp at earthlink.net>
• Date: Thu, 30 Nov 2000 01:04:04 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Use

Plot[{f[t], g[t]} // Evaluate, {t, 0, 2.2}];

When you don't evaluate the plotting function g[t] first, then for each t
point Mathematica evaluates g[t]. When t == 1 it evaluates g ->
Fit[data,{1,1,1^2}], which is not what you intended. An alternative is to
define g[t_] with a Set:

g[t_] = Fit[data, {1, t, t^2}, t]

Then

Plot[{f[t], g[t]}, {t, 0, 2.2}];

works the way you wish.

David Park

> -----Original Message-----
> From: GERMAN [mailto:gerbual at col2.telecom.com.co]
To: mathgroup at smc.vnet.net
> Hi, Group:
>
> With:
>
> In:=
> data = {{0, 79.6}, {0.2, 79.2}, {0.4, 77.1}, {0.6, 73.7}, {0.8, 69.1},
> {1., 63.2}};
>
> I can to get its cuadratic regression function:
>
> In:=
> Fit[data, {1, t, t^2}, t]
>
> Out=
> 79.68214285714285` + 0.21249999999984936` t - 16.741071428571246` t^2
>
> Then, I can define the regression function in two different, but
> equivalent ways:
>
> First: copying and pasting the last output:
>
> In:=
> f[t_] :=
>     79.68214285714285`+ 0.21249999999984936` t - 16.741071428571246 t^2
>
> Second: using directly the *Fit* function in the right hand:
>
> In:=
> g[t_] := Fit[data, {1, t, t^2}, t]
>
> In this conditions:
>
> In:=
> f[t] == g[t]
>
> Out=
> True
>
> However:
>
> In:=
> Plot[{f[t], g[t]}, {t, 0, 2.2}]
>
> Out=
>
> (GRAPHICS ...!!!)
>
> genere two different plots (a straight line and a curve). The curve is
> well, but the straight line not. I DON'T UNDERSTAND. Can somebody
> explain to me this inconsistency?
>