home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math.symbolic
- Path: sparky!uunet!utcsri!torn!watserv2.uwaterloo.ca!watdragon.uwaterloo.ca!watdragon!drclark
- From: drclark@daisy.uwaterloo.ca (David R. Clark)
- Subject: Re: Help with user defined functions in Maple.
- In-Reply-To: jmp1@ns1.cc.lehigh.edu's message of 17 Dec 92 06:07:55 GMT
- Message-ID: <DRCLARK.92Dec17103709@daisy.uwaterloo.ca>
- Sender: news@watdragon.uwaterloo.ca (USENET News System)
- Organization: University of Waterloo, Waterloo, Ontario, Canada
- References: <1992Dec17.060755.53708@ns1.cc.lehigh.edu>
- Date: Thu, 17 Dec 1992 15:37:09 GMT
- Lines: 45
-
- jmp1@ns1.cc.lehigh.edu (JEFFREY MICHAEL PARSONS) writes:
-
- From: jmp1@ns1.cc.lehigh.edu (JEFFREY MICHAEL PARSONS)
- Subject: Help with user defined functions in Maple.
-
- I tried defining a function in Maple V r1.1 like this:
-
- f := proc(x) if x<0 then -1 else 1 fi; end;
-
- I could then type f(3) or f(-100) and get the correct result. The
- problem is that I can't integrate it, etc. I always get:
-
- Error, (in f) cannot evaluate boolean.
-
- Is there a better way to be doing this kind of thing?
-
- Thanks.
- --
-
- The procedure you have written does not allow for the possibility that
- the parameter may be an expression that cannot be compared to zero.
-
- The procedure can be better defined as:
-
- f := proc(x) if not type(x,numeric) then 'procname(x)'
- elif x<0 then -1
- else 1 fi;
- end;
-
- When supplied with a non-numeric parameter this new function returns
- without evaluating. It can be numerically integrated, plotted,
- and manipulated in Maple. Allowing symbolic integration of user defined
- functions is a much more difficult question.
-
- You can also work with your original function by using the Maple
- quote operator to disable evaluation of the expressions, e.g.:
-
- > f := proc(x) if x<0 then -1 else 1 fi; end;
-
- f := proc(x) if x < 0 then -1 else 1 fi end
-
- > evalf(Int('f(x)',x=-1..1));
-
- 0
-
-