Monday, July 6, 2020

Symbolic derive of function and plot it

% 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)')

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)

Graph of fd(x) = f'(x)
הוסף כיתוב




No comments:

Post a Comment

Featured Post

Solve simple Absolute Value Inequality

  Exam - BARTON COLLEGE PRACTICE PLACEMENT TEST Ex. 39 Exercise: The inequality |8 - x| < 8   is equivalent to:   a) x < 0 b) x &g...