필터 지우기
필터 지우기

How to add integration constant

조회 수: 14 (최근 30일)
Emre Tunc
Emre Tunc 2016년 9월 25일
답변: Nathan Hall 2021년 4월 5일
I couldn't lose this function
syms a t
f(t)=-a
F(t)=int(a) (When I integrated)
=-at
but I want to add a constant with a letter which has to have:
F(t)=-at+C
How can I add a constant for indefinite integrals?

답변 (2개)

Philip M
Philip M 2020년 1월 24일
Bit of a late response, but this post is still getting 50 views per month and there doesn't seem to be an answer to this question out there anywhere, so here you go.
Think about it like this:
Putting that into MATLAB format and solving using the differential equations solution function, dsolve:
syms t a F(t)
f(t) = -a;
eqn = diff(F(t))==f(t);
sol=dsolve(eqn)
sol =
C1 - a*t
Voilà! It also works for more complex equations:
syms t a F(t)
f(t)=(t^4-1/t)/sqrt(2*a*t)-(a*t)^5;
eqn=diff(F(t))==f(t);
sol=dsolve(eqn)
sol =
C1 - (a^5*t^6)/6 + 2^(1/2)/(a^(1/2)*t^(1/2)) + (2^(1/2)*t^(9/2))/(9*a^(1/2))
as well as for higher order integrals:
syms t a F(t)
f(t)=(t^4-1/t)/sqrt(2*a*t)-(a*t)^5;
eqn=diff(F(t),t,t,t)==f(t);
sol=dsolve(eqn)
sol =
C3 + C2*t + (C1*t^2)/2 + (1716*2^(1/2)*t^(3/2) + 4*2^(1/2)*t^(13/2))/(1287*a^(1/2)) - (a^5*t^8)/336
I'm perplexed as to why this workaround is even necessary and why this isn't just an option of the int feature, and why nobody has posted this solution yet. In fact, I trekked through three whole pages of Google results and this is the only instance I could find of someone even asking about it.
But oh well, there's an answer out there for it now.
  댓글 수: 1
Joel Silva
Joel Silva 2021년 2월 18일
Thank you very much. This is exactly what I was looking for.

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


Nathan Hall
Nathan Hall 2021년 4월 5일
syms t C0 C1 C2;
a(t) = C0
v(t) = int(a(t),t) + C1
d(t) = int(v(t),t) + C2

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by