简体   繁体   中英

Using R to solve equations

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM