sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 479 forks source link

solve misses some solutions in a certain nonlinear system #8862

Open 9dd22736-ae7b-4fcc-871e-f43b962cbafd opened 14 years ago

9dd22736-ae7b-4fcc-871e-f43b962cbafd commented 14 years ago

We search the critical points of the function x|-> (x2 + y2)^x

This function has four critical points : ±(0,1) and ±(1/e,0)

However the function solve can not find any of this.

More, solve returns (0,0) which is not a critical point since f is not differentiable at (0,0) !

  sage: var('x y')
  sage: f(x,y) = (x^2 + y^2)^x
  sage: solve([diff(f(x,y), x), diff(f(x,y), y)], x, y)
  [[x == 0, y == 0]] 

Upstream: Reported upstream. No feedback yet.

CC: @kcrisman @robert-marik @jasongrout

Component: calculus

Keywords: solve

Stopgaps: #12730

Issue created by migration from https://trac.sagemath.org/ticket/8862

zimmermann6 commented 14 years ago

Changed author from Alexandre Casamayou to none

burcin commented 14 years ago
comment:2

What is the expected improvement in this ticket?

The solve() function in Sage is just a wrapper around maxima for now. In this case we just return the result from maxima.

There are two problems here:

If this ticket is about improving the capabilities of solve to handle the given input properly, this is an enhancement request. Do we know of any algorithm that will help with this?

Otherwise, this ticket is a duplicate of #2617.

Comments?

zimmermann6 commented 14 years ago
comment:3

the issue here is not only that Sage returns undefined points (which indeed duplicates #2617) but that it fails to find the following (trivial) solutions, which is a defect:

sage: sys=[diff(f(x,y), x), diff(f(x,y), y)]
sage: map(lambda s: s.subs(x=0,y=1),sys)
[0, 0]
sage: map(lambda s: s.subs(x=0,y=-1),sys)
[0, 0]
sage: map(lambda s: s.subs(x=1/e,y=0),sys)
[0, 0]
sage: map(lambda s: s.subs(x=-1/e,y=0),sys)
[0, 0]

For example Maple finds:

> f := (x,y) -> (x^2 + y^2)^x:                                         
> solve({diff(f(x,y), x), diff(f(x,y), y)}, {x, y}, Explicit=true);
                                          exp(1)               exp(1)
  {x = 0, y = 1}, {x = 0, y = -1}, {x = - ------, y = 0}, {x = ------, y = 0}
                                          exp(2)               exp(2)

When some solutions are lost, at least a warning should be issued.

burcin commented 14 years ago
comment:4

Replying to @zimmermann6:

the issue here is not only that Sage returns undefined points (which indeed duplicates #2617) but that it fails to find the following (trivial) solutions, which is a defect:

> When some solutions are lost, at least a warning should be issued. I don't think we can get that information out of maxima. Can someone more experienced in maxima comment on this? Or ask the maxima developers what they think about this problem? Another option is to take this as an opportunity to start implementing some native `solve()` functionality in Sage. I have no idea how to (more or less algorithmically) find a solution to this system though. I'd appreciate any pointers.
kcrisman commented 13 years ago

Upstream: Reported upstream. Little or no feedback.

kcrisman commented 13 years ago
comment:5
Maxima 5.23.2 http://maxima.sourceforge.net
using Lisp ECL 11.1.1
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) solve([(2*x^2/(x^2 + y^2) + log(x^2 + y^2))*(x^2 + y^2)^x,2*x*y*(x^2 + y^2)^(x - 1)],[x,y]);
(%o1)                          [[x = 0, y = 0]]

So still present in 4.7.alpha1.

This is a pretty straightforward Maxima bug/enhancement need.

The issue about it not being a critical point is irrelevant, since this is exactly equivalent to the uninterpreted

solve([(2*x^2/(x^2 + y^2) + log(x^2 + y^2))*(x^2 + y^2)^x,2*x*y*(x^2 + y^2)^(x - 1)],[x,y])

So the relevant problem is that it's returning something not in the domain of the functions in question, which is indeed a problem. In addition to not finding other solutions.

This is now Maxima bug 3216684.

roed314 commented 12 years ago

Stopgaps: #12730

roed314 commented 12 years ago

Changed upstream from Reported upstream. Little or no feedback. to Reported upstream. No feedback yet.

a29f3e21-153a-43e1-9dc1-3808f8f5634e commented 8 years ago
comment:12

Just a random comment: sympy can solve this. I tested it in the 'live shell' in their webpage:

solve([(x**2 + y**2)**x*(2*x**2/(x**2 + y**2) + log(x**2 + y**2)),2*(x**2 + y**2)**(x - 1)*x*y],x,y)
[(0,−1),(0,1),(−1/e,0),(1/e,0)]

(I edited the output because copy&paste mangled it).

It would be nice to have an 'algorithm=sympy' option to solve(). It seems that nobody is working in the Maxima bug.