How to add integration constant

31 ビュー (過去 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 Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by