MathGroup Archive 2008

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

Search the Archive

Re: Function Programming Problems

  • To: mathgroup at
  • Subject: [mg90835] Re: [mg90782] Function Programming Problems
  • From: Bob Hanlon <hanlonr at>
  • Date: Fri, 25 Jul 2008 06:19:04 -0400 (EDT)
  • Reply-to: hanlonr at


linearApproximation[expr_, a_, x_Symbol: x] :=
   (expr + D[expr, x]*(var - a)) /.
    {x -> a, var -> x}];

linearApproximation[Sin[a*x], 0] ==
  Series[Sin[a*x], {x, 0, 1}] // Normal


linearApproximation[Exp[-a*x], 0] ==
  Series[Exp[-a*x], {x, 0, 1}] // Normal


linearApproximation[f[y], a, y] ==
  Series[f[y], {y, a, 1}] // Normal


Bob Hanlon

---- davey79 at wrote: 


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

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.


David Taylor
Roanoke College

  • Prev by Date: Re: Function Programming Problems
  • Next by Date: Re: Solving 3d degree polynomial
  • Previous by thread: Re: Function Programming Problems
  • Next by thread: Re: Function Programming Problems