MathGroup Archive 2005

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

Search the Archive

Re: Getting crude approximation to a function

  • To: mathgroup at
  • Subject: [mg58855] Re: Getting crude approximation to a function
  • From: Peter Pein <petsie at>
  • Date: Thu, 21 Jul 2005 03:08:01 -0400 (EDT)
  • References: <dbkkpu$s6a$>
  • Sender: owner-wri-mathgroup at

Mukhtar Bekkali schrieb:
> Assume I have a function f[x], x is some variable, given below (my real
> function is much more complex). I would like to obtain its crude
> approximation. I used command Series, first order expansion. The
> resulting function has coefficients that have high precision. I do not
> need that since my expansion is very crude anyway. I need coefficients
> that are rational number approximations to these coefficients. How do I
> obtain this? It seems to me that command Chop takes care of
> coefficients that are not product with variable x but cannot handle
> coefficients that are not standalone. For instance, in this example
> \!\(\(\(Normal[
>         Series[0.71  p\
>             x + \(1\/3\)
>             x\^2 - 4, {x, 1, 1}]] // Expand\) // Chop\) //
> Rationalize\)
> I would like to obtain output of the form (-13/10)+(29/10)x.
> Mathematica gives me (-13/10)+2.8972x instead, where it keeps
> 2.8971974507154195` in the memory. I need this because I use
> InequalitySolve package and it refuses to function unless all numbers
> are rational.  
> Mukhtar Bekkali
Hi Mukhtar,

I don't find the definition of p, so I have to guess:

In[1]:= p = N[Expand[Pi*(1 + 34/(25*x))]];
In[2]:= appr = Expand[Normal[
   Series[(p/Sqrt[2])*x + (1/3)*x^2 - 4, {x, 1, 1}]]]
Out[2]= -1.3121729353856435 + 2.8881081357458496*x

If you prefer the 10 in the denominator, try

In[3]:= appr /. a_Real :> Round[10*a]/10
Out[3]= -(13/10) + (29*x)/10

If you just want /any/ approximation, then

In[4]:= Rationalize[appr, 0.0125]
Out[4]= -(13/10) + (26*x)/9

does the job too.

Peter Pein

  • Prev by Date: Re: Re: Directed Graph from Adjacency Matrix
  • Next by Date: Gridlines in MultipleListPlot
  • Previous by thread: Re: Getting crude approximation to a function
  • Next by thread: Re: Getting crude approximation to a function