Re: rearranging equations
- To: mathgroup at smc.vnet.net
- Subject: [mg22453] Re: [mg22505] rearranging equations
- From: BobHanlon at aol.com
- Date: Wed, 8 Mar 2000 02:21:52 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
f[x_] := 7 + 3x + 2x^2; data = Sort[Table[{x = 10*Random[], f[x]}, {6}]]; Clear[x]; As expected, the quadratic fit to the data arrives at the quadratic definition used to generate the data y == Fit[data, {1, x, x^2}, x] y == 6.999999999999996 + 3.0000000000000133*x + 2.*x^2 Inverting the quadratic equation (x == (x /. #)) & /@ Solve[%, x] // Simplify {x == -0.7500000000000033 - 0.7071067811865476* Sqrt[-5.874999999999986 + 1.*y], x == -0.7500000000000033 + 0.7071067811865476* Sqrt[-5.874999999999986 + 1.*y]} Note that x is not quadratic in y. However, the quadratic terms of the series expansion are Series[#[[2]], {y, 0, 2}] & /@ % // Normal {-0.7500000000000033 - 1.713913650100259*I + 0.14586499149789472*I*y + 0.006207020914804047*I*y^2, -0.7500000000000033 + 1.713913650100259*I - 0.14586499149789472*I*y - 0.006207020914804047*I*y^2} Extracting the coefficients CoefficientList[#, y] & /@ % {{-0.7500000000000033 - 1.713913650100259*I, 0.14586499149789472*I, 0.006207020914804047*I}, {-0.7500000000000033 + 1.713913650100259*I, -0.14586499149789472*I, -0.006207020914804047*I}} Bob Hanlon In a message dated 3/4/2000 3:49:44 AM, cdeacon at .physics.mun.ca writes: >Suppose I take some data and use Fit or Regress to obtain values for >a,b and in the equation y=a+bx+cx^2. > >Is there a simple Mathematica function that will let me rewrite the >equation as x=A+By+Cy^2 and obtain values for A, B and C? >