# Need to re-write an expression to get rid of 0/0 problem

OK, this is really, really vague. Sorry. But this is for work and the boss man, justifiably or not, is really worried about intellectual property and ROI and blah blah blah. So I can't say much. But anyway: I have a mathematical expression that has a 0/0 problem. That is, at a set of discrete points, the straightforward evaluation of the expression collapses to 0/0. Now, limits can be taken to produce completely reasonable results at these points. But the catch is I have to program this, and 1) I don't want to put in an exception for these points and 2) even if the inputs don't land us exactly on these points, computational accuracy will suffer in their neighborhood.

So, are there any generic methods of wide applicablity for re-writing expressions to get rid of 0/0 problems? I know about l'Hopital's rule etc., but again, I want to be able to program this thing without putting in special exceptions. Sorry again to be so vague. Thanks for whatever you've got!

-
Is it one or two expressions hard coded in your program? Or do you need a general approach that needs to be implemented by a computer to remove those zeroes? – Ward Beullens Mar 14 '14 at 20:12
It's a very specific expression. Thanks. – bob.sacamento Mar 14 '14 at 20:40
I think it would be best if you posted the expression (It can't really hurt if we don't know it's purpose right?) So we could look for a trick. Or you could try my suggestion below – Ward Beullens Mar 14 '14 at 21:14

If the domain of your expression is bounded you could consider calculating an approximating polynomial. (For example use Wolfram Alpha to calculate a taylor series)

In some cases even if the domain is not bounded, you can make it so by some numerically stable manipulation. (like finding y' such that $y(x) = y'(a)$ with $a \in [0,1]$)

EDIT: You should first try to type your expression in Wolfram Alpha (https://www.wolframalpha.com/), if you are lucky, it will give you a alternate expression without the $(0/0)$

-
Was not aware of Wolfram alpha. It is a great tool. Unfortunately, all of its alternate expressions ahve the same problem. But I will definitely keep it in mind for the future. Thanks! – bob.sacamento Mar 16 '14 at 16:39

It depends on particular expression, but one approach would be to put small numbers in to replace zero or very small numbers in the calculation.

For example, it is not uncommon to use the square root of the smallest possible positive floating-point number allowed by your system as the smallest permitted input to your calculation. But is you are going to cube this in the denominator, then it will fail.

It may or may not make a substantial difference as to which small inputs you decide to use for your expression and you should test this. If it does, you cannot expect to get a reasonable result near to zero.

-