# [R] How to solve following equation?

RON70 ron_michael70 at yahoo.com
Wed Dec 3 18:32:28 CET 2008

```Thanks for this reply, However I am interested to know why I need to modify
my function to a=1?

Regards,

Gabor Grothendieck wrote:
>
> Assume a = 1.  If not set b = b/a, etc.
> Now use (1) uniroot
>
>> f <- function(x) b + c/(1+x) + d/(1+x)^2 - 1 - x
>> uniroot(f, 0:1)
> \$root
>  0.8392679
>
> \$f.root
>  3.049818e-05
>
> \$iter
>  3
>
> \$estim.prec
>  6.103516e-05
>
> or multiply through by 1+x
> and subtract 1 from both sides giving
> x = b + c/(1+x) + d/(1+x)^2 - 1
> and iterate that.
>
>> a <- b <- c <- d <- 1
>> x <- 0
>> for(i in 1:25) {
> + x <- b + c/(1+x) + d/(1+x)^2 - 1
> + print(x)
> + }
>  2
>  0.4444444
>  1.171598
>  0.6725419
>  0.9553676
>  0.7729558
>  0.8821595
>  0.8135892
>  0.8554268
>  0.829437
>  0.8454056
>  0.835527
>  0.8416126
>  0.837854
>  0.8401717
>  0.838741
>  0.8396236
>  0.839079
>  0.839415
>  0.8392076
>  0.8393356
>  0.8392566
>  0.8393053
>  0.8392753
>  0.8392938
>
> On Mon, Dec 1, 2008 at 9:47 PM, RON70 <ron_michael70 at yahoo.com> wrote:
>>
>> I need to solve a equation like this :
>>
>> a = b/(1+x) + c/(1+x)^2 + d/(1+x)^3
>>
>> where a,b,c,d are known constant. Is there any R-way to do that?
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-solve-following-equation--tp20785063p20785063.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help