MathGroup Archive 2008

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

Search the Archive

Re: Function Programming Problems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90814] Re: [mg90782] Function Programming Problems
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Fri, 25 Jul 2008 06:14:13 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200807240851.EAA18893@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

First, do you REALLY want your students to think of a function as "an 
expression in x" -- technically, a functional relation in variable x -- 
  such as sin x (Mathematica: Sin[x]).  Or wouldn't you rather want then 
to think of a function as an object in its own right, or as an object 
sine (Mathematica: Sin) in its own right, such as sine (Mathematica: 
Sin)?  Mathematically, surely the former is preferable.

If so, then it seems to me a more natural way to set this up would be:

   LocalLinearApproximation[f_,a_][x_] := f[a] + f'[a](x-a)

For example:

   LocalLinearApproximation[Sin,0][x]
x

That makes evident that the local linear approximation depends upon the 
function and the point "a" and, in essence, gives you a function that 
can then, in turn, be evaluated at any input x.

Of course you could make this more explicit by the following variant:

   Clear[LocalLinearApproximation]
   LocalLinearApproximation[f_, a_] := f[a] + f'[a] (# - a) &
   (* or:
      LocalLinearApproximation[f_,a_] := Function[x, f[a]+f'[a] (x-a)] *)

But if you insist upon the unfortunate, traditional calculus textbook 
approach of confusing a function with a functional relation in a 
variable x, then I'm not sure how you would want to get rid of that 
third argument entirely: how else would Mathematica know what is the 
variable?


davey79 at gmail.com wrote:
> Hello,
> 
> A colleague and myself are working on some Mathematica labs for
> Calculus using Mathematica 6.0 and I can't seem to find any
> information or examples that explain defining functions and using
> functions as arguments.
> 
> I want to define a LinearApproximation command that preferably would
> take two arguments and return the linear approximation.  Ideally,
> 
> LinearApproximation[function_,a_] would have
> LinearApproximation[Sin[x],0] give "x" as the output.
> 
> So far I have:
> LinearApproximation[function_, a_, x_] := function[a] +
> function'[a]*(x - a)
> 
> which works mostly nicely, except it only works with
> LinearApproximation[Sin,0,x].
> 
> Does anyone know how I would fix this to allow Sin[x] as input (or
> even x^2, etc)?  Getting rid of the third argument "x" would be nice,
> but not necessary.
> 
> Thanks!
> 
> David Taylor
> Roanoke College
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Writing to an External file, ie .txt
  • Next by Date: Re: several plots in manipulate
  • Previous by thread: Re: Function Programming Problems
  • Next by thread: Re: Function Programming Problems