I have some piecewise functions that I need to use. I could use the unit_step function but I need
a variant of it defined at end points. These functions are outcomes of other results and need to be used in another program. I am running into mcond and I do not know how to evaluate these. I tried using double quotes and ev function without success. Here are the relevant maxima code ( I am trying to evaluate the expression sum, say for some value of x). I want sum to be for this particular case
f1:lambda([x],if x<5/2 then ev(c64[1])
elseif x<7/2 then ev(c64[2])
elseif x<9/2 then ev(c64[3])
elseif x<11/2 then ev(c64[4])
else ev(c64[5])
);
).
Thank you for your help.
Ram
c64:[[(2*x-5)^2/9,-(4*(x-1)*(8*x-23))/45,(4*(x-1)^2)/15],[(2*x-7)^2/10,-(36*x^2-212*x+281)/40,(2*x-5)^2/8],[(2*x-9)^2/8,-(4*x^2-32*x+61)/4,(2*x-7)^2/8],[(2*x-11)^2/8,-(36*x^2-364*x+889)/40,(2*x-9)^2/10],[(4*(x-7)^2)/15,-(4*(x-7)*(8*x-41))/45,(2*x-11)^2/9]];
c65:[[-(x-3)^3/8,((x-1)*(19*x^2-128*x+217))/72,-((x-1)^2*(31*x-121))/180,(x-1)^3/30],[-(x-4)^3/9,(11*x^3-123*x^2+438*x-476)/45,-(11*x^3-108*x^2+333*x-336)/45,(x-3)^3/9],[-(x-6)^3/30,((x-6)^2*(31*x-96))/180,-((x-6)*(19*x^2-138*x+252))/72,(x-4)^3/8]];
ipt1:[3,1.75,4,3.0,5,4.0,6,5.0,7,6.25]; /** odd index represents breaks in the function **/
sfn:lambda([x],'if x<0 then 0 else 1); /** step function **/
sum:0;
for i:1 thru length(ipt1)/2 - 1 do
( print(sfn(x-ipt1[2*i-1])*c64[i] - sfn(x-ipt1[2*i+1])*c64[i]),
sum: sum + sfn(x-ipt1[2*i-1])*c64[i] - sfn(x-ipt1[2*i+1])*c64[i]);
/** outcome of above which needs to be evaluated for x in another program **/
sum:
[((2*x-5)^2*(mcond(x-3<0,0,true,1)))/9-((2*x-5)^2*(mcond(x-4<0,0,true,1)))/9+((2*x-7)^2*(mcond(x-4<0,0,true,1)))/10-((2*x-7)^2*(mcond(x-5<0,0,true,1)))/10+((2*x-9)^2*(mcond(x-5<0,0,true,1)))/8-((2*x-9)^2*(mcond(x-6<0,0,true,1)))/8+((2*x-11)^2*(mcond(x-6<0,0,true,1)))/8-((2*x-11)^2*(mcond(x-7<0,0,true,1)))/8,-(4*(x-1)*(8*x-23)*(mcond(x-3<0,0,true,1)))/45-((36*x^2-212*x+281)*(mcond(x-4<0,0,true,1)))/40+(4*(x-1)*(8*x-23)*(mcond(x-4<0,0,true,1)))/45+((36*x^2-212*x+281)*(mcond(x-5<0,0,true,1)))/40-((4*x^2-32*x+61)*(mcond(x-5<0,0,true,1)))/4-((36*x^2-364*x+889)*(mcond(x-6<0,0,true,1)))/40+((4*x^2-32*x+61)*(mcond(x-6<0,0,true,1)))/4+((36*x^2-364*x+889)*(mcond(x-7<0,0,true,1)))/40,(4*(x-1)^2*(mcond(x-3<0,0,true,1)))/15+((2*x-5)^2*(mcond(x-4<0,0,true,1)))/8-(4*(x-1)^2*(mcond(x-4<0,0,true,1)))/15-((2*x-5)^2*(mcond(x-5<0,0,true,1)))/8+((2*x-7)^2*(mcond(x-5<0,0,true,1)))/8-((2*x-7)^2*(mcond(x-6<0,0,true,1)))/8+((2*x-9)^2*(mcond(x-6<0,0,true,1)))/10-((2*x-9)^2*(mcond(x-7<0,0,true,1)))/10];