Re: Re: Fit function vs Hand Calculation
- To: mathgroup at smc.vnet.net
- Subject: [mg104586] Re: [mg104528] Re: Fit function vs Hand Calculation
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Wed, 4 Nov 2009 01:37:44 -0500 (EST)
- References: <4AEDB3D2.4010604@accardi.com> <4AEE0305.8070404@gmail.com>
- Reply-to: drmajorbob at yahoo.com
The jpeg is a time-waster; you could have put a notebook at the link,
instead.
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.
Bobby
On Tue, 03 Nov 2009 01:53:58 -0600, John Accardi <accardi at accardi.com>
wrote:
> 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:
>
> http://www.accardi.com/zane.jpg
> Thanks in advance for helping out.
>
>
--
DrMajorBob at yahoo.com