How to substitute x by an integer in a derivative function

조회 수: 7 (최근 30일)
Rodrigo Toledo
Rodrigo Toledo 2021년 3월 29일
댓글: Paul 2021년 3월 30일
I have a function:
syms x
f(x) = (tan(x^2 + 3*x))^2
a = diff(f(x))
Now i want to calculate the a when x=1. How can i do it?
i tried a(2) but didnt work.
Thanks

채택된 답변

Andreas Apostolatos
Andreas Apostolatos 2021년 3월 29일
Hello,
To evaluate symbolic expression 'a' at 'x = 1' you can use function 'subs', namely,
a_at_1 = subs(a, 1);
I am not sure why you tried typing 'a(2)' since you are trying to evaluate 'a' at 1.
More information about function 'subs' you can find in the following documentation page,
I hope that this helps.
Kind Regards,
Andreas
  댓글 수: 2
Rodrigo Toledo
Rodrigo Toledo 2021년 3월 30일
thanks mate. a(2) is a typo. i meant a(1), sorry.
Paul
Paul 2021년 3월 30일
You can also define a to be a function of x and then evaluate it at the value of interest
>> syms x
f(x) = (tan(x^2 + 3*x))^2
a(x) = diff(f(x))
f(x) =
tan(x^2 + 3*x)^2
a(x) =
2*tan(x^2 + 3*x)*(2*x + 3)*(tan(x^2 + 3*x)^2 + 1)
>> a(1)
ans =
10*tan(4)*(tan(4)^2 + 1)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by