R Markdown

Kw =10^(-14)
kb = 5.6 * 10^-4
Atot = 0.01


AFunction <- function(x){
 (kb*(x + 0.01 - (Kw/x)))-((Atot-x-0.01+ (Kw/x))*(Kw/x))
}

Hroot <- uniroot(AFunction, c(10^-6, 10^-12), tol = 10^-20)
Hroot
## $root
## [1] 4.755249e-12
## 
## $f.root
## [1] 5.624299e-18
## 
## $iter
## [1] 25
## 
## $init.it
## [1] NA
## 
## $estim.prec
## [1] 5.000002e-21
pH <- seq(12,13,0.1)
h <- 10^(-pH)

val <- AFunction(h)

plot(pH, val)