Solving an integral with variable as upper limit and plotting the solution
8 次查看(过去 30 天)
显示 更早的评论
How can I solve an integral when the upper limit is a variable, and then plot the solution? My integral is as follows: Integral of e^(-(y^2))dy and my upper limit is x, while the lower limit is negative infinity. X and y are variables. I have tried using the trapz function, but then you must have a constant as upper limit. I have also tried using the int-funtion, but that is only solving for an indefinite integral. Does anyone know what I should do?
0 个评论
采纳的回答
Torsten
2015-1-20
Your function is equal to
sqrt(pi)/2*(1+erf(x))
Best wishes
Torsten.
1 个评论
john zhang
2020-8-12
what if the function is very complex and has no general antiderivative? Thank you
更多回答(4 个)
David
2015-1-20
4 个评论
John D'Errico
2015-1-21
You could just use basic calculus.
erf gives you the integral from 0 to x. If you want the integral from -inf to x, then add 1. This is because the integral from -inf to 0 is 1.
erf(-inf)
ans =
-1
(Beware of the order of those limits, which gives me here -1.)
So the integral from -inf to x is
1 + erf(x)
Which is valid for any real x as your upper limit.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!