% This script plot derivetive fd(x) of the function f(x).
% The script use the function_handle function to create numeric
% function ffd from dff(x).
pkg load symbolic
setenv PYTHON C:\ProgramData\Anaconda3\pythonw.exe
% Declare symbolic variable x
syms x;
disp('The function f(x):')
% Input the function f(x) here:
f = sin(x) + cos(x)+ x*sin(x)
disp('The derivetive fd(x) of the function f(x):')
% The derivative of the function f:
% fd(x) = f'(x)
fd = diff(f, x)
% Convert symbolic function fd(x) to numeric function dff(x):
dff = function_handle(fd);
x=-2*pi:0.1:2*pi;
y= dff(x);
plot(x,y)
xlabel('x')
ylabel('fd(x)')
% The script use the function_handle function to create numeric
% function ffd from dff(x).
pkg load symbolic
setenv PYTHON C:\ProgramData\Anaconda3\pythonw.exe
% Declare symbolic variable x
syms x;
disp('The function f(x):')
% Input the function f(x) here:
f = sin(x) + cos(x)+ x*sin(x)
disp('The derivetive fd(x) of the function f(x):')
% The derivative of the function f:
% fd(x) = f'(x)
fd = diff(f, x)
% Convert symbolic function fd(x) to numeric function dff(x):
dff = function_handle(fd);
x=-2*pi:0.1:2*pi;
y= dff(x);
plot(x,y)
xlabel('x')
ylabel('fd(x)')
Output
>> plot_derive_sym
The function f(x):
f = (sym) x*sin(x) + sin(x) + cos(x)
The derivetive fd(x) of the function f(x):
fd = (sym) x*cos(x) + cos(x)
>> plot_derive_sym
The function f(x):
f = (sym) x*sin(x) + sin(x) + cos(x)
The derivetive fd(x) of the function f(x):
fd = (sym) x*cos(x) + cos(x)
הוסף כיתוב |
No comments:
Post a Comment