Question: If "error message" then ....

Hi!
I have the following code:

f:=proc(x)
   local u;
   Digits:=15;
   if x>10^9 
    then 
        u:=1/x; evalf(2/Pi*arccos((u*u-1)/(1+u*u)));
    else
        evalf(2/Pi*arccos((1-x*x)/(1+x*x)))
    end if
end proc;

 

The advantage is that f(+infinity) is defined in this case whereas evalf(2/Pi*arccos((1-x*x)/(1+x*x))) is not for x:=+infinity. But, I would like to extend this procedure in such a way that f(1/0) or f(something) where something is infinity or a division by zero is defined and gives the same result as f(+infinity).

I added before the preocedure f above the following code:
 

NumericEventHandler( division_by_zero = proc() +infinity; end proc ):

But, it defines a global environment. I would like a local modification of the environment only inside the procedure for f.

How to solve this issue?

Best regards,

 

Jaqr


 

Please Wait...