How to add integration constant
조회 수: 35 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (2개)
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
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!