MathGroup Archive 2009

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

Search the Archive

Re: Re: Fit function vs Hand Calculation

The jpeg is a time-waster; you could have put a notebook at the link,  

BUT: all we need is code, and you don't need a notebook, a link, OR a  
picture for that.

Here's a look at the problem:

data = {{7, 1}, {5, 0}, {4, -1}};
g[x_] = InterpolatingPolynomial[data, x];

FindFit[data, a + b Log@x, {a, b}, x]
f[x_] = a + b Log@x /. %

{a -> -5.80756, b -> 3.52568}

-5.80756 + 3.52568 Log[x]

Show[Plot[{f@x, g@x}, {x, 0, 10}],
  Graphics[{PointSize[.02], Point@data}]]

Show[Plot[f@x, {x, 3.9, 7.1}, PlotStyle -> Red],
  Graphics[{Blue, PointSize[.02], Point /@ data}],
  Plot[g@x, {x, 3.9, 7.1}, PlotStyle -> Blue]]

InterpolatingPolynomial gives an exact fit, but the Fit function only  
tries to get close.

In this case, I assume there's no function of the form a + b Log[x] that  
precisely fits your three points.


On Tue, 03 Nov 2009 01:53:58 -0600, John Accardi <accardi at>  

> Hello,
> Reading this forum I know my question is quite elementary.  I am
> new to Mathematica and have been pulling my hair out here (and I'm
> bald to being with!).
> Any insights on this one?
> I assume a *.nb file can be attached here to this posting.  It
> contains the question.  If not, it can be viewed here:
> Thanks in advance for helping out.

DrMajorBob at

  • Prev by Date: MathKernel7 produces no Graphics
  • Next by Date: Re: Re: Mathematica and desktop search
  • Previous by thread: Re: Re: Fit function vs Hand Calculation
  • Next by thread: Finding Clusters