[Maxima] parsing arguments for functions
rich.hennessy at verizon.net
Thu Jun 4 21:28:18 CDT 2009
I think you have to define f(x,y) as
if length(v) = 2 then
if not freeof('Interval,first(v)) and not freeof('Interval, second(v)) then
first(v) * second(v)
error("Function takes two arguments")
----- Original Message -----
From: "Sheldon Newhouse" <sen1 at math.msu.edu>
To: <maxima at math.utexas.edu>
Sent: Thursday, June 04, 2009 9:40 PM
Subject: [Maxima] parsing arguments for functions
Suppose I have a function f(x,y) which does different operations for
different types of arguments. How can I parse the arguments of f(x,y)
and decide what properties x and y have?
For instance, the function f(x,y) = x*y already does this, say for x, y
real numbers or matrices.
How can I do this for other types of arguments?
For instance, consider real closed intervals [a,b] denoted by Interval(a,b).
Then, the usual definition of the multiplication is
Interval(a,b)*Interval(c,d) = Interval(min(ac,ad,bc,bd),max(ac,ad,bc,bd))
Suppose f(x,y) = x*y
Then, I would like to have '*' defined so that
if x, y are real numbers, then f(x,y) = x*y is the usual product,
but if x=Interval(a,b) and y=Interval(c,d), then
Is there a simple way this can be done?
TIA for any suggestions.
Maxima mailing list
Maxima at math.utexas.edu
More information about the Maxima