Average Error: 0.0 → 0.0
Time: 12.6s
Precision: binary64
Cost: 14016
\[\left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(1 - v \cdot v\right) \]
\[\begin{array}{l} t_0 := 1 - v \cdot v\\ \sqrt{\left(\mathsf{fma}\left(v, v \cdot -3, 1\right) \cdot 0.125\right) \cdot \left(t_0 \cdot t_0\right)} \end{array} \]
(FPCore (v)
 :precision binary64
 (* (* (/ (sqrt 2.0) 4.0) (sqrt (- 1.0 (* 3.0 (* v v))))) (- 1.0 (* v v))))
(FPCore (v)
 :precision binary64
 (let* ((t_0 (- 1.0 (* v v))))
   (sqrt (* (* (fma v (* v -3.0) 1.0) 0.125) (* t_0 t_0)))))
double code(double v) {
	return ((sqrt(2.0) / 4.0) * sqrt((1.0 - (3.0 * (v * v))))) * (1.0 - (v * v));
}
double code(double v) {
	double t_0 = 1.0 - (v * v);
	return sqrt(((fma(v, (v * -3.0), 1.0) * 0.125) * (t_0 * t_0)));
}
function code(v)
	return Float64(Float64(Float64(sqrt(2.0) / 4.0) * sqrt(Float64(1.0 - Float64(3.0 * Float64(v * v))))) * Float64(1.0 - Float64(v * v)))
end
function code(v)
	t_0 = Float64(1.0 - Float64(v * v))
	return sqrt(Float64(Float64(fma(v, Float64(v * -3.0), 1.0) * 0.125) * Float64(t_0 * t_0)))
end
code[v_] := N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] / 4.0), $MachinePrecision] * N[Sqrt[N[(1.0 - N[(3.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[v_] := Block[{t$95$0 = N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]}, N[Sqrt[N[(N[(N[(v * N[(v * -3.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.125), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(1 - v \cdot v\right)
\begin{array}{l}
t_0 := 1 - v \cdot v\\
\sqrt{\left(\mathsf{fma}\left(v, v \cdot -3, 1\right) \cdot 0.125\right) \cdot \left(t_0 \cdot t_0\right)}
\end{array}

Error

Derivation

  1. Initial program 0.0

    \[\left(\frac{\sqrt{2}}{4} \cdot \sqrt{1 - 3 \cdot \left(v \cdot v\right)}\right) \cdot \left(1 - v \cdot v\right) \]
  2. Applied egg-rr0.0

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(v \cdot v, -3, 1\right) \cdot 0.125} + \left(v \cdot \left(-v\right)\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -3, 1\right) \cdot 0.125}} \]
  3. Simplified0.0

    \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(v \cdot v, -3, 1\right) \cdot 0.125} \cdot \left(1 - v \cdot v\right)} \]
    Proof
    (*.f64 (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8)) (-.f64 1 (*.f64 v v))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8)) (Rewrite=> sub-neg_binary64 (+.f64 1 (neg.f64 (*.f64 v v))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8)) (+.f64 1 (Rewrite<= distribute-rgt-neg-out_binary64 (*.f64 v (neg.f64 v))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 1 (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8))) (*.f64 (*.f64 v (neg.f64 v)) (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8))))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> *-lft-identity_binary64 (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8))) (*.f64 (*.f64 v (neg.f64 v)) (sqrt.f64 (*.f64 (fma.f64 (*.f64 v v) -3 1) 1/8)))): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr0.0

    \[\leadsto \color{blue}{\sqrt{\left(\mathsf{fma}\left(v, v \cdot -3, 1\right) \cdot 0.125\right) \cdot {\left(1 - v \cdot v\right)}^{2}}} \]
  5. Applied egg-rr0.0

    \[\leadsto \sqrt{\left(\mathsf{fma}\left(v, v \cdot -3, 1\right) \cdot 0.125\right) \cdot \color{blue}{\left(\left(1 - v \cdot v\right) \cdot \left(1 - v \cdot v\right)\right)}} \]
  6. Final simplification0.0

    \[\leadsto \sqrt{\left(\mathsf{fma}\left(v, v \cdot -3, 1\right) \cdot 0.125\right) \cdot \left(\left(1 - v \cdot v\right) \cdot \left(1 - v \cdot v\right)\right)} \]

Alternatives

Alternative 1
Error0.0
Cost7360
\[\left(1 - v \cdot v\right) \cdot \sqrt{0.125 \cdot \left(1 + v \cdot \left(v \cdot -3\right)\right)} \]
Alternative 2
Error0.3
Cost6976
\[\sqrt{2} \cdot \left(0.25 + \left(v \cdot v\right) \cdot -0.625\right) \]
Alternative 3
Error0.7
Cost6464
\[\sqrt{0.125} \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (v)
  :name "Falkner and Boettcher, Appendix B, 2"
  :precision binary64
  (* (* (/ (sqrt 2.0) 4.0) (sqrt (- 1.0 (* 3.0 (* v v))))) (- 1.0 (* v v))))