Re: Annoying Maximize behaviour
- To: mathgroup at smc.vnet.net
- Subject: [mg64071] Re: Annoying Maximize behaviour
- From: "Solomon, Joshua" <J.A.Solomon at city.ac.uk>
- Date: Tue, 31 Jan 2006 01:14:17 -0500 (EST)
- References: <200601280723.CAA14674@smc.vnet.net> <dri745$9qh$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Yes, I understand. FWIW I failed to articulate *why* this behaviour annoyed me. So, for the record, it would be nice to know the function hasn't simply returned the original input because of improper use, e.g. In[1]:= f[x_]:=x In[2]:= f[] Out[2]= f[] js On 29/1/06 10:58, in article dri745$9qh$1 at smc.vnet.net, "Andrzej Kozlowski" <akoz at mimuw.edu.pl> wrote: > > On 28 Jan 2006, at 07:23, Solomon, Joshua wrote: > >> In[1]:= >> {$Version, $ReleaseNumber} >> >> >> Out[1]= >> {5.1 for Mac OS X (October 25, 2004),0} >> >> In[2]:= >> Maximize[Exp[-x^2]Sin[x],x] >> >> >> Out[2]= >> Maximize[Exp[-x^2]Sin[x],x] >> >> wouldn't the following output be friendlier? >> >> Maximize::choke: No analytic solution found, resorting to numerical >> methods. >> Out[2]= >> {0.396653, {x -> 0.653271}} >> >> j >> -- >> Joshua A. Solomon >> http://www.staff.city.ac.uk/~solomon >> > > > The principle that functions that are unable to perform the requested > computation return the original input is a basic principle of > Mathematica programming and should be, unless there are very good > reasons, strictly adhered to. It is extremely useful in writing > functional programs. To give a somewhat artificial example based on > your case, one can something like this > > > (If[Head[#1] === Maximize, NMaximize @@ #, Identity] & )[ > Maximize[Exp[-x^2]*Sin[x], x]] > > > {0.39665296108547105, {x -> 0.653271187094403}} > > which would be impossible if Mathematica behaved as you wish. > Personally I find nothing more irritating than when programs try to > guess what I might want to without giving me a chance to decide > myself (even Mathematica does it too often but this is mainly legacy > of the bad old days when computers were too slow for many things that > we take for granted today). > > Andrzej Kozlowski >
- References:
- Annoying Maximize behaviour
- From: "Solomon, Joshua" <J.A.Solomon@city.ac.uk>
- Annoying Maximize behaviour