Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there any way to ensure simplified expressions are only defined over the same range as the original expression?

My guess is no, but it is often important to understand that, for example, a polynomial fraction is not defined when the denominator is 0.

To use an example from the page,

    simplify((x**3 + x**2 - x - 1)/(x**2 + 2*x + 1))
gives

    x - 1
but should give

    x - 1; x != 1 + sqrt(2), x != 1 - sqrt(2)
This is not always what you want to see, but it would be cool if you could turn it on :)


This is because of a rigorously defined procedure called "extending by continuity". The function is continuous, your issue is just an artifact of notation.


Can you explain this more? From what I understand the original function has division by '0' at those specific values of 'x'. So the final reduced form has a different domain where it is valid.


I will give an example, not the general definition.

Consider the function f: x -> sin(x)/x. At x=0 you indeed have a division by 0, and if you stick to blindly using your notation it does not work. The function is not defined at x=0. However you usually (not always) are interested in the function as a whole. Look at the limit from the left, look at the limit from the right. They have the same values, it makes sense just to use this limiting value for the value at x=0.

See https://en.wikipedia.org/wiki/Removable_singularity




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: