r - Obtain inverse function analytically instead of numerically -
i implemented
> inverse = function (f, lower = -100, upper = 100) { function (y) uniroot((function (x) f(x) - y), lower = lower, upper = upper)[1] } > square_inverse = inverse(function (x) x^2, 0.1, 100) > square_inverse(4) [1] 1.999976
from solving inverse of function in r , happy worked :) despite visible in origin solution unfortunately not analytic one. there way exact solution or @ least improve approximation of above code?
Comments
Post a Comment