#728 Plot2D can't plot IF THEN predicate

closed
nobody
None
5
2005-04-26
2005-04-25
Rod Ival
No

Maxima version: 5.9.1
Maxima build date: 7:34 9/24/2004
host type: i686-pc-mingw32
lisp-implementation-type: Kyoto Common Lisp
lisp-implementation-version: GCL 2.6.5

(%i1)f(x):= if x>0 then x else -x;
(%i2)plot2d(f(x),[x,1,2]);
MACSYMA was unable to evaluate the predicate:
x > 0
#0: f(x=x)
-- an error. Quitting. To debug this try DEBUGMODE
(TRUE);

Discussion

  • Barton Willis

    Barton Willis - 2005-04-26

    Logged In: YES
    user_id=895922

    To plot f, you'll need to quote the first argument to plot2d.

    (%i1) f(x):= if x>0 then x else -x;
    (%o1) f(x):=if x>0 then x else -x
    (%i2) plot2d('(f(x)),[x,1,2]);

    Maxima handles if--then--else expressions poorly.

    Barton

     
  • Rod Ival

    Rod Ival - 2005-04-26

    Logged In: YES
    user_id=729768

    Sorry, I've found my mistake:
    (%i1)f(x):= if x>0 then x else -x;

    solved with:
    (%i2)plot2d('f,['x,1,2]);

    but this (your one) work too:
    (%i2) plot2d('(f(x)),['x,1,2]);

     
  • Barton Willis

    Barton Willis - 2005-04-26
    • status: open --> closed
     
  • Barton Willis

    Barton Willis - 2005-04-26

    Logged In: YES
    user_id=895922

    Not a problem. I'll close the bug.

    Barton

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks