home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math.symbolic
- Path: sparky!uunet!cs.utexas.edu!wupost!darwin.sura.net!Sirius.dfn.de!chx400!bernina!neptune!monagan
- From: monagan@inf.ethz.ch (Michael)
- Subject: Re: plots and eval
- Message-ID: <1992Sep11.135137.22089@neptune.inf.ethz.ch>
- Summary: plot3d functionality in Maple
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: rutishauser-gw.inf.ethz.ch
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- References: <1992Sep10.164017.3507@magnus.acs.ohio-state.edu>
- Date: Fri, 11 Sep 1992 13:51:37 GMT
- Lines: 62
-
- In article <1992Sep10.164017.3507@magnus.acs.ohio-state.edu>, hmarvel@magnus.acs.ohio-state.edu (Howard P Marvel) writes:
- > Consider the following series of statements in Maple:
- >
- > c := proc (alpha,beta) if signum(alpha+beta)=1 then alpha+ beta else 0 fi en\
- > d;
- > c(a,b);
- > a:=1;
- > b:=1;
- > c(a,b);
- > plot3d(c(x,y),x=0..1,y=0..1);
- >
- > The first sets up a proc that returns alpha + beta if alpha + beta is
- > a positive real. However, if alpha and beta are variables, signum
- > cannot evaluate the expression, and the proc returns 0. The first call
- > c(a,b) returns 0 and the second returns 2. Now consider the plot
- > statement. This should yield values from 0 to 2, right? Instead,
- > signum fails and all plotted values are 0. My question is, is there a
- > way to force Maple to evaluate c for the values in question and to
- > plot the values?
- >
- > Thanks in advance for any suggestions.
-
- Dear Howard,
-
- The plot3d function has no special evaluation rules. The arguments
- get evaluated, then function is executed. So what happens when you do
-
- plot3d( c(x,y), x=0..1, y=0..1 );
-
- is that c(x,y) is executed on symbolic x and y, and this returns 0,
- so it's just as if you had written plot3d( 0, x=0..1, y=0..1 );
- The plot3d command has two ways of being called. You can plot either
- a formula in x and y, or a function of two variables. Consider
-
- plot3d( binomial(n,k), n=0..3, k=0..3 );
-
- versus
-
- plot3d( binomial, 0..3, 0..3 );
-
- The second way allows you to plot a function of two variables defined
- by a Maple procedure or operator expression. So the simple solution
- to your problem is
-
- plot3d( c, -1..1, -1..1 );
-
- The alternative is to use quotes to prevent c(x,y) being evaluated
- before the plot routine gets the expression, i.e.
-
- plot3d( 'c(x,y)', x=-1..1, y=-1..1 );
-
- Some more examples to clarify.
-
- plot3d( 'binomial(x,y)*c(x,y)', x=-3..3, y=-3..3 );
- plot3d( binomial*c, -3..3, -3..3 );
-
- These are wrong
-
- plot3d( 'binomial(x,y)*c(x,y)', -3..3, -3..3 );
- plot3d( binomial*c, x=-3..3, y=-3..3 );
-
- Mike Monagan
-