Average Error: 15.2 → 14.7
Time: 9.4s
Precision: binary64
Cost: 66048
\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
\[\begin{array}{l} t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\ \frac{\frac{\sqrt[3]{{\left(0.25 + \frac{-0.25}{\mathsf{fma}\left(x, x, 1\right)}\right)}^{2}} \cdot \sqrt[3]{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}}{{\left(\sqrt[3]{t_0}\right)}^{2}}}{1 + \sqrt{t_0}} \end{array} \]
(FPCore (x)
 :precision binary64
 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ 0.5 (/ 0.5 (hypot 1.0 x)))))
   (/
    (/
     (*
      (cbrt (pow (+ 0.25 (/ -0.25 (fma x x 1.0))) 2.0))
      (cbrt (+ 0.5 (/ -0.5 (hypot 1.0 x)))))
     (pow (cbrt t_0) 2.0))
    (+ 1.0 (sqrt t_0)))))
double code(double x) {
	return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
double code(double x) {
	double t_0 = 0.5 + (0.5 / hypot(1.0, x));
	return ((cbrt(pow((0.25 + (-0.25 / fma(x, x, 1.0))), 2.0)) * cbrt((0.5 + (-0.5 / hypot(1.0, x))))) / pow(cbrt(t_0), 2.0)) / (1.0 + sqrt(t_0));
}
function code(x)
	return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x))))))
end
function code(x)
	t_0 = Float64(0.5 + Float64(0.5 / hypot(1.0, x)))
	return Float64(Float64(Float64(cbrt((Float64(0.25 + Float64(-0.25 / fma(x, x, 1.0))) ^ 2.0)) * cbrt(Float64(0.5 + Float64(-0.5 / hypot(1.0, x))))) / (cbrt(t_0) ^ 2.0)) / Float64(1.0 + sqrt(t_0)))
end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[Power[N[Power[N[(0.25 + N[(-0.25 / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(0.5 + N[(-0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision] / N[Power[N[Power[t$95$0, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{\frac{\sqrt[3]{{\left(0.25 + \frac{-0.25}{\mathsf{fma}\left(x, x, 1\right)}\right)}^{2}} \cdot \sqrt[3]{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}}{{\left(\sqrt[3]{t_0}\right)}^{2}}}{1 + \sqrt{t_0}}
\end{array}

Error

Derivation

  1. Initial program 15.2

    \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
  2. Simplified15.2

    \[\leadsto \color{blue}{1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
    Proof
    (-.f64 1 (sqrt.f64 (+.f64 1/2 (/.f64 1/2 (hypot.f64 1 x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 1 (sqrt.f64 (+.f64 (Rewrite<= metadata-eval (*.f64 1 1/2)) (/.f64 1/2 (hypot.f64 1 x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 1 (sqrt.f64 (+.f64 (*.f64 1 1/2) (/.f64 (Rewrite<= metadata-eval (*.f64 1 1/2)) (hypot.f64 1 x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 1 (sqrt.f64 (+.f64 (*.f64 1 1/2) (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 (hypot.f64 1 x)) 1/2))))): 0 points increase in error, 0 points decrease in error
    (-.f64 1 (sqrt.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 1/2 (+.f64 1 (/.f64 1 (hypot.f64 1 x))))))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr14.7

    \[\leadsto \color{blue}{\frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}} \]
  4. Applied egg-rr14.7

    \[\leadsto \frac{\color{blue}{\frac{0.25 - \frac{0.25}{\mathsf{fma}\left(x, x, 1\right)}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
  5. Applied egg-rr15.2

    \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{{\left(0.25 + \frac{-0.25}{\mathsf{fma}\left(x, x, 1\right)}\right)}^{2}}}{{\left(\sqrt[3]{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\right)}^{2}} \cdot \sqrt[3]{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
  6. Simplified14.7

    \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{{\left(0.25 + \frac{-0.25}{\mathsf{fma}\left(x, x, 1\right)}\right)}^{2}} \cdot \sqrt[3]{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}}{{\left(\sqrt[3]{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\right)}^{2}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
    Proof
    (/.f64 (*.f64 (cbrt.f64 (pow.f64 (+.f64 1/4 (/.f64 -1/4 (fma.f64 x x 1))) 2)) (cbrt.f64 (+.f64 1/2 (/.f64 -1/2 (hypot.f64 1 x))))) (pow.f64 (cbrt.f64 (+.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))) 2)): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 (cbrt.f64 (pow.f64 (+.f64 1/4 (/.f64 -1/4 (fma.f64 x x 1))) 2)) (cbrt.f64 (+.f64 1/2 (/.f64 (Rewrite<= metadata-eval (neg.f64 1/2)) (hypot.f64 1 x))))) (pow.f64 (cbrt.f64 (+.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))) 2)): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 (cbrt.f64 (pow.f64 (+.f64 1/4 (/.f64 -1/4 (fma.f64 x x 1))) 2)) (cbrt.f64 (+.f64 1/2 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 1/2 (hypot.f64 1 x))))))) (pow.f64 (cbrt.f64 (+.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))) 2)): 0 points increase in error, 0 points decrease in error
    (/.f64 (*.f64 (cbrt.f64 (pow.f64 (+.f64 1/4 (/.f64 -1/4 (fma.f64 x x 1))) 2)) (cbrt.f64 (Rewrite=> unsub-neg_binary64 (-.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))))) (pow.f64 (cbrt.f64 (+.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))) 2)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (cbrt.f64 (pow.f64 (+.f64 1/4 (/.f64 -1/4 (fma.f64 x x 1))) 2)) (pow.f64 (cbrt.f64 (+.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))) 2)) (cbrt.f64 (-.f64 1/2 (/.f64 1/2 (hypot.f64 1 x)))))): 2 points increase in error, 117 points decrease in error
  7. Final simplification14.7

    \[\leadsto \frac{\frac{\sqrt[3]{{\left(0.25 + \frac{-0.25}{\mathsf{fma}\left(x, x, 1\right)}\right)}^{2}} \cdot \sqrt[3]{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}}{{\left(\sqrt[3]{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\right)}^{2}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

Alternatives

Alternative 1
Error14.7
Cost20352
\[\frac{0.5 - \sqrt{\frac{0.25}{1 + x \cdot x}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
Alternative 2
Error14.7
Cost20160
\[\frac{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
Alternative 3
Error57.2
Cost13312
\[1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \]
Alternative 4
Error15.2
Cost13312
\[1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \]

Error

Reproduce

herbie shell --seed 2022334 
(FPCore (x)
  :name "Given's Rotation SVD example, simplified"
  :precision binary64
  (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))