-2

enter image description hereI have an question concerning the possibility to solve functions in R, but to know the answer would really help to understand the R better.

0.10 = (1/(1+(((1.04e+19*((T/300)^(3/2)))/(4e+16))exp((-(0.045)/(0.0259(T/300)))))))

How can I solve this expression in R and find the value of T?

1 Answers1

1

Your equation does not have solutions. To see this define the function, defined over the positive reals,

f <- function(T) (1/(1+(((1.04e+19*((T/300)^(3/2)))/(4e+16))*exp((-(-0.045)/(0.0259*(T/300)))))))

and define a function f(x) - a, in order to solve the equation f(x) - a = 0.

g <- function(x, a) f(x) - a

Now plot this second function.

curve(g(x, 0.10), 0, 1e3)

enter image description here

As the graph shows, all values of g(x, 0.10) = f(x) - 0.10 are positive, f(x) != 0.10 for all x.
Analytically, if the functions never changes sign it does not have roots. Since the function is continuous, all we need to do is to check its value near 0 and the maximum.

g(.Machine$double.eps, 0.10)
#[1] -0.1

The maximum is determined with optimise.

optimise(g, c(0, 1e3), a = 0.10, maximum = TRUE)
#$maximum
#[1] 347.4904
#
#$objective
#[1] -0.09931205

Both values are negative, which confirms what the graph had shown.


Edit

Everything that was said above is right but apparently the function's expression was wrong. With the correct expression the root can be found with uniroot. Note that the solution given in the question's image was found by trial and error, the solution below was found by a numeric method but they are the same solution.

f <- function(T) {
  numer <- 1.04e19*(T/300)^(3/2) / 4e16
  numer <- numer * exp(-0.045/(0.0259*T/300))
  numer <- 1 + numer
  1/numer
}
g <- function(x, a) f(x) - a

xzero <- uniroot(g, a = 0.10, interval = c(0, 1e3))
xzero
#$root
#[1] 192.9487
#
#$f.root
#[1] -1.149569e-10
#
#$iter
#[1] 13
#
#$init.it
#[1] NA
#
#$estim.prec
#[1] 6.103516e-05

curve(g(x, 0.10), 0, 1e3)
abline(h = 0)
points(xzero$root, 0, col = "blue", pch = 16)

enter image description here

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66