So here are two work-arounds: A=find_minimum_on_interval(-x*sin(x),.5,2.5) (-1)*A[0]
and A=x*sin(x) A.find_maximum_on_interval(.5,2.5) - but neither of these is really satisfying. A function as fundamental as max of a continuous function over an interval should not run into and error message like Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_36.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZmluZF9tYXhpbXVtX29uX2ludGVydmFsKHgqc2luKHgpLC41LDIuNSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module> File "/private/var/folders/h-/h-SNXV0qH8Ge-MkoSlEMtE+++TI/-Tmp-/tmpT70pnk/___code___.py", line 3, in <module> exec compile(u'find_maximum_on_interval(x*sin(x),_sage_const_p5 ,_sage_const_2p5 ) File "", line 1, in <module> File "/Volumes/sage-4.7.1-OSX-64bit-10.6-x86_64-Darwin/Sage-4.7.1-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/numerical/optimize.py", line 127, in find_maximum_on_interval minval, x = find_minimum_on_interval(lambda z: -f(z), a=a, b=b, tol=tol, maxfun=maxfun) File "/Volumes/sage-4.7.1-OSX-64bit-10.6-x86_64-Darwin/Sage-4.7.1-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/numerical/optimize.py", line 186, in find_minimum_on_interval xmin, fval, iter, funcalls = scipy.optimize.fminbound(f, a, b, full_output=1, xtol=tol, maxfun=maxfun) File "/Volumes/sage-4.7.1-OSX-64bit-10.6-x86_64-Darwin/Sage-4.7.1-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/scipy/optimize/optimize.py", line 1021, in fminbound if fu <= fx: File "expression.pyx", line 1852, in sage.symbolic.expression.Expression.__nonzero__ (sage/symbolic/expression.cpp:8675) File "/Volumes/sage-4.7.1-OSX-64bit-10.6-x86_64-Darwin/Sage-4.7.1-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.py", line 403, in test_relation_maxima s = m.parent()._eval_line('is (%s)'%repr(m)) File "/Volumes/sage-4.7.1-OSX-64bit-10.6-x86_64-Darwin/Sage-4.7.1-OSX-64bit-10.6.app/Contents/Resources/sage/local/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 420, in _eval_line if statement: result = ((result + '\n') if result else '') + max_to_string(maxima_eval("#$%s$"%statement)) File "ecl.pyx", line 691, in sage.libs.ecl.EclObject.__call__ (sage/libs/ecl.c:4622) File "ecl.pyx", line 556, in sage.libs.ecl.EclObject.__init__ (sage/libs/ecl.c:4305) File "ecl.pyx", line 387, in sage.libs.ecl.python_to_ecl (sage/libs/ecl.c:3521) File "ecl.pyx", line 365, in sage.libs.ecl.python_to_ecl (sage/libs/ecl.c:3292) File "ecl.pyx", line 282, in sage.libs.ecl.ecl_safe_read_string (sage/libs/ecl.c:2805) File "ecl.pyx", line 265, in sage.libs.ecl.ecl_safe_funcall (sage/libs/ecl.c:2650) RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined. On Thursday, May 24, 2012 2:44:07 PM UTC-4, MathLynx wrote: > > The code find_minimum_on_interval(x*sin(x),.5,2.5) works like a > charm, giving (0.23971279031301418, 0.5000000228822995) as output. > > But the code find_maximum_on_interval(x*sin(x),.5,2.5) gives a mess. > Plotting works fine ( plot(x*sin(x),(x,.5,2.5)) ). > > Is there some notational issue here? Some issue that works for min but > not max? > > John A. Velling > -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org