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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -