MathGroup Archive 2011

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

Search the Archive

Re: Can FindFit take two (or more) equations?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123526] Re: Can FindFit take two (or more) equations?
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sat, 10 Dec 2011 07:28:31 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201112091056.FAA03863@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

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}};

Clear[a, b, f, g, error]
f[x_] = 1 - a^2/(x^2 + b^2);
g[x_] = a^2*b/(x*(x^2 + b^2));
error[a_, b_] =
   Total@Replace[
     data, {x_, y_, z_} :> (f@x - y)^2 + (g@x - z)^2, {1}];
Timing[{err, rules} = Minimize[error[a, b], {a, b}]]
{a, b} = {a, b} /. rules;
{low, high} = data[[{1, -1}, 1]];
Show[ListPlot[data[[All, {1, 2}]]], Plot[f@x, {x, low, high}],
  ListPlot[data[[All, {1, 3}]]], Plot[g@x, {x, low, high}],
  PlotRange -> All]

{0.129184, {1976.97, {a -> 14.5228, b -> 2.36932}}}

Bobby

On Fri, 09 Dec 2011 04:56:46 -0600, Luiz Melo <lmelo at 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
>


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: Complex diagram
  • Next by Date: Re: Findminimum too slow for iterative reweighted least
  • Previous by thread: Can FindFit take two (or more) equations?
  • Next by thread: Re: Can FindFit take two (or more) equations?