I tried to take the derivative the function, but I can't find my mistake:
syms x
A = -1.6*x^2+18.7*x+3.4
This returns (187*x)/10 - (8*x^2)/5 + 17/5
.
Then, diff(A)
yields 187/10 - (16*x)/5
.
I tried to take the derivative the function, but I can't find my mistake:
syms x
A = -1.6*x^2+18.7*x+3.4
This returns (187*x)/10 - (8*x^2)/5 + 17/5
.
Then, diff(A)
yields 187/10 - (16*x)/5
.
There is no mistake here. The derivative of a second degree polynomial is a first degree polynomial... hence the variable x
is still present in the result and you cannot evaluate it numerically unless you give a value to x
:
vpa(subs(diff(A),x,4)) % evaluates the derivative for X=4, yields 5.9
If you want to reduce your function to a scalar value, a second order derivative must be taken:
vpa(diff(A,2)) % this returns: -3.2
Finally, if you just feel that the numerical parts of the result are "messy" and should be evaluated, you can call the vpa function on the derivative:
vpa(diff(A)) % this returns: 18.7 - 3.2*x