Potential for lambert_w0_exp

WolframAlpha tells us that the solution of the Michaelis-Menten ODE given by
can be expressed using the Lambert W function for which we have implemented the principal branch
x(t)=KW(\exp(tV+x(0)/K+\log(x(0)/K)) .

However if the argument of the exponential function is large enough we can not evaluate the solution, with large enough meaning roughly larger than 700.

However W(\exp(x)) is essentially linear for “large” x as WolframAlpha tells us again.

Can we get a function that can evaluate W(\exp(x)) for large x? Implementation should be straightforward ™, i.e. just casting x to a higher precision type before passing it to boosts W and exp.

Might be of interest to PK models, hence the tag.


Oh! That really shoots off into the stratosphere. Yeah this would be nice to have, would be good to file a math issue. If you want to have a crack at adding it then checkout out the stan math getting started guide and feel free to ask any Qs. Otherwise I’ll add this to my to-do list


Oh, I forgot to answer. I’d be glad to contribute, not sure when I’ll find the time but the issue is not too pressing.

In the meantime, I’m using as a workaround a C1 continuation after the problematic small and large values. I can share the code here in a bit.

1 Like