|
From: Eduardo O. <edu...@gm...> - 2024-11-28 02:25:22
|
Hi list,
I tried to replace the `integrate' of my last question with a variant
that calls `quad_qagi':
integrate_qagi(f,x,a,b) := quad_qagi(f,x,a,b)[1]$
f(x) := if x<0 then 0
elseif x<1 then 1
else 0;
g(x) := if x<0 then 0
elseif x<1 then x
else 0;
h(x) := integrate_qagi(f(t)*g(x-t), t, minf, inf);
draw2d(xrange=[-4,4],
yrange=[-4,4],
proportional_axes=xy,
explicit(h(w),w,-4,4));
Now calculating h(x) at specific points works:
h(0.0042906454260024365);
h(0.5);
h(0.1);
h(-1);
h(-2);
h(-3);
but the draw2d above fails with this error...
quad_qagi: Numerical evaluation of (if t < 0 then 0 elseif t < 1 then 1
else 0)
(if w - t < 0 then 0 elseif w - t < 1 then w - t else 0) at
0.0042906454260024365 is not a float or is not defined
Is that a bug?
Thanks in advance!
Eduardo Ochs
On Wed, 27 Nov 2024 at 18:56, Eduardo Ochs <edu...@gm...> wrote:
> Hi list,
>
> what is the recommended way to integrate piecewise defined
> functions? I tried this,
>
> f(x) := if x<0 then 0
> elseif x<1 then 1
> else 0;
> g(x) := if x<0 then 0
> elseif x<1 then x
> else 0;
> h(x) := integrate(f(t)*g(x-t), t, -2, +2);
>
> and I couldn't find a way to make Maxima calculate this
> integral...
>
> integrate(f(x), x, -2, 4);
> float(integrate(f(x), x, -2, 4));
>
> The convolution left Maxima even more confused, obviously...
> Thanks in advance!
> Eduardo Ochs
> http://anggtwu.net/eev-maxima.html
> http://anggtwu.net/eev-qdraw.html
>
|