0 like 0 dislike
0 like 0 dislike
help to change an equation to remove an undefined error

3 Answers

0 like 0 dislike
0 like 0 dislike
the first thing that comes to mind is adding a very small number to the denominator to prevent it from becoming 0


let x=a-b

 x / ( |x| + 0.0001 )

 then when doing calculations you can basically ignore that small number



Or you can use a simple piecewise function to take care of the extreme case
0 like 0 dislike
0 like 0 dislike
The function you want, also know as sign(a-b), is discontinuous at x=0.

Addition, subtraction, multiplication, division (except by 0), and the absolute value function are all continuous  (as are many other standard functions).   And the composition of continuous functions is continuous.

So you'll never be able to produce the expression sin(a-b) using a combination of any of those operations and functions which is defined everywhere.   As you noticed, if you allow division by expressions which might equal zero then you can come close but your expression will be undefined at those points where you allowed division by zero.

**Edit:** If you allow the floor() function which is already discontinuous, then you can do something like sign(x) = floor((2+|2+x|-|x|)/4) - floor((2+|2-x|-|x|)/4).    Just replace x with (a-b) for your specific case.
0 like 0 dislike
0 like 0 dislike
Why do you want to remove the undefined error? It's perfectly sensible to keep it.

The function you deceived (technically called the "sign" function, but not to be confused with the "sine" function) makes perfect sense with the error. Think about it like this:

You want the function to return a "sign" indicating which number is larger than the other, if they are equal then this question makes no sense and an error is rightly returned.

If you need a function that say, returns 0 when they are equal, just use a piecewise:

signoreqaual(a, b) = (a-b)/|a-b| if a ≠ b, or 0 if a=b

Likewise, if you want a function that returns +1 if one is greater than the other, or 0 otherwise:

greaterthan(a, b) = 0.5 + ((a-b)/|a-b| if a ≠ b, or -1 if a=b)/2

Or simply:

greaterthan(a, b) = 1 if a>b, otherwise 0

Related questions

0 like 0 dislike
0 like 0 dislike
1 answer
MSR_Tlse asked Jun 21
Are the S3/S4 Edexcel Further Maths units useful to become an actuary? Topics include sampling, unbiased and biased estimators, confidence intervals and significance test...
MSR_Tlse asked Jun 21
0 like 0 dislike
0 like 0 dislike
26 answers
ShanePaulNeil asked Jun 21
Why is it boring to be an actuary?
ShanePaulNeil asked Jun 21
0 like 0 dislike
0 like 0 dislike
7 answers
alfonsoesparzao asked Jun 21
Using SOA suggested text books to study for an exam
alfonsoesparzao asked Jun 21
0 like 0 dislike
0 like 0 dislike
3 answers
Pinterest_ITA asked Jun 21
Relative to LTAM, what would you guess is an appropriate difficulty multiplier for FAM-L ?
Pinterest_ITA asked Jun 21
0 like 0 dislike
0 like 0 dislike
2 answers
ANCJHB asked Jun 21
When to start exams/modules as an EL
ANCJHB asked Jun 21
by ANCJHB

24.8k questions

103k answers

0 comments

33.7k users

OhhAskMe is a math solving hub where high school and university students ask and answer loads of math questions, discuss the latest in math, and share their knowledge. It’s 100% free!