필터 지우기
필터 지우기

Format coefficients of the derivative of a function

조회 수: 2 (최근 30일)
Aleem Andrew
Aleem Andrew 2020년 10월 3일
댓글: Aleem Andrew 2020년 10월 3일
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?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 3일
편집: Ameer Hamza 2020년 10월 3일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by