On 2013-01-19, Philippe Piot <piot at nicadd.niu.edu> wrote:
> So why when I type Vm(I0, a, b, tau, T, w,k, t) I do not get a
> result where the integral have been evaluated -- something like
>
> if t<=tau then 2*a*(1/w^2-cos(t*w)/w^2)*I0 else
> 2*(b/w^2-((b*tau-1)*w*sin((tau-t)*w)+b*cos((tau-t)*w))/w^2)*I0+2*a*((tau*w*sin((tau-t)*w)+cos((tau-t)*w))/w^2-cos(t*w)/w^2)*I0
"if" does not evaluate its branches until the condition evaluates to
true or false. Integrals are computed by evaluation (not simplification
-- this is an important distinction in Maxima) so the integrals aren't
computed until t <= tau has a definite Boolean value.
My advice is to construct the function something like:
I1 : integrate (...);
I2 : integrate (...);
I3 : integrate (...);
foo (t, tau) := if t <= tau then ''I1 else ''I2 + ''I3;
Note the use of quote-quote (two single quotes) to interpolate the
current values of I1, I2, & I3 into the function definition; otherwise
the function body would contain variables I1, I2, I3 instead of their
values.
I don't know any easy way to cause "if" to evaluate its branches. It
seems like a reasonable thing to do in some circumstances.
Robert Dodier