Using R to solve equations

限于喜欢 提交于 2019-12-10 14:56:19

问题


How might I solve for the roots of an equation of the following form numerically in R:

f(r)=r*c+1-B*c-exp(-M(B-r))

Where M, B and c are known constants.

Thanks in advance.


回答1:


Since R can not do this functionality you might want to use a superset package like Sage. Sage includes R and many other packages and can do what you want using a webbrowser interface. The site is http://www.sagemath.org/

Examples are located at: http://www.sagemath.org/doc/reference/sage/symbolic/relation.html

You can try stuff like the following at: http://www.sagenb.org/

var('r', 'c', 'B', 'M')
f = r*c+1-B*c-exp(-M(B-r))
print solve(f, r)

The results of this is:

r == (B*c + e^(-B + r) - 1)/c



来源:https://stackoverflow.com/questions/14646542/using-r-to-solve-equations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!