Editing Symbolic package
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 160: | Line 91: | ||
## | ## | ||
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 169: | Line 99: | ||
grid minor on | grid minor on | ||
* '''Demo of how to suppress a warning about converting from floating point numbers to symbolic numbers. | |||
## Demo of how to use a number (which was calculated in an octave | |||
## variable) in a symbolic calculation, without getting a warning. | |||
## use octave to calculate some number: | |||
a=pi/2 | |||
## now do some work with the symbolic pkg | |||
syms x | |||
f = x * cos(x) | |||
df = diff(f) | |||
## Next get the number into a symbolic variable | |||
## convert to string first | |||
aa=mat2str(a) | |||
## and now to a symbolic variable. | |||
ww=sym(aa) | |||
## and now use it | |||
vpa(subs(df, x, ww), 28) | |||
</source> | </source> |