>How can I make the function to evaluate at x=1.5 in %o5 instead of
>giving me the definition of the function.
Try something like: (notice the subst('x = x, ...)
(%i7) tLis:[1.0,2.0,3.0];
pp:[x, x^2+1];
gg:lambda([i,x],if (x>=tLis[i] and x<tLis[i+1]) then subst('x = x,pp[i])
else 0);
g:lambda([x],gg(1,x) + gg(2,x));
(%o7) [1.0,2.0,3.0]
(%o8) [x,x^2+1]
(%o9) lambda([i,x],if x>=tLis[i] and x<tLis[i+1] then subst('x=x,pp[i])
else 0)
(%o10) lambda([x],gg(1,x)+gg(2,x))
(%i11) g(1.5);
(%o11) 1.5
>In general pp may involve large sequence of functions (same for tLis).
As you defined pp, it is a list of expressions, not a list of functions.
You might like
to consider passing pp and tLis as arguments to gg. If you change x to a
different
symbol, you'll break your code. Is that what you want?
Barton