       Re: Function Programming Problems

Murray Eisenberg wrote:
>
> The use of a function name instead of a functional expression works just
> as nicely for a user-defined function as for a built-in function.  For
> example:
>
>    f[x_] := x^3 Exp[-x]
>    LinearApproximation[f,0][x]
>
> Second, since the original poster is writing the LinearApproximation
> function for use in a calculus class, presumably this comes well before
> the notion of series expansion or Taylor polynomials are are ever
> discussed.  So it would be unfair to the students at this point to
> "spoil" things by prematurely introducing Series.  Let them deal with
> the special case of best local linear approximation, probably very early
> in Calculus I, and some time later with best local quadratic
> approximation.  Then they'll have something upon which to build the
> generalization to best n-th degree polynomial local approximation.

Then why not let them find the linear and quadratic approximations for
themselves, instead of providing a function to do it? My students would
do the following.

f[x_] = x^2 Cos[x]

a = \[Pi]

p1[x_] = f[a] + f'[a] (x - a)

p2[x_] = f[a] + f'[a] (x - a) + f''[a]/2 (x - a)^2

Plot[{f[x], p1[x]}, {x, 0, 2 \[Pi]}]

Plot[{f[x], p2[x]}, {x, 0, 2 \[Pi]}]

--