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]] | ||
=== Demos and usage examples === | === Demos and usage examples === | ||
* '''Demo of Anonymous function to symbolic function and back to anonymous function and then the use of the interval pkg.''' | * '''Demo of Anonymous function to symbolic function and back to anonymous function and then the use of the interval pkg.''' | ||
Line 79: | Line 11: | ||
% 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 107: | Line 38: | ||
[-0.777688831121563, -0.7776888311215626] | [-0.777688831121563, -0.7776888311215626] | ||
[0.22911205809043574, 0.2291120580904359] | [0.22911205809043574, 0.2291120580904359] | ||
</source> | </source> | ||
Line 160: | Line 62: | ||
## | ## | ||
syms y(x) | syms y(x) | ||
de =diff(y, 3 ) +sqrt(2)*diff(y,2) + diff(y) == 0; | |||
de =diff(y, 3 ) + | |||
f = dsolve(de, y(0) == 0, diff(y,1)(0) == 0 , diff(y,2)(0) == 1) | f = dsolve(de, y(0) == 0, diff(y,1)(0) == 0 , diff(y,2)(0) == 1) | ||
ff=function_handle(rhs(f)) | ff=function_handle(rhs(f)) | ||
Line 168: | Line 69: | ||
plot(x1,y) | plot(x1,y) | ||
grid minor on | grid minor on | ||
</source> | </source> |