Average Error: 13.3 → 13.3
Time: 8.9s
Precision: binary64
Cost: 33856
\[10^{-150} < \left|x\right| \land \left|x\right| < 10^{+150}\]
\[\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))))));
}

Error

Bits error versus p

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.3
Target13.3
Herbie13.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
Error15.0
Cost53056
\[\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
Error14.9
Cost53056
\[\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
Error15.1
Cost47168
\[\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
Error15.1
Cost47040
\[\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
Error15.2
Cost47040
\[\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
Error50.4
Cost46784
\[\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
Error50.4
Cost34752
\[\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
Error14.6
Cost33728
\[\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
Error14.3
Cost33728
\[\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
Error56.7
Cost33728
\[\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
Error14.7
Cost33600
\[\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
Error14.4
Cost33600
\[\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
Error14.7
Cost33600
\[\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
Error14.3
Cost33600
\[\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
Error15.1
Cost33216
\[\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
Error15.1
Cost33216
\[\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
Error13.3
Cost28416
\[\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
Error28.4
Cost27584
\[\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
Error56.7
Cost27264
\[\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
Error31.3
Cost27072
\[\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
Error19.4
Cost26624
\[\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
Error13.3
Cost26560
\[\sqrt{0.5 \cdot e^{\log \left(1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}}\]
Alternative 23
Error13.3
Cost26560
\[\sqrt{0.5 \cdot \log \left(e^{1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}}\right)}\]
Alternative 24
Error16.1
Cost26560
\[\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
Error32.1
Cost26560
\[\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
Error55.7
Cost20416
\[\sqrt{0.5 \cdot \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}} - 6 \cdot \frac{{p}^{4}}{{x}^{4}}\right)}\]
Alternative 27
Error28.8
Cost14784
\[\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
Error53.0
Cost13952
\[\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
Error13.5
Cost13888
\[\sqrt{0.5 \cdot \left(1 + x \cdot \frac{1}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\]
Alternative 30
Error13.3
Cost13760
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{p \cdot \left(p \cdot 4\right) + x \cdot x}}\right)}\]
Alternative 31
Error28.2
Cost7488
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{p \cdot 2 + \frac{x \cdot x}{p} \cdot 0.25}\right)}\]
Alternative 32
Error15.9
Cost7360
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{x + 2 \cdot \frac{p \cdot p}{x}}\right)}\]
Alternative 33
Error52.0
Cost7104
\[\sqrt{0.5 \cdot \left(2 \cdot \frac{p}{\frac{x \cdot x}{p}}\right)}\]
Alternative 34
Error31.4
Cost6976
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{p \cdot 2}\right)}\]
Alternative 35
Error60.0
Cost6912
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{-x}\right)}\]
Alternative 36
Error41.0
Cost6848
\[\sqrt{0.5 \cdot \left(1 + \frac{x}{x}\right)}\]
Alternative 37
Error60.0
Cost6464
\[\sqrt{0}\]
Alternative 38
Error28.5
Cost6464
\[\sqrt{0.5}\]
Alternative 39
Error41.0
Cost64
\[1\]
Alternative 40
Error60.0
Cost64
\[0\]
Alternative 41
Error62.9
Cost64
\[-1\]

Error

Derivation

  1. Initial program 13.3

    \[\sqrt{0.5 \cdot \left(1 + \frac{x}{\sqrt{\left(4 \cdot p\right) \cdot p + x \cdot x}}\right)}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt_binary64_316913.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)}}\]
  4. 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)}\]
  5. 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)}\]
  6. 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)}}\]
  7. 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))))))))