# Solve contains wrong solution

Hello, I tried to following to find a maxima of a function:

var('t x');
f=(e^(x*t))*(x-1)^2;
maxima = solve([derivative(f,x)==0, derivative(f,x,2)<0],x)
show(maxima);


And the solution sage spits out are:

[
[x == 1, -2 > 0],
[x == (t - 2)/t, -(t - 2)^2 + 2*(t - 2)*t - t^2 + 6 > 0]
]


I understand that sage cannot evaluate the validity of the second solution but the first one surely is no solution at all.

Why does it give me this solution or am I doing anything wrong?

edit retag close merge delete

I know, that I could only solve for f'(x)==0 and filter for f''(x)<0 but solve shouldn't contain solutions like that, I think.

Sort by » oldest newest most voted

This is a bug (?) in to_poly_solve in Maxima.

(%i1) load(to_poly_solver);

Loading maxima-grobner $Revision: 1.6$ $Date: 2009-06-02 07:49:49$
(%o1) /Applications/MathApps/Sage-5.4.1-OSX-64bit-10.6.app/Contents/Resources/\
sage/local/share/maxima/5.26.0/share/contrib/to_poly_solver.mac
(%i3) display2d:false;

(%o3) false
(%i4) to_poly_solve([2*(x-1)*%e^(t*x)+t*(x-1)^2*%e^(t*x)=0,4*t*(x-1)*%e^(t*x)+t^2*(x-1)^2*%e^(t*x)+2*%e^(t*x)>0],[x]);

(%o4) %union([x = 1,2 > 0],[x = (t-2)/t,
t^2-2*(t-2)*t-4*t+4*(t-2)+(t-2)^2+2 > 0])


The current Maxima has

(%o4) %union([x = 1,2 > 0],[x = (t-2)/t,
t^2-2*(t-2)*t-4*t+4*(t-2)+(t-2)^2+2 > 0])


which is basically the same issue. I've reported this upstream here.

more

I beg to differ :

Maxima 5.28.0 http://maxima.sourceforge.net using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (a.k.a. GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) load(to_poly_solve);

Loading maxima-grobner $Revision: 1.6$ $Date: 2009-06-02 07:49:49$

(%o1) /usr/share/maxima/5.28.0/share/to_poly_solve/to_poly_solve.mac

(%i2) display2d:false;

(%o2) false

(%i3) f(x,t):=(%e^(xt))(x-1)^2;

(%o3) f(x,t):=%e^(xt)(x-1)^2

(%i4) map(factor,%solve([factor(diff(f(x,t),x))=0,factor(diff(diff(f(x,t),x),x))<0],x));

(%o4) %union([x = 1,-2 > 0],[x = (t-2)/t,2 > 0])

which is correct.

Note that I load()ed to poly solve, not to_poly_solver ; according to a comment in the former source, the latter is obsolete.

HTH,

                                          Emmanuel Charpentier

more

I would not agree with you that these solutions are 'wrong'. They are just presented in a very user unfriendly way. The 1st one, i.e.:

[x == 1, -2 > 0]


definitely is a solution - it just specifies a range of measure zero, since

sage: -2>0
False


so, it is not 'wrong' as you state - it is just 'totally useless' ;) The other solution is also perfectly ok since

sage: bool(-(t - 2)^2 + 2*(t - 2)*t - t^2 + 6)
True


so, the solution you want is

x == (t - 2)/t


which I think is ok ..... however I would definetely agree with you that

In:= f[x_, t_] = Exp[x t] (x - 1)^2;
In:= Solve[{D[f[x, t], x] == 0 , D[f[x, t], {x, 2}] < 0, {x, t}]
Out= {{t -> ConditionalExpression[-(2/(-1 + x)), (t | x) \[Element] Reals]}}


from a well known competitor is far more user friendly

more