Editing Symbolic package
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
The {{Forge|symbolic|symbolic package}} is part of the | The {{Forge|symbolic|symbolic package}} is part of the octave-forge project. | ||
[[Category:Octave Forge]] | [[Category:Octave-Forge]] | ||
Demo of Anonymous function to symbolic function and back to anonymous function | |||
and then the use of the interval pkg. | |||
% this is just a formula to start with | |||
% have fun and change it if you want to. | % have fun and change it if you want to. | ||
f = @(x) x.^2 + 3*x - 1 + 5*x.*sin(x); | 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; | syms x; | ||
ff = f(x); | |||
ff=formula(f(x)); | |||
% now calculate the derivative of the function | % now calculate the derivative of the function | ||
ffd = diff(ff | ffd=diff(ff); | ||
% and convert it back to an Anonymous function | % and convert it back to an Anonymous function | ||
df = function_handle(ffd) | df=function_handle(ffd) | ||
% this uses the interval pkg to find all the roots between -15 an 10 | % this uses the interval pkg. to find all the roots between -15 an 10 | ||
fzero (f, infsup (-15, 10), df) | fzero (f, infsup (-15, 10), df) | ||
Line 105: | Line 35: | ||
[-5.743488743719015, -5.743488743719013] | [-5.743488743719015, -5.743488743719013] | ||
[-3.0962279604822407, -3.09622796048224] | [-3.0962279604822407, -3.09622796048224] | ||
[-0.777688831121563, -0.7776888311215626] | |||
[0.22911205809043574, 0.2291120580904359] | |||