Average Error: 26.8 → 26.8
Time: 1.6s
Precision: binary64
\[\frac{2}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]
\[\frac{2}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]
\frac{2}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}
\frac{2}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}
double code(double NdotD, double XdotD, double alpha_x, double YdotD, double alpha_y) {
	return ((double) (2.0 / ((double) (NdotD + ((double) sqrt(((double) (((double) (((double) (NdotD * NdotD)) + ((double) (((double) (XdotD * alpha_x)) * ((double) (XdotD * alpha_x)))))) + ((double) (((double) (YdotD * alpha_y)) * ((double) (YdotD * alpha_y))))))))))));
}
double code(double NdotD, double XdotD, double alpha_x, double YdotD, double alpha_y) {
	return ((double) (2.0 / ((double) (NdotD + ((double) sqrt(((double) (((double) (((double) (NdotD * NdotD)) + ((double) (((double) (XdotD * alpha_x)) * ((double) (XdotD * alpha_x)))))) + ((double) (((double) (YdotD * alpha_y)) * ((double) (YdotD * alpha_y))))))))))));
}

Error

Bits error versus NdotD

Bits error versus XdotD

Bits error versus alpha_x

Bits error versus YdotD

Bits error versus alpha_y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 26.8

    \[\frac{2}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]
  2. Final simplification26.8

    \[\leadsto \frac{2}{NdotD + \sqrt{\left(NdotD \cdot NdotD + \left(XdotD \cdot alpha_x\right) \cdot \left(XdotD \cdot alpha_x\right)\right) + \left(YdotD \cdot alpha_y\right) \cdot \left(YdotD \cdot alpha_y\right)}}\]

Reproduce

herbie shell --seed 2020153 
(FPCore (NdotD XdotD alpha_x YdotD alpha_y)
  :name "(/ 2.0 (+ NdotD (sqrt (+ (+ (* NdotD NdotD) (* (* XdotD alpha_x) (* XdotD alpha_x))) (* (* YdotD alpha_y) (* YdotD alpha_y))))))"
  :precision binary64
  (/ 2.0 (+ NdotD (sqrt (+ (+ (* NdotD NdotD) (* (* XdotD alpha_x) (* XdotD alpha_x))) (* (* YdotD alpha_y) (* YdotD alpha_y)))))))