help-octave
[Top][All Lists]
Advanced

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

Re: Confused by Integration


From: CdeMills
Subject: Re: Confused by Integration
Date: Tue, 16 Aug 2011 00:42:05 -0700 (PDT)

Jason C. Wells wrote:
> 
> I am confused by integration.  I see that the various quad function take 
> different types (scalar, vector) and give different outputs.  I've been 
> trying them out and watching how the quadrature behaves for each of 
> them. E.g:
> 
>          function retval = integrand (x)
>              x
>              retval = x .^ 2
>          endfunction
> 
>          # integral = quadv ("integrand", -Inf, Inf)
> 
>          a = -10: 1: 10;
>          integral = quadgk ("integrand", a(1), a(end))
> 
> Quadgk seems close to what I want, but the variable of integration 
> "bounces around" which makes plotting impossible.
> 
> x=
>        -9.999989
>        -9.435377
>        -7.911791
>        -5.669229
>        -2.947694
>         0.012817
>         2.972302
>         5.690762
>         7.928196
> 
> Ultimately I'd like to make a plot of the integral.  It seems that all 
> of the quadrature functions do not pay attention to the the range i've 
> given.  The functions do their own thing within the limits of integration.
> 
> Does a person need to run the integration, then re-sort and 
> re-interpolate in order to produce outputs at evenly spaced inputs?
> 
> How do I integrate such that each output value corresponds with an input 
> value taken from a range of from a linspace vector?
> 
> 

For the first point: contribution are done by volunteers. They have time to
code. Having a nice and unified interface to a lot of functions requires a
lot of work.
Second point: I suppose they're some kind of refinment algorithm, this
explains the bouncing back behaviour. If it's a problem, either try to
decompose it into ordered sequences, either sort them.
For the last point, I don't understand the issue. Either you're interested
into the integral, which is a scalar result, either you've a function
defined  by a differential relationship. In the latter case, what you should
use is a function like lsode or similar. It will compute the integral over
segments defined by the user, so you have control over the points spacing.

Regards

Pascal

--
View this message in context: 
http://octave.1599824.n4.nabble.com/Confused-by-Integration-tp3743591p3746560.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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