[Date Index] [Thread Index] [Author Index]
Re: Solving 3d degree polynomial
On 7/24/08 at 4:51 AM, fzoutman at hotmail.com (Floris Zoutman) wrote: >I have a function f(q)=2n(n+1)q^3-(1+t)(2n+1)q^2+2(t-(n+1)A)q+(1+t)A >in which n>1, -1<A<1, and 0<t<1 are parameters. If I fill in >appropriate values for the parameters before: Solve[Y==0,q] it gives >me 3 real roots. If instead I ask for a symbolic solution before >filling in the same values of the parameters, Mathematica gives >almost the same roots, but now there is an imaginary part to the >solution. It is of the order 10^(-16). Why are the roots complex if >I find a solution before filling in parameters, but real if I fill >in parameters before finding the solution? I suspect in both cases you are using machine precision numbers. If so, this is the reason. By default, Mathematica does not simplify expressions before evaluating them with your substituted values. The symbolic solution you get by using Solve before substituting values will have a different structure and have different numerical properties even though it will be mathematically equivalent to the alternative approach. You should be able to get exactly the same result if you use exact numbers for the parameter values in both cases. Also, if you want a machine precision number the better choice would be to substitute the values for the parameters and use NSolve rather than Solve.