>>>>> "Raymond" == Raymond Toy <toy.raymond at gmail.com> writes:
Raymond> On 3/21/11 8:33 PM, Jaime Villate wrote:
>> Hi,
>>
>> (%i4) f(x):= sin(x)/x$ (%i5) plot2d(f(x), [x,-8,8]); plot2d:
>> expression evaluates to non-numeric value somewhere in plotting
>> range. (%o5) (%i6) plot2d(f, [x,-8,8]); expt: undefined: 0 to
>> a negative exponent.
>> #0: f(x=0.0)
>>
>> %i5 shows the plot correctly but %i6 does not.
>> The expression sin(x)/x gives no problem for x=0, but when the
>> function
Raymond> Nice. The problem is in
Raymond> coerce-maxima-function-or-maxima-lambda. It needs an
Raymond> (catch 'errorsw foo) like what is done in
Raymond> %coerce-float-fun. With this change, we don't get the
Raymond> error and the plot comes out the same.
Here is a possible patch.
Ray
--- plot.lisp 07 Jan 2011 09:14:53 -0500 1.169
+++ plot.lisp 22 Mar 2011 09:07:58 -0400
@@ -708,11 +708,20 @@
(let* (($ratprint nil)
($numer t)
(*nounsflag* t)
- (result (maybe-realpart (mapply ',expr (list , at gensym-args) t))))
- ;; Just always try to convert the result to a float, which
- ;; handles things like $%pi. See also BUG #2880115
- ;; http://sourceforge.net/tracker/?func=detail&atid=104933&aid=2880115&group_id=4933
- (,float-fun result)))
+ (errorsw t)
+ (errcatch t))
+ (declare (special errcatch))
+ ;; Just always try to convert the result to a float,
+ ;; which handles things like $%pi. See also BUG
+ ;; #2880115
+ ;; http://sourceforge.net/tracker/?func=detail&atid=104933&aid=2880115&group_id=4933
+ ;;
+ ;; Should we use HANDLER-CASE like we do above in
+ ;; %coerce-float-fun? Seems not necessary for what we want
+ ;; to do.
+ (catch 'errorsw
+ (,float-fun
+ (maybe-realpart (mapply ',expr (list , at gensym-args) t))))))
'function)))
;; Same as above, but call APPLY instead of MAPPLY.