Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum > General > > "Plotting non-linear values and solving"

Post Reply:
Name:
Email Address:

Please send email when my message is replied to.

Url (optional):
Subject:
Message: view original message?
Attachment (optional):
Please answer this:2+1 =



Original Message (ID '78731') By Bill Simpson:
In Response To 'Re: Re: Re: Re: Re: Re: Plotting non-linear val...' --------- I take your revised equation to fit and your data. In[1]:= c = 0.0000132; b = 1+k c+k x/(2 s); y2 = (b-(Sqrt[b^2-2k^2 c x/s]))/(2k); x =.; data = {{0.0,0.0},{0.0000079333,0.4176},{0.0000119,0.5385},{0.000015867,0.6374},{0.000019833,0.7473},{0.0000238,0.8571},{0.000027767,0.9231},{0.000031733,0.9560},{0.0000357,0.9780},{0.000039667,0.9780},{0.000043633,0.9890},{0.0000476,1.0220},{0.000051567,0.9890},{0.000055533,1.0110},{0.000063467,1.0000},{0.000075367,1.0000},{0.000087267,1.0110},{0.00010313,1.0000}}; fit = FindFit[data, y2, {k, s}, x] FindFit gives us a small k and s. Out[6]={k->1.57811,s->0.421896} Generate {x,y} from those coefficients. In[7]:= fitdata=Map[{First[#],y2/.x->First[#]/.fit}&,{{0.0, 0.0}, {0.0000079333, 0.4176}, {0.0000119, 0.5385}, {0.000015867, 0.6374}, {0.000019833, 0.7473}, {0.0000238, 0.8571}, {0.000027767, 0.9231}, {0.000031733, 0.9560}, {0.0000357, 0.9780}, {0.000039667, 0.9780}, {0.000043633, 0.9890}, {0.0000476, 1.0220}, {0.000051567, 0.9890}, {0.000055533, 1.0110}, {0.000063467, 1.0000}, {0.000075367, 1.0000}, {0.000087267, 1.0110}, {0.00010313, 1.0000}}] And that is a horrible fit. Out[7]= {{0., 0.}, {7.9333*^-6, 1.9585*^-10}, {0.0000119, 2.9377*^-10}, {0.000015867, 3.9170*^-10}, {0.000019833, 4.8960*^-10}, {0.0000238, 5.8752*^-10}, {0.000027767, 6.8545*^-10}, {0.000031733, 7.8334*^-10}, {0.0000357, 8.8127*^-10}, {0.000039667, 9.7918*^-10}, {0.000043633, 1.0771*^-9}, {0.0000476, 1.1750*^-9}, {0.000051567, 1.2729*^-9}, {0.000055533, 1.3708*^-9}, {0.000063467, 1.5666*^-9}, {0.000075367, 1.8603*^-9}, {0.000087267, 2.1540*^-9}, {0.00010313, 2.5455*^-9}} Maybe FindFit is getting stuck in a local minima. Give it SigmaPlot's k and s values to start. In[8]:= sigmafit=FindFit[data,y2,{{k,2900000},{s,.84}},x] Now it finds far larger k and far smaller s. Out[8]= {k->1.3980773696034728`*^7, s->0.00031468882517991163`} Generate {x,y} data from that. In[9]:= sigmafitdata=Map[{First[#],y2/.x->First[#]/.sigmafit}&,{{0.0, 0.0}, {0.0000079333, 0.4176}, {0.0000119, 0.5385}, {0.000015867, 0.6374}, {0.000019833, 0.7473}, {0.0000238, 0.8571}, {0.000027767, 0.9231}, {0.000031733, 0.9560}, {0.0000357, 0.9780}, {0.000039667, 0.9780}, {0.000043633, 0.9890}, {0.0000476, 1.0220}, {0.000051567, 0.9890}, {0.000055533, 1.0110}, {0.000063467, 1.0000}, {0.000075367, 1.0000}, {0.000087267, 1.0110}, {0.00010313, 1.0000}}] And it is a horrible fit. Out[9]= {{0., 0.}, {7.9333*^-6, 0.00001}, {0.0000119, 0.00001}, {0.000015867, 0.00001}, {0.000019833, 0.00001}, {0.0000238, 0.00001}, {0.000027767, 0.00001}, {0.000031733, 0.00001}, {0.0000357, 0.00001}, {0.000039667, 0.00001}, {0.000043633, 0.00001}, {0.0000476, 0.00001}, {0.000051567, 0.00001}, {0.000055533, 0.00001}, {0.000063467, 0.00001}, {0.000075367, 0.00001}, {0.000087267, 0.00001}, {0.00010313, 0.00001}} Brute force just use the SigmaPlot k and s. In[10]:= sigmaforcefit=Map[{First[#], y2/.x->First[#]/.{k->2900000,s->.84}}&,{{0.0, 0.0}, {0.0000079333, 0.4176}, {0.0000119, 0.5385}, {0.000015867, 0.6374}, {0.000019833, 0.7473}, {0.0000238, 0.8571}, {0.000027767, 0.9231}, {0.000031733, 0.9560}, {0.0000357, 0.9780}, {0.000039667, 0.9780}, {0.000043633, 0.9890}, {0.0000476, 1.0220}, {0.000051567, 0.9890}, {0.000055533, 1.0110}, {0.000063467, 1.0000}, {0.000075367, 1.0000}, {0.000087267, 1.0110}, {0.00010313, 1.0000}}] And it is a horrible fit. Out[10]= {{0., 0.}, {7.9333*^-6, 4.5413*^-6}, {0.0000119, 6.7252*^-6}, {0.000015867, 8.7635*^-6}, {0.000019833, 0.00001}, {0.0000238, 0.00001}, {0.000027767, 0.00001}, {0.000031733, 0.00001}, {0.0000357, 0.00001}, {0.000039667, 0.00001}, {0.000043633, 0.00001}, {0.0000476, 0.00001}, {0.000051567, 0.00001}, {0.000055533, 0.00001}, {0.000063467, 0.00001}, {0.000075367, 0.00001}, {0.000087267, 0.00001}, {0.00010313, 0.00001}} Something is terribly wrong somewhere. I'm now no longer seeing the complex value complaints from FindFit. That is probably the result of changing the equation you are fitting. But none of these coefficients are coming anywhere near the data. Can you double check the equation again? Can you scrape-n-paste the exact equation that SigmaPlot is being given so we can see that? There have been things in the past where Mathematica only used the first n data points and ignored the rest, but that was a far bigger n than you have here and so that doesn't seem to be the likely culprit. Generate your own sets of {x,y} data points from the coefficients, using your given x and calculating the y, without being influenced by how I did it. If you or someone else can do that completely independently and they also get points that look nothing like the original data points then that may mean it is less likely I am making an error there. As x gets large, if we can think of x=.00001 being "large", or even a small fraction of that then y should approach 1. Can simple algebra and your y2 tell you that is true? You do have a range of x that is orders of magnitude smaller than your range of y. Maybe that is what is blowing this up. At this point I'm stumped. There isn't a chance that your units introduce scale factors of 10^9 or 10^-9, is there? Anyone else have any ideas?