help-octave
[Top][All Lists]
Advanced

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

Re: Here is a dem of how to use the symbolic pkg. for derivatives of ano


From: Doug Stewart
Subject: Re: Here is a dem of how to use the symbolic pkg. for derivatives of anonymous functions
Date: Mon, 29 Jun 2015 06:25:44 -0400



On Mon, Jun 29, 2015 at 12:41 AM, Oliver Heimlich <address@hidden> wrote:
On 29.06.2015 02:32, Doug Stewart wrote:
It also demos Newton-Raphson roots.

Doug,

thanks for pointing me to this feature of the symbolic package. Did you know the “interval Newton method”? It computes enclosures of /all/ zeros of a function in a given domain and is globally convergent.

I have implemented it in the interval package and it can make great use of this particular feature to compute a derivative.

Oliver


% this is just a formula to start with
% have fun and change it if you want to.
f=@(x) x.^2 +3*x-1 + 5*x.*sin(x);

% the next 2 line take the Anonymous function into a symbolic formula
syms x;
ff=formula(f(x));
% now calculate the derivative of the function
ffd=diff(ff);
% and convert it back to an Anonymous function
df=function_handle(ffd)

fzero (f, infsup (-15, 10), df)

ans ⊂ 4×1 interval vector

    [-5.743488743719015, -5.743488743719013]
    [-3.0962279604822407, -3.09622796048224]
   [-0.777688831121563, -0.7776888311215626]
   [0.22911205809043574, 0.2291120580904359]

Wow.
We need mor show and tell like this.

Glad to be of some help.
I was just trying to learn the symbolic pkg., and this is one practical thing that came to mind.

The use of the 'double' to move from vpa back to octave variables is also handy.

Doug


reply via email to

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