Re: Solving 3d degree polynomial
- To: mathgroup at smc.vnet.net
- Subject: [mg90806] Re: [mg90778] Solving 3d degree polynomial
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 25 Jul 2008 06:12:06 -0400 (EDT)
- Reply-to: hanlonr at cox.net
f[q] = 2 n (n + 1) q^3 - (1 + t) (2 n + 1) q^2 + 2 (t - (n + 1) A) q + (1 + t) A; sub = {n -> 3, A -> 1/4, t -> 1/2}; soln1 = Solve[f[q] == 0, q] // Simplify; soln2 = Solve[f[q] == 0 /. sub, q] // Simplify; (soln1 /. sub) == soln2 // Simplify True soln1 /. sub // N {{q -> 0.4533892260432264 + 0.*I}, {q -> -0.19375575274301296 + 1.2335811384723961*^-17*I}, {q -> 0.17786652669978656 - 4.9343245538895844*^-17*I}} soln2 // N {{q -> 0.45338922604322646 - 5.551115123125783*^-17*I}, {q -> -0.19375575274301293 - 6.476300976980079*^-17*I}, {q -> 0.17786652669978645 + 1.1102230246251565*^-16*I}} Both have small Imaginary parts due to numerical errors when using machine size numbers in the calculation. Use Chop {%, %%} // Chop {{{q -> 0.45338922604322646}, {q -> -0.19375575274301293}, {q -> 0.17786652669978645}}, {{q -> 0.4533892260432264}, {q -> -0.19375575274301296}, {q -> 0.17786652669978656}}} Bob Hanlon ---- Floris Zoutman <fzoutman at hotmail.com> 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? Thank you for your answer Floris