Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 217
2han12 Avatar asked Oct 06 '22 04:10

2han12


1 Answers

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

like image 124
Andrew Stern Avatar answered Oct 16 '22 10:10

Andrew Stern