Is there a name for the mathematical function f(x) = 0 when x=0 and 1/x otherwise?

106 Views Asked by At

I'm using Octave, a programming language similar to MATLAB, and I would like to invert every value in a particular matrix.

But if I tell it to use the function f(x) = 1/x, it will display an error when x=0.

Is there a well-known mathematical function (preferably that Octave has code for) that is equivalent to f(x) = 0 for x=0 and 1/x otherwise?

I'm relatively new to stack exchange, so please let me know how to improve my answer (or improve it by editing it, especially through adding LATEX).

1

There are 1 best solutions below

0
On BEST ANSWER

Some computer languages have a zidz(a, b) (=zero if divide by zero) function that returns $0$ if b = 0 and a/b otherwise. The function you want would be a special case, zidz(1, x). Octave doesn't have this as a built-in function, but you can write one simply enough.