The Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.


Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Topic: Can FindFit take two (or more) equations?
Replies: 3   Last Post: Dec 11, 2011 3:03 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Ray Koopman

Posts: 3,383
Registered: 12/7/04
Re: Can FindFit take two (or more) equations?
Posted: Dec 10, 2011 7:06 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Dec 9, 3:02 am, Luiz Melo <lm...@ufsj.edu.br> wrote:
> Dear mathgroup
> I have the following list of data:
>
> {{0.972, -45.7, 60.3}, {1.17, -39.7, 52.4}, {1.35, -34.1, 46.3},
> {1.55, -29.8, 40.0}, {1.73, -25.9, 34.6}, {1.91, -22.5, 30.6},
> {2.11, -19.6, 27.3}, {2.29, -17.4, 24.7}, {2.49, -15.8, 22.3},
> {2.67, -14.5, 20.6}, {2.86, -13.2, 19.2}, {3.05, -12.1,18.0},
> {3.24, -11.1, 16.9}, {3.43, -10.4, 15.7}, {3.62, -9.66, 14.5},
> {3.80, -9.07, 13.3}, {4.00, -8.35, 12.3}, {4.18, -7.73, 11.4},
> {4.38, -7.26, 10.6}, {4.56, -6.71, 9.82}, {4.74, -6.12, 9.20},
> {4.94, -5.61, 8.63}, {5.12, -5.09, 8.13}, {5.32, -4.59, 7.78},
> {5.50, -4.16, 7.46}, {5.68, -3.82, 7.12}, {5.88, -3.51, 6.87},
> {6.06, -3.26, 6.65}, {6.26, -2.99, 6.48}, {6.44, -2.72, 6.31},
> {6.62, -2.51, 6.16}, {6.82, -2.29, 6.02}, {7.00, -2.09, 5.88},
> {7.20, -1.97, 5.79}, {7.38, -1.78, 5.71}, {7.57, -1.62, 5.60},
> {7.76, -1.52, 5.58}, {7.95, -1.41, 5.56}, {8.14, -1.34, 5.50},
> {8.33, -1.36, 5.39}, {8.51, -1.38, 5.29}, {8.71, -1.40, 5.19},
> {8.89, -1.41, 5.02}, {9.09, -1.32, 4.84}, {9.27, -1.32, 4.62},
> {9.45, -1.26, 4.41}, {9.65, -1.20, 4.21}, {9.83, -1.19, 3.94},
> {10.0, -1.18, 3.69}}
>
> where the first column is, let's say, x, the second is y1 and the
> third, y2. I would like to simultaneously fit the curve given by
> the points y1 = y1(x) with the equation y1(x) = 1 - a^2/(x^2+b^2),
> and the curve given by the points y2 = y2(x) with the equation
> y2(x) = a^2*b/(x*(x^2+b^2)).
> Can FindFit help us to find the parameters "a" and "b"
> of the above equations? How?
>
> Thank you.
> Luiz


The usual way is to reorganize the data so that each y is on a
different line, and to include an indicator that tells which y
it is. Here the indicator is i, with value 1|0 for y1|y2.

Clear[a,b,i,x];
FindFit[Flatten[{{1,#1,#2},{0,#1,#3}}& @@@ data, 1],
i + ((1-i)b/x - i)*a^2/(x^2+b^2), {a,b}, {i,x}]

{a -> 14.5228, b -> 2.36932}




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2017. All Rights Reserved.