help-octave
[Top][All Lists]
Advanced

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

Re: definite integral of arbitrary function


From: Martin Helm
Subject: Re: definite integral of arbitrary function
Date: Fri, 27 Apr 2012 12:20:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0

Am 27.04.2012 11:55, schrieb rdurkacz:
> Thankyou Juan for your answer, I appreciate it. However it may be that you
> have misunderstood my question.
> If I use one of the quad functions, that function requires a function as an
> argument and two limits and returns
> a number. I know about this; I want more than this; I want a function in
> return. Thus if f is defined as a function in
> octave I wish to write g= adiff (h); (adiff -"anti-derivative", and I am
> neglecting some boundary condition argument here).
> g should just as good a function as f is, and I should be able to write
> g([0:0.1:1]), quad (g, ...), lsode (g, ...) etc.
>
> It is obvious how to write adiff as a special case of lsode but I run into
> practical problems as mentioned. Also as mentioned, there 
> are unanswered posts that seem to touch on this question. One is this:
>
> Marcin Sleczka
> Dec 14, 2008; 12:52am
> Re: Numerical Integration
> I suspect it is the same question as mine, but not understood and ultimately
> unanswered.
>
> Another relevant note is this:
> Paul Thomas
> Jul 25, 2004; 11:57pm
> integration function
> It discusses which is better when for integration, quadxx or lsode.
>
> Sorry if I am missing something basic. I first tried with MathCad, now with
> with Octave assuming it does the same as Matlab.
> ie I am a beginner with Octave if that is not obvious.
>
I am really not sure if I understand exactly what you want. There is of
course the arbitrary additive constant you have somehow to fix for
example by using a fixed point where the integration starts and then you
can do something like this

adiff = @(f) @(x) quad(f, 0, x);

or as an ordinary function

function af = adiff(f)
    af = @(x) quad(f, 0, x);
endfunction

adiff returns a function handle which you can use as any other function

c = adiff(@sin);
c(pi)
    ans =  2
 




reply via email to

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