In <math.h> the constant M_2_SQRTPI is defined with the value 2/sqrt(pi).
I have never seen this expression used in a formula, so I searched for uses of M_2_SQRTPI but I could only found documentation about the constant and no actual uses of it.
Where is the constant used and what is the reason it is defined in <math.h> as a mathematical constant?
The constant is related to the error function.
I don't know why it's provided as a constant in the standard library POSIX, though. With GCC on a x86-64 system, and by extension on every system conforming to IEEE 754, computing 2.0 / sqrt(M_PI) yields exactly the same double-precision value as M_2_SQRTPI.
Try it online!
Even if there was a slight error, the very few people who need the constant could simply define it themselves.
It is used in different scientific computations (I've seen it in finance, for instance).
Why do you want it as a constant? Because sqrt(M_PI) will not have the same precision as a precomputed value (using more precision for PI to start with). And it makes quite a difference, I've seen the damages of not using it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With