简体   繁体   中英

How can I solve non linear equation in R and uniroot function

How can i find the value of x using R for the equation

a(x^b)+k*log(1+(x^c))+log(1-(u^(1/d)))=0 for the values

u=0.1,c=0.8,k=1.2,d=1.5,a=0.9,b=1 They got the ans as 0.0539. But i didn't get this ans.

Here is my code and my checks of the solution

f <- function(x, a, b, c, d, k, u) {
  a * (x^b) + k * log(1 + (x^c))+ log(1 - (u^(1/d)))
}

res <- uniroot(f, interval = c(0, 1), u=0.1,c=0.8,k=1.2,d=1.5,a=0.9,b=1)
res
#> $root
#> [1] 0.08930995
#> 
#> $f.root
#> [1] 1.234389e-06
#> 
#> $iter
#> [1] 5
#> 
#> $init.it
#> [1] NA
#> 
#> $estim.prec
#> [1] 6.103516e-05

# Check solution
f(res$root, u=0.1,c=0.8,k=1.2,d=1.5,a=0.9,b=1)
#> [1] 1.234389e-06

# Plot
x <- seq(0, .1, length.out = 100)
plot(x, f(x, u=0.1,c=0.8,k=1.2,d=1.5,a=0.9,b=1))

Created on 2020-04-09 by the reprex package (v0.3.0)

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