Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Odd behavior of solve()

0 views
Skip to first unread message

Rouben Rostamian

unread,
Nov 29, 2009, 3:19:37 PM11/29/09
to
I wish to compute the locations of the extrema of the the
function z defined below. So I set its partial derivatives
equal to zero and solve:

restart;
z := (x,y) -> exp(-(x-1)^2 - y^2) + exp(-(x+1)^2 - y^2);
solve({D[1](z)(x,y)=0, D[2](z)(x,y)=0}, {x,y});

This returns four solutions, two of which are:

{x = -1, y = 0}, {x = 3, y = 0}.

Surprisingly, these are far from being solutions
as evaluating D[1](z)(-1,0) and D[1](z)(3,0) shows.

Is this due to a Maple bug/feature or did I eat
too much Thanksgiving turkey?

[Tested on Maple 11, 12, 13].

--
Rouben Rostamian

Nasser M. Abbasi

unread,
Nov 29, 2009, 5:17:30 PM11/29/09
to

"Rouben Rostamian" <r...@nohost.noname> wrote in message
news:heul0p$iip$1...@news.albasani.net...

I tried the optimization package, this is what I get:

With Maple12
===============

with(Optimization):
Minimize(exp(-(x-1)^2 - y^2) + exp(-(x+1)^2 - y^2));
[0.203708984379844490 * 10^-15 , [x = 1.16896322532382112, y =
6.00920669540742303]]

> Maximize(exp(-(x-1)^2 - y^2) + exp(-(x+1)^2 - y^2));
[1.01986581833111933, [x = 0.957503983154222250, y = 0.959583930651859228*
10^-8 ]]

in Mathematica
============
f=Exp[-(x-1)^2-y^2]+Exp[-(x+1)^2-y^2];

FindMinimum[f,{x,y}, Method->"ConjugateGradient"]
{3.05169*10^-275,{x->1.86789,y->25.1265}}

FindMaximum[f,{x,y}, Method->"ConjugateGradient"]
{1.01987,{x->0.957504,y->8.52452*10^-12}}


Some difference between the 2. But the max value is the same. Or may be I
made an error?

--Nasser


Rouben Rostamian

unread,
Nov 29, 2009, 6:06:35 PM11/29/09
to

The function z does not achieve its minimum anywhere
because z(x,y)>0 for all x,y and z goes to zero at infinity.
This explains the discrepancy between the purported "minimum"
values computed by Mathematica and Maple but they cannot
be faulted for that. The maximum is computed correctly.
(Actually there are two points where z achieves the maximum
value because z(x,y is an even function of x.)

The location and value of z's maximum can be computed in a
number of different ways. For instance, it is easy to see
that it will occur at y=0, therefore it suffices to compute
the maximum of z(x,0) as a function of single variable which
is a much easier job.

The intent of my question was to find out whether Maple's
solve() is working as advertised or if its behavior in this
case should be considered a bug.

--
Rouben Rostamian

Robert Israel

unread,
Nov 29, 2009, 7:44:44 PM11/29/09
to
Rouben Rostamian <r...@nohost.noname> writes:

Yes, certainly it is a bug. I don't know how it arises in this case, but
there are times when solve produces spurious "solutions".
--
Robert Israel isr...@math.MyUniversitysInitials.ca
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia Vancouver, BC, Canada

Rouben Rostamian

unread,
Nov 29, 2009, 8:41:46 PM11/29/09
to
On 2009-11-30, Robert Israel <isr...@math.MyUniversitysInitials.ca> wrote:
> Rouben Rostamian <r...@nohost.noname> writes:
>
>> I wish to compute the locations of the extrema of the the
>> function z defined below. So I set its partial derivatives
>> equal to zero and solve:
>>
>> restart;
>> z := (x,y) -> exp(-(x-1)^2 - y^2) + exp(-(x+1)^2 - y^2);
>> solve({D[1](z)(x,y)=0, D[2](z)(x,y)=0}, {x,y});
>>
>> This returns four solutions, two of which are:
>>
>> {x = -1, y = 0}, {x = 3, y = 0}.
>>
>> Surprisingly, these are far from being solutions
>> as evaluating D[1](z)(-1,0) and D[1](z)(3,0) shows.
>>
>> Is this due to a Maple bug/feature or did I eat
>> too much Thanksgiving turkey?
>>
>> [Tested on Maple 11, 12, 13].
>
> Yes, certainly it is a bug. I don't know how it arises in this case, but
> there are times when solve produces spurious "solutions".

OK, thanks for confirming. I have reported this to Maplesoft support.

--
Rouben Rostamian

Message has been deleted

Rouben Rostamian

unread,
Nov 29, 2009, 9:42:58 PM11/29/09
to
On 2009-11-30, Ray Vickson <RGVi...@shaw.ca> wrote:

> On Nov 29, 12:19 pm, Rouben Rostamian <r...@nohost.noname> wrote:
>> I wish to compute the locations of the extrema of the the
>> function z defined below.  So I set its partial derivatives
>> equal to zero and solve:
>>
>> restart;
>> z := (x,y) -> exp(-(x-1)^2 - y^2) + exp(-(x+1)^2 - y^2);
>> solve({D[1](z)(x,y)=0, D[2](z)(x,y)=0}, {x,y});
>>
>> This returns four solutions, two of which are:
>>
>>    {x = -1, y = 0}, {x = 3, y = 0}.
>>
>> Surprisingly, these are far from being solutions
>> as evaluating D[1](z)(-1,0) and D[1](z)(3,0) shows.
>
> In Maple 9.5: plotting f = exp(-(x-1)^2 - y^2) + exp(-(x+1)^2 - y^2)
> shows there are two local maxima at (x,y) = (-1,0) and at (x,y) =
> (x0,0), where x0 is near 1. simplifying diff(f,x) = 0 and diff(f,y) =
> 0 by taking out common nonzero factors shows that we have y = 0 and
> two x-solutions: x = -1 and x = .95750402407727010291 (using fsolve).
> We have f(-1,0) = 1.0183156388887341803 while f(.
> 95750402407727010291,0) = 1.0198658183311206328. Thus, the global max
> is at (0.957,0), while another nearly-as-good local max is at (-1,0).
> There is no local min, but there is a saddle point at (0,0), which is
> a third solution of f_x = f_y = 0.

That analysis is partially correct. The function does achieve
a maximum at (x0,0) as you have calculated, but not at (-1,0).

--
Rouben Rostamian

Ray Vickson

unread,
Nov 30, 2009, 2:38:58 AM11/30/09
to
On Nov 29, 6:42 pm, Rouben Rostamian <r...@nohost.noname> wrote:

I removed my message, but I guess some remnant of it remains out in
cyberspace somewhere.

R.G. Vickson

0 new messages