Average Error: 13.3 → 13.3
Time: 8.9s
Precision: binary64
Cost: 33856
\[10^{-150} < \left|x\right| \land \left|x\right| < 10^{+150}\]
Math TeX FPCore C \[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
↓
\[\sqrt{0.5 \cdot \left(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)} ↓
\sqrt{0.5 \cdot \left(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)} (FPCore (p x)
:precision binary64
(sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x)))))))) ↓
(FPCore (p x)
:precision binary64
(sqrt
(*
0.5
(*
(sqrt (+ 1.0 (/ x (sqrt (+ (* p (* p 4.0)) (* x x))))))
(sqrt (+ 1.0 (/ x (sqrt (+ (* p (* p 4.0)) (* x x)))))))))) double code(double p, double x) {
return sqrt(0.5 * (1.0 + (x / sqrt(((4.0 * p) * p) + (x * x)))));
}
↓
double code(double p, double x) {
return sqrt(0.5 * (sqrt(1.0 + (x / sqrt((p * (p * 4.0)) + (x * x)))) * sqrt(1.0 + (x / sqrt((p * (p * 4.0)) + (x * x))))));
}
Try it out Enter valid numbers for all inputs
Target Original 13.3 Target 13.3 Herbie 13.3
\[\sqrt{0.5 + \frac{\mathsf{copysign}\left(0.5, x\right)}{\mathsf{hypot}\left(1, \frac{2 \cdot p}{x}\right)}}\]
Alternatives Alternative 1 Error 15.0 Cost 53056
\[\sqrt{0.5 \cdot \left(1 + \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\left|\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}\right|} \cdot \frac{\sqrt[3]{x}}{\sqrt{\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 2 Error 14.9 Cost 53056
\[\sqrt{0.5 \cdot \left(1 + \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \frac{\sqrt[3]{x}}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 3 Error 15.1 Cost 47168
\[\sqrt{0.5 \cdot \left(1 + \frac{1}{\sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}} \cdot \sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \frac{x}{\sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 4 Error 15.1 Cost 47040
\[\sqrt{0.5 \cdot \left(1 + \frac{\frac{x}{\sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}} \cdot \sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}}{\sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 5 Error 15.2 Cost 47040
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}} \cdot \left(\sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}} \cdot \sqrt[3]{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\right)}\]
Alternative 6 Error 50.4 Cost 46784
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\frac{\sqrt{{p}^{6} \cdot 64 + {x}^{6}}}{\sqrt{{p}^{4} \cdot 16 + \left({x}^{4} - \left(p \cdot \left(p \cdot 4\right)\right) \cdot \left(x \cdot x\right)\right)}}}\right)}\]
Alternative 7 Error 50.4 Cost 34752
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{{p}^{6} \cdot 64 + {x}^{6}}} \cdot \sqrt{\left(p \cdot \left(p \cdot 4\right)\right) \cdot \left(p \cdot \left(p \cdot 4\right)\right) + \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) - \left(p \cdot \left(p \cdot 4\right)\right) \cdot \left(x \cdot x\right)\right)}\right)}\]
Alternative 8 Error 14.6 Cost 33728
\[\sqrt{0.5 \cdot \left(1 + \frac{1}{\left|\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}\right|} \cdot \frac{x}{\sqrt{\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 9 Error 14.3 Cost 33728
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \frac{1}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 10 Error 56.7 Cost 33728
\[\sqrt{0.5 \cdot \left(20 \cdot \frac{{p}^{6}}{{x}^{6}} + \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}} - 6 \cdot \frac{{p}^{4}}{{x}^{4}}\right)\right)}\]
Alternative 11 Error 14.7 Cost 33600
\[\sqrt{0.5 \cdot \left(1 + \frac{\frac{x}{\left|\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}\right|}}{\sqrt{\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 12 Error 14.4 Cost 33600
\[\sqrt{0.5 \cdot \left(1 + \frac{\frac{x}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 13 Error 14.7 Cost 33600
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\left|\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}\right| \cdot \sqrt{\sqrt[3]{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 14 Error 14.3 Cost 33600
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}} \cdot \sqrt{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 15 Error 15.1 Cost 33216
\[\sqrt{0.5 \cdot \left(1 + \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\frac{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}{\sqrt[3]{x}}}\right)}\]
Alternative 16 Error 15.1 Cost 33216
\[\sqrt{0.5 \cdot \left(1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \frac{\sqrt[3]{x}}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\]
Alternative 17 Error 13.3 Cost 28416
\[\sqrt{0.5 \cdot \frac{1 + {\left(\frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}^{3}}{1 + \left(\frac{x \cdot x}{p \cdot \left(p \cdot 4\right) + x \cdot x} - \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}}\]
Alternative 18 Error 28.4 Cost 27584
\[\sqrt{0.5 \cdot \frac{1 - \frac{x \cdot x}{p \cdot \left(p \cdot 4\right) + x \cdot x}}{1 - \frac{x}{e^{\log \left(\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}\right)}}}}\]
Alternative 19 Error 56.7 Cost 27264
\[\sqrt{0.5 \cdot \left(20 \cdot \frac{{p}^{6}}{{x}^{6}} + \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}} - 6 \cdot {\left(\frac{p}{x}\right)}^{4}\right)\right)}\]
Alternative 20 Error 31.3 Cost 27072
\[\sqrt{0.5 \cdot \left(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \sqrt{1 + \frac{x}{p \cdot 2}}\right)}\]
Alternative 21 Error 19.4 Cost 26624
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt[3]{{\left(\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}\right)}^{3}}}\right)}\]
Alternative 22 Error 13.3 Cost 26560
\[\sqrt{0.5 \cdot e^{\log \left(1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}}\]
Alternative 23 Error 13.3 Cost 26560
\[\sqrt{0.5 \cdot \log \left(e^{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 24 Error 16.1 Cost 26560
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{e^{\log \left(\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}\right)}}\right)}\]
Alternative 25 Error 32.1 Cost 26560
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\log \left(e^{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\right)}\]
Alternative 26 Error 55.7 Cost 20416
\[\sqrt{0.5 \cdot \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}} - 6 \cdot \frac{{p}^{4}}{{x}^{4}}\right)}\]
Alternative 27 Error 28.8 Cost 14784
\[\sqrt{0.5 \cdot \frac{1 - \frac{x \cdot x}{p \cdot \left(p \cdot 4\right) + x \cdot x}}{1 - \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}}\]
Alternative 28 Error 53.0 Cost 13952
\[\sqrt{0.5 \cdot \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}} - 6 \cdot {\left(\frac{p}{x}\right)}^{4}\right)}\]
Alternative 29 Error 13.5 Cost 13888
\[\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\]
Alternative 30 Error 13.3 Cost 13760
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\]
Alternative 31 Error 28.2 Cost 7488
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{p \cdot 2 + \frac{x \cdot x}{p} \cdot 0.25}\right)}\]
Alternative 32 Error 15.9 Cost 7360
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{x + 2 \cdot \frac{p \cdot p}{x}}\right)}\]
Alternative 33 Error 52.0 Cost 7104
\[\sqrt{0.5 \cdot \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}}\right)}\]
Alternative 34 Error 31.4 Cost 6976
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{p \cdot 2}\right)}\]
Alternative 35 Error 60.0 Cost 6912
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{-x}\right)}\]
Alternative 36 Error 41.0 Cost 6848
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{x}\right)}\]
Alternative 37 Error 60.0 Cost 6464
\[\sqrt{0}\]
Alternative 38 Error 28.5 Cost 6464
\[\sqrt{0.5}\]
Alternative 39 Error 41.0 Cost 64
\[1\]
Alternative 40 Error 60.0 Cost 64
\[0\]
Alternative 41 Error 62.9 Cost 64
\[-1\]
Error Derivation Initial program 13.3
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
Using strategy rm Applied add-sqr-sqrt_binary64_3169 13.3
\[\leadsto \sqrt{0.5 \cdot \color{blue}{\left(\sqrt{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}} \cdot \sqrt{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}}\]
Simplified13.3
\[\leadsto \sqrt{0.5 \cdot \left(\color{blue}{\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}}}} \cdot \sqrt{1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}}\right)}\]
Simplified13.3
\[\leadsto \sqrt{0.5 \cdot \left(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}}} \cdot \color{blue}{\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(4 \cdot p\right) + x \cdot x}}}}\right)}\]
Simplified13.3
\[\leadsto \color{blue}{\sqrt{0.5 \cdot \left(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}}\]
Final simplification13.3
\[\leadsto \sqrt{0.5 \cdot \left(\sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}} \cdot \sqrt{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Reproduce herbie shell --seed 2021022
(FPCore (p x)
:name "Given's Rotation SVD example"
:precision binary64
:pre (< 1e-150 (fabs x) 1e+150)
:herbie-target
(sqrt (+ 0.5 (/ (copysign 0.5 x) (hypot 1.0 (/ (* 2.0 p) x)))))
(sqrt (* 0.5 (+ 1.0 (/ x (sqrt (+ (* (* 4.0 p) p) (* x x))))))))