Skip to content
Prev 393693 / 398503 Next

R emulation of FindRoot in Mathematica

Dear Leonard - thanks a lot for the solution! Yes, you are right: pH is 
presumed known, so the effort is repeated at a series of chosen pH 
values.? It appears that no matter x0 the estimate for atp is always 
-6.239560e-01 which even accounting for offset of 0.008 is negative 
which is not possible and the estimate of the other species also appear 
to be constant no matter x0? The algorithm needs only 2 or 3 iterations 
and doesn't complain. I have been through the equations and they appear 
correct. Wonder what I did wrong?

Below some output

Best wishes
Troels

x0 = c(
 ? atp = 0.008,
 ? adp = 0.00001,
 ? pi = 0.003,
 ? pcr = 0.042,
 ? cr = 0.004,
 ? lactate = 0.005
) / 3;
# tricky to get a positive value !!!
 ?x0[1] = 0.001; # still NOT positive;

x = multiroot(solve.AcidSpecies, x0, H = 4E-8)
x
# $root
# atp?????????? adp??????????? pi?????????? pcr cr?????? lactate
# -6.239560e-01? 3.254998e-06? 5.581774e-08? 4.142785e-09 5.011807e-10? 
4.973691e-03

x0 <- 1000*x0
x = multiroot(solve.AcidSpecies, x0, H = 4E-8)
x
# $root
# atp?????????? adp??????????? pi?????????? pcr cr?????? lactate
# -6.239560e-01? 3.254998e-06? 5.581774e-08? 4.142785e-09 5.011807e-10? 
4.973691e-03

x0 <- x0*1e-6
x = multiroot(solve.AcidSpecies, x0, H = 4E-8)
x
# $root
# atp?????????? adp??????????? pi?????????? pcr cr?????? lactate
# -6.239560e-01? 3.254998e-06? 5.581774e-08? 4.142785e-09 5.011807e-10? 
4.973691e-03


Den 23-01-2023 kl. 01:24 skrev Leonard Mada: