Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试实现一种算法,R其中涉及求解积分的边界限制。例如,我想找到a以下积分:
R
a
integral_0^a exp(x) = 1/2
我有一个粗略的想法如何做到这一点matlab。但是如何解决这个问题R呢?
matlab
感谢您的建议。
您可以使用integrate计算积分(数值)和uniroot求解方程(数值)。
integrate
uniroot
f <- function(a) integrate( exp, 0, a )$value - 1/2 uniroot( f, c(-1, 1) ) # Look for a solution in [-1,1] log(3/2) # Compare with the exact solution