Format coefficients of the derivative of a function
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aleem Andrew
am 3 Okt. 2020
Kommentiert: Aleem Andrew
am 3 Okt. 2020
The following code is meant to output the derivative of a function but the coefficients are displayed as fractions even when I try to change the format to short or long.
syms x
e = 2.718282;
f = x * e^x^2;
format short
diff(f)
The output is a function whose coefficients are the ratios of large integers. How can their format be changed?
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 3 Okt. 2020
Bearbeitet: Ameer Hamza
am 3 Okt. 2020
Convert everthing to symbolic to prevent the loss of precision
syms x
e = exp(sym(1));
f = x * e^x^2;
format short
df = diff(f)
Result
>> df
df =
exp(2*x) + 2*x*exp(2*x)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!