필터 지우기
필터 지우기

want to differentiate 1+c*exp(t)/1-exp(t) which is 2*c*exp(t)/(1-exp(t))^2 and then return it to it's original form by integration using int(), understand rewrite(tanh,"exp")

조회 수: 1 (최근 30일)
% from Stewart's Calc 6 ed p. 599 just examples 1 and 2
%INPUT
syms f c t y(t) y yprime yIntegral;
y=(1+c*exp(t))/(1-c*exp(t))
y = 
simplify(y)
ans = 
yprime=diff(y)
yprime = 
%f=int(f);
yprime=simplify(yprime)
yprime = 
%disp(f);
yIntegral=int(yprime);
simplify(yIntegral);
disp(yIntegral);
OUTPUT
-(c*exp(t) + 1)/(c*exp(t) - 1)
-(c*exp(t) + 1)/(c*exp(t) - 1)
(c*exp(t)*(c*exp(t) + 1))/(c*exp(t) - 1)^2 - (c*exp(t))/(c*exp(t) - 1)
(2*c*exp(t))/(c*exp(t) - 1)^2
-2/(c*exp(t) - 1)
  댓글 수: 2
Walter Roberson
Walter Roberson 2024년 2월 23일
You are not specifying the variable of differentiation, and you are not specifying the variable of integration.
John D'Errico
John D'Errico 2024년 2월 26일
편집: John D'Errico 2024년 2월 26일
@Joseph Palumbo - I moved your comment that you posted as the accepted answer. Since you accepted the answer, I could not even move it directly. Please learn to use comments.
"Please forgive me everyone, this is my favorite calculus text I studied in college however, it appears I misunderstood something, this part begins with y=(1+c*exp(t))/(1-c*exp(t)) including the c's which are constants only to show you this is a family of functions, each different 'c' completing a separate function of which they are all of the same family. These c's should be replaced by their respective constant before differentiating or integrating, what fooled me however is that MatLab did differentiate it properly even with the c's included: 2ce^t/(ce^t-1)^2, being the correct answer (matches the book) but when it comes to integrating it, c's definitely cannot be included they are only added in for the integration, itself to symbolize constants. I MUST REVALUATE MY QUESTION AND GET BACK!------Joseph Palumbo"

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

채택된 답변

Paul
Paul 2024년 2월 26일
편집: Paul 2024년 2월 26일
Hi Joseph,
I think you got the correct result, though not using what might be considered best practices
syms f c t y(t) y yprime yIntegral
y = (1+c*exp(t))/(1-c*exp(t))
y = 
yprime = simplify(diff(y))
yprime = 
When calling diff without a second argument, the differentiation is taken wrt
symvar(y,1)
ans = 
t
which in this case does happen to be the variable you want. To be safe, and for clarity, its probably better to always specify the variable of differentation, especially in an expression with more than one variable
yprime = simplify(diff(y,t))
yprime = 
Similarly, int w/o the second argument will integrate wrt to
symvar(yprime,1)
ans = 
t
Again, it's the variable we want, but better to just be explicit
yr = int(yprime,t)
yr = 
which is the result you obtained.
However, int only returns an anti-derivative with a "constant of integration" being zero. So let's add a constant
syms K
yr = yr + K
yr = 
Now, we can solve for the value of K such that yr matches y
K = solve(yr == y,K)
K = 
Sub in that value of K to yr
yr = subs(yr)
yr = 
And simplify to the expected fraction
[num,den] = numden(subs(yr));
yr = num/den
yr = 
  댓글 수: 1
Joseph Palumbo
Joseph Palumbo 2024년 2월 27일
이동: Paul 2024년 2월 27일
Thanks alot Paul you explained alot of things that I am trying to do, which in the long run, is just to become familiar wth symbolic toolbox!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by