SQLite Forum

Math functions for arguments outside the domain should raise exception according to SQL Standard
Login
The SQL standard is technically incorrect (or is geared for someone with a primary school education only).

There is an answer to the functions SQRT(-1) and LN(-1).  Those answers are not, however, real numbers -- they are what are called "imaginary numbers".  

Imaginary numbers cannot be represented as "real numbers" and SQLite3 does not do arithmetic using complex numbers (well, actually it does, the complex part is just always 0j).

Since the answer to SQRT(-1) and LN(-1) have a non-zero imaginary part and the real part is zero (SQRT(-1) -> 1j; LN(-1) -> 3.141592653589793j (which you will note is PI)) these results cannot be represented as real numbers even though the answer does, in fact, exist.

The mathematically correct answer when that answer must be expressed in the real number domain is a NaN (not a number in the real domain).  That result is represented by SQLite3 as a NULL (which happens to have the same propagation qualities as a NaN).

So in short, SQLite3 is correct and the SQL standard (and those things which follow that standard) are incorrect.