Derivative of a function with constants

Hello,
how can i calculate the derivative of a function like x*e^x(a*x^2+b*x+c), where a,b,c are constants(for example integers).
I tried syms x a b c and then
f=inline('ax^2+bx+c','x')
diff(f(x),x)
but then i get an error.
A function like that is easy enough without Matlab but i want the sum of y'''+y''-y'+y which needs a lot of calculation.
Thanks in advance.

1 Comment

jessupj
jessupj on 13 Jan 2022
Edited: jessupj on 13 Jan 2022
maybe
a*x^2 + b*x +c
with multiplication operations? (always report details of the error... its easier to tell what the problem is that way)

Sign in to comment.

Answers (1)

syms x a b c
f = x*e^x*(a*x^2+b*x+c);
df = diff(f,x)

4 Comments

It gives me an error :Undefined function or variable 'e'.
Then use exp(x) instead of e^x.
Thank you so much, do you know how to calculate also y'' and y'''
d2f = diff(f,x,2)
d3f = diff(f,x,3)
...
dnf = diff(f,x,n) % n-th derivative, n has to be set to a value before

Sign in to comment.

Products

Release

R2019a

Asked:

on 13 Jan 2022

Edited:

on 14 Jan 2022

Community Treasure Hunt

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

Start Hunting!