1

I have a function in Maxima I am differentiating then attempting to find the value at which this is zero. When I use solve(), however, I am not given a solution. Why is this, and how can I work around it?

(%i1)   f(x):=(-5*(x^4+5*x^3-3*x))/(x^2+1);
(%o1)   f(x):=((-5)*(x^4+5*x^3+(-3)*x))/(x^2+1)
(%i2)   df(x):=''(diff(f(x), x));
(%o2)   df(x):=(10*x*(x^4+5*x^3-3*x))/(x^2+1)^2-(5*(4*x^3+15*x^2-3))/(x^2+1)
(%i3)   solve(df(x), x);
(%o3)   [0=2*x^5+5*x^4+4*x^3+18*x^2-3]
tsvallender
  • 2,615
  • 6
  • 32
  • 42

2 Answers2

3

The function solve is not too strong; there are many problems it can't solve. A stronger version is under development. In the meantime, try the add-on package to_poly_solve. Here's what I get:

(%i1) df(x) := (10*x*(x^4+5*x^3-3*x))/(x^2+1)^2-(5*(4*x^3+15*x^2-3))/(x^2+1) $

(%i2) load (to_poly_solve) $
(%i3) to_poly_solve (df(x), x);
(%o3) %union([x = - 2.872468527640942], [x = - 0.4194144025323134], 
[x = 0.3836388367122223], [x = 0.2041221431132173 - 1.789901606296292 %i], 
[x = 1.789901606296292 %i + 0.2041221431132173])

Something which is maybe a little surprising is that to_poly_solve has returned a numerical solution instead of exact or symbolic. Tracing allroots shows that to_poly_solve has constructed a quintic equation and punted it to allroots. Since the general quintic doesn't have a solution in terms of radicals, and even in special cases it's probably very messy, maybe it's most useful to have a numerical solution anyway.

Try plot2d(df(x), [x, -3, 1]) to visualize the real roots returned above.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
0

You can try to find a numerical solution. I don't know why solve does not try this. Either you take the ouput of aolveor you do hte folölowing:

(%i1) f(x):=(-5*(x^4+5*x^3-3*x))/(x^2+1);

                                      4      3
                              (- 5) (x  + 5 x  + (- 3) x)
(%o1)                 f(x) := ---------------------------
                                         2
                                        x  + 1
(%i2) df(x):=''(diff(f(x), x));

                            4      3                3       2
                     10 x (x  + 5 x  - 3 x)   5 (4 x  + 15 x  - 3)
(%o2)       df(x) := ---------------------- - --------------------
                             2     2                  2
                           (x  + 1)                  x  + 1

Bring it to a common denominator and extract the numerator:

(%i3) xthru(df(x));

                   4      3              2          3       2
            10 x (x  + 5 x  - 3 x) - 5 (x  + 1) (4 x  + 15 x  - 3)
(%o3)       ------------------------------------------------------
                                    2     2
                                  (x  + 1)
(%i4) num(%);

                   4      3              2          3       2
(%o4)       10 x (x  + 5 x  - 3 x) - 5 (x  + 1) (4 x  + 15 x  - 3)

use allsrootsto find the roots of a polynomial numerically

(%i5) allroots(%);

(%o5) [x = 0.3836388391066617, x = - 0.4194143906217701, 
x = 1.789901606296292 %i + 0.2041221431132174, 
x = 0.2041221431132174 - 1.789901606296292 %i, x = - 2.872468734711326]

skip the complex solutions

(%i6) sublist(%,lambda([t],imagpart(rhs(t))=0))
;

(%o6) [x = 0.3836388391066617, x = - 0.4194143906217701, 
                                                       x = - 2.872468734711326]
miracle173
  • 1,852
  • 16
  • 33