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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!