# [Maxima] mcond

Robert Dodier robert.dodier at gmail.com
Sun Jul 20 14:06:05 CDT 2008

```On 7/20/08, amli at comcast.net <amli at comcast.net> wrote:

> I am running into mcond and  I do not know how to evaluate these.
> I tried using double quotes and ev function without success.

Well, your function lambda([x],'if x<0 then 0 else 1) returns a so-called
noun expression (because of the single quote on the operator).
ev(expr, nouns) causes nouns to be evaluated.
I think ev(sum, x=whatever, nouns) should yield a numeric result for you.

As for the appearance of mcond, I think you must be using an old
version of Maxima; I'm pretty sure the display of 'if nouns was fixed
a couple of years ago. Also the policy for evaluation of if--then--else
was modified a couple of years ago so you could probably omit
the quote mark and just write lambda([x], if x < 0 ...) instead.

Here's what I get (current CVS version).
With c64, c65, ipt1, sfn, and sum as you have defined them:

sum;
=> [(2*x-5)^2*(if x-3 < 0 then 0 else 1)/9
-(2*x-5)^2*(if x-4 < 0 then 0 else 1)/9
+(2*x-7)^2*(if x-4 < 0 then 0 else 1)/10
-(2*x-7)^2*(if x-5 < 0 then 0 else 1)/10
+(2*x-9)^2*(if x-5 < 0 then 0 else 1)/8
-(2*x-9)^2*(if x-6 < 0 then 0 else 1)/8
+(2*x-11)^2*(if x-6 < 0 then 0 else 1)/8
-(2*x-11)^2*(if x-7 < 0 then 0 else 1)/8,
-4*(x-1)*(8*x-23)*(if x-3 < 0 then 0 else 1)/45
+(-36*x^2+212*x-281)*(if x-4 < 0 then 0 else 1)/40
+4*(x-1)*(8*x-23)*(if x-4 < 0 then 0 else 1)/45
+(-4*x^2+32*x-61)*(if x-5 < 0 then 0 else 1)/4
-(-36*x^2+212*x-281)*(if x-5 < 0 then 0 else 1)/40
-(-4*x^2+32*x-61)*(if x-6 < 0 then 0 else 1)/4
+(-36*x^2+364*x-889)*(if x-6 < 0 then 0 else 1)/40
-(-36*x^2+364*x-889)*(if x-7 < 0 then 0 else 1)/40,
4*(x-1)^2*(if x-3 < 0 then 0 else 1)/15
+(2*x-5)^2*(if x-4 < 0 then 0 else 1)/8
-4*(x-1)^2*(if x-4 < 0 then 0 else 1)/15
-(2*x-5)^2*(if x-5 < 0 then 0 else 1)/8
+(2*x-7)^2*(if x-5 < 0 then 0 else 1)/8
-(2*x-7)^2*(if x-6 < 0 then 0 else 1)/8
+(2*x-9)^2*(if x-6 < 0 then 0 else 1)/10
-(2*x-9)^2*(if x-7 < 0 then 0 else 1)/10]

sum, x = 9/2, nouns;
=> [2/5,-7/5,2]

I recommend against using a variable named sum, since there is
a Maxima function by the same name. But it doesn't seem to have
caused any trouble in this example.

HTH

Robert Dodier
```