# Solving one equation, then inputting the values into another for NonlinearModelFit

Considering the equation

a*x^3 + a*x^2 + x + b == 0


I'm looking to find the best value for a and x from the above polynomial (with b known) for which the second function using the same a and x

(65 + 103*a*x^2)/(1 + a*x^2)


gives me the closest NonlinearModelFit for an already determined set of (x,y) coordinates.

• If you fit your data to the model you get an expression for a. If you use that in the first equation you can than Solve or NSolve that for x. The phrasing of your question seems rather peculiar to me. If you have determined a using the fit you cannot use the first equation to determine a again as you seem to suggest. – Sjoerd C. de Vries May 28 '13 at 20:43

data = {{0, 64.88916615388398}, {1, 83.24718374138278}, {2,
93.75766523300271}, {3, 99.74735460092744}, {4,
101.22704834518477}, {5, 105.38706473218782}, {6,
100.10310736034148}, {7, 104.83229572643938}, {8,
103.76491949073773}, {9, 105.68123555532274}, {10,
99.70060366431277}};

sol =  NonlinearModelFit[data, (65 + 103*a*x^2)/(1 + a*x^2), {a}, x]["BestFitParameters"]


{a -> 0.951042699}

Solve[a*x^3 + a*x^2 + x + b == 0 /. sol /. b -> 1, x]
`

{{x -> -1.}, {x -> 0. - 1.02541577 I}, {x -> 0. + 1.02541577 I}}