# [Maxima] plotting a parametric integral

Richard Hennessy rich.hennessy at verizon.net
Fri Oct 9 20:16:09 CDT 2009

```Of course as stated before if k is known then Maxima can do the problem.  It
cannot do the general case for arbitrary k.

Rich

----- Original Message -----
From: "Richard Hennessy" <rich.hennessy at verizon.net>
To: "Leo Butler" <l.butler at ed.ac.uk>; "Stanislav Maslovski"
<stanislav.maslovski at gmail.com>
Cc: <maxima at math.utexas.edu>
Sent: Friday, October 09, 2009 9:04 PM
Subject: Re: [Maxima] plotting a parametric integral

> This integral cannot be done by Maxima.  Try
>
> (%i4) display2d:false;
>
> (%o4) false
>
> (%o5)
> "C:/Maxima-5.19.2/share/maxima/5.19.2/share/contrib/noninteractive/noninteractive.mac"
> (%i6) integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf);
>
> (%o6) if k-1 < 0 then integrate(%e^(%i*k*x)*sin(x)/x,x,minf,inf) elseif
> equal(k-1,0) then %pi else 0
>
> The answer shows that when k-1<0 Maxima can't do the integration.
>
> Rich
>
> ----- Original Message -----
> From: "Leo Butler" <l.butler at ed.ac.uk>
> To: "Stanislav Maslovski" <stanislav.maslovski at gmail.com>
> Cc: <maxima at math.utexas.edu>
> Sent: Friday, October 09, 2009 4:03 AM
> Subject: Re: [Maxima] plotting a parametric integral
>
>
>>
>>
>> On Fri, 9 Oct 2009, Stanislav Maslovski wrote:
>>
>> < Hello,
>> <
>> < I am trying to plot this simple Fourier integral in Maxima 5.17.1:
>> <
>> < (%i1) display2d : false\$
>> <
>> < (%i2) f(k):=integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf)\$
>> <
>> < (%i3) [f(0), f(1), f(3/2)];
>> <
>> < (%o3) [%pi,%pi,0]
>> <
>> < So far so good.
>> <
>> < (%i4) plot2d(f,[x,-3,3]);
>> <
>> < (%o4)
>> < (%i5) Warning: empty y range [0:0], adjusting to [-1:1]
>> <
>> < Theoretically, f(k) must be equal to %pi for k in [-1;1] and 0
>> < outside. The plot does not show anything in [-1;1].
>> <
>> < Moreover, if I try this plotting command
>> <
>> < plot2d(f(k),[k,-3,3]);
>> <
>> < I get a stupid question about the sign of k-1.
>> <
>> < Can anyone explain what is wrong here?
>>
>> There are a few things. The integral, f(k), is a piece-wise constant
>> function. At the moment, Maxima lacks the ability to return an answer in
>> this form. Work is being done to correct this.
>>
>> I would suggest that you try the following definition:
>>
>> (%i2) f(t) ::= buildq([k:t],
>> integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf));
>> (%o2) f(t)::=buildq([k:t],integrate(exp(%i*k*x)*sin(x)/x,x,minf,inf))
>>
>> of k) when t is a constant. I have also set ratprint to false to avoid
>> the annoying warnings about floats being converted to rationals.
>>
>> (%i3) l : makelist(i/10,i,-20,20)\$
>> (%i4) fl : float(map(f,l));
>> (%o4) [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,3.141592653589793,
>>       3.141592653589793,3.141592653589793,3.141592653589793,
>>       3.141592653589793,3.141592653589793,3.141592653589793,
>>       3.141592653589793,3.141592653589793,3.141592653589793,
>>       3.141592653589793,3.141592653589793,3.141592653589793,
>>       3.141592653589793,3.141592653589793,3.141592653589793,
>>       3.141592653589793,3.141592653589793,3.141592653589793,
>>       3.141592653589793,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
>> (%i5) plot2d([discrete,l,fl]);
>> This plots what you want.
>>
>> Incidentally, you will find that this is very slow. The problem is that
>> the integral is being recomputed each time f is evaluated. What you
>> would really want to do is to compute the integral once, as a symbolic
>> facility is under development.
>>
>> Note that you can also use 'assume':
>>
>> (%i35) [ (map(forget,facts()), assume(k<-1),f(k)) , (forget(k<-1),
>> assume(k>1),f(k)) , (forget(k>1), assume(k>-1,k<1),f(k)), f(-1), f(1) ];
>> (%o35) [0,0,%pi,0,%pi]
>>
>> Leo
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>> _______________________________________________
>> Maxima mailing list
>> Maxima at math.utexas.edu
>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>

```