How to add integration constant

35 次查看(过去 30 天)
Emre Tunc
Emre Tunc 2016-9-25
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.

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 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by