help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plot and graphs


From: Mahvish Nazir
Subject: Re: plot and graphs
Date: Mon, 3 Sep 2012 13:49:22 +0100



On Mon, Sep 3, 2012 at 1:45 PM, Doug Stewart <address@hidden> wrote:


On Mon, Sep 3, 2012 at 8:38 AM, Andy Buckle <address@hidden> wrote:
On 3 September 2012 13:14, James Sherman Jr. <address@hidden> wrote:
> On Mon, Sep 3, 2012 at 7:59 AM, Mahvish Nazir <address@hidden>
> wrote:
>>
>>
>>
>> On Mon, Sep 3, 2012 at 12:38 PM, Andy Buckle <address@hidden> wrote:
>>>
>>> On 3 September 2012 12:09, Mahvish Nazir <address@hidden>
>>> wrote:
>>> > Can we plot the integrals using octave. I know we can plot functions
>>> > but can
>>> > we plot the integral of the function? please help
>>>
>>> Why not?
>>>
>>> >x=0:.1:1;
>>> >y=x;
>>> >plot(x,y)
>>> >hold on
>>> >q=cumtrapz(x,y);
>>> >plot(x,q)
>>> >plot(x,x^2/2,'x')
>>>
>>>
>>> --
>>> /* andy buckle */
>>
>>
>> Thanks Andy!
>> What if we have a function say (cos(t^2))^2*exp(i*t) and we want to plot
>> its integral over the limits -5 to 5? how do we do that?
>>
>> _______________________________________________
>> Help-octave mailing list
>> address@hidden
>> https://mailman.cae.wisc.edu/listinfo/help-octave
>>
>
> I'm not sure what you mean here.  Do you want to evaluate the integral from
> -5 to 5 of that function?  If so, you can just take the same steps that Andy
> did with the numerical estimation of the integral.  I'm not sure what you
> want to plot here.
>
> James Sherman

That is a nasty function (assuming i=sqrt(-1)). I don't know if your
answer will be sufficiently accurate if you just use small steps in t
with a trapezoidal method. I think it is only trapz and sum that have
the versions that tell you the intermediate integrals (cumtrapz and
cumsum).

I would probably try using a loop and a cleverer numerical integration
function and do it in small bits. There is probably a better way.

However you do it, estimate your uncertainty.

--
/* andy buckle */
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave


Maxima can integrate it  :-)


(%i3) integrate((cos(t^2))^2*exp(%i*t),t);
                                1                 1
(%o3) (sqrt(%pi) (((%i + 1) sin(-) + (1 - %i) cos(-))
                                8                 8
     (4 %i + 4) t - %i - 1                  1                   1
 erf(---------------------) + ((%i - 1) sin(-) + (- %i - 1) cos(-))
               4                            8                   8
     (4 %i - 4) t + %i - 1
 erf(---------------------)) + 8 sin(t) - 8 %i cos(t))/16
               4


--
DAS

https://linuxcounter.net/user/206392.html

This is not the actual function only a part of it. I have tried maxima with my complete function. It says _expression_ too long to display. However I am more interested in the plot/graph rather than the solution. Maxima cant plot it
reply via email to

[Prev in Thread] Current Thread [Next in Thread]