what is the wrong in this code

qustion 1
Recall the Product Rule for differentiating functions of the form f(x)*g(x):
(f*g) ' = f * g ' + f ' * g
For these problems, define x as a symbolic variable, then define appropriate expressions for f and g to find the derivative two ways:
  1. Using the rule above
  2. Using the diff command directly on f*g
(a) Find the derivative of (4 * x^4 - 2 * x^(-7/4) - x^(-2)) * (-3 * x^2 - 2 * x^(-3))
(b) Find the derivative of ( x^(-3)) * (-4 * x^5 + 7 * x^3 - 4 * x^2)
syms x; % DO NOT CHANGE CODE ON THIS LINE
% Part a
fa=(4.*x^4-2.*x^(-7/4)-x^(-2));
ga=(-3.*x^2-2.*x^(-3));
Prulea= (4.*x^4-2.*x^(-7/4)-x^(-2)).*(-3.*x^2-2.*x^(-3)) % Use the formula above here (no semicolons so you can compare answers)
Directa= (4.*x^4-2.*x^(-7/4)-x^(-2)).*(-3.*x^2-2.*x^(-3)); % Just use the diff command here
% Part b
fb= (x.^(-3));
gb= (-4.*x^5+7.*x^3-4.*x^2);
Pruleb= (x.^(-3)).*(-4.*x^5+7.*x^3-4.*x^2)
Directb= (x.^(-3)).*(-4.*x^5+7.*x^3-4.* x^2);
qustion 2
Given a function f, we can now create a new function f ' called the derivative function (or simply the derivative), which represents the slope of the tangent line to f at any given value of x. The formal definition of this function is found by simply replacing the specific value a with the symbolic variable x in the tangent line slope definition:
f'(x)=lim h-->0 (f(x+h)-f(x)/h)
Use this definition to symbolically calculate the derivatives of the following functions. Remember to define x and h as symbolic variables, then simplify the difference quotient in the formula above, then calculate the limit. As always, if you need to reference MATLAB's help feature on these or any function, you may do so here: https://www.mathworks.com/help/matlab/ by entering the command in the search box.
(a) f(x) = 8* x - 3* x^2
(b) g(x) = 4 / (2* x - 1)
syms x h; % DO NOT CHANGE CODE ON THIS LINE
% Part (a)
f=@(x)(8.*x-3.*x.^2) ; % Define the function
DQf=simplify(8-6.*x) %simplify the difference quotient (no semicolon so you can see the output)
df=limit(DQf,h,0) % calculate the limit (again no semicolon to see output)
% Part (b)
g=@(x)(4)./(2.*x-1); % Define the function
DQg=simplify(-8/(2*x - 1).^2) %simplify the difference quotient (no semicolon so you can see the output)
dg=limit(DQg,h,0) % calculate the limit (again no semicolon to see output)

2 comentarios

Torsten
Torsten el 7 de Dic. de 2018
Your "solutions" have no relation to the questions asked in the exercises.
Rik
Rik el 7 de Dic. de 2018
You can find guidelines for posting homework on this forum here.

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 7 de Dic. de 2018

Comentada:

Rik
el 7 de Dic. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by