Falkner and Boettcher, Equation (22+)

Percentage Accurate: 98.5% → 100.0%
Time: 2.4s
Alternatives: 4
Speedup: N/A×

Specification

?
\[\begin{array}{l} \\ \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))
double code(double v) {
	return 4.0 / (((3.0 * ((double) M_PI)) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
}
public static double code(double v) {
	return 4.0 / (((3.0 * Math.PI) * (1.0 - (v * v))) * Math.sqrt((2.0 - (6.0 * (v * v)))));
}
def code(v):
	return 4.0 / (((3.0 * math.pi) * (1.0 - (v * v))) * math.sqrt((2.0 - (6.0 * (v * v)))))
function code(v)
	return Float64(4.0 / Float64(Float64(Float64(3.0 * pi) * Float64(1.0 - Float64(v * v))) * sqrt(Float64(2.0 - Float64(6.0 * Float64(v * v))))))
end
function tmp = code(v)
	tmp = 4.0 / (((3.0 * pi) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
end
code[v_] := N[(4.0 / N[(N[(N[(3.0 * Pi), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 - N[(6.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 98.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))
double code(double v) {
	return 4.0 / (((3.0 * ((double) M_PI)) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
}
public static double code(double v) {
	return 4.0 / (((3.0 * Math.PI) * (1.0 - (v * v))) * Math.sqrt((2.0 - (6.0 * (v * v)))));
}
def code(v):
	return 4.0 / (((3.0 * math.pi) * (1.0 - (v * v))) * math.sqrt((2.0 - (6.0 * (v * v)))))
function code(v)
	return Float64(4.0 / Float64(Float64(Float64(3.0 * pi) * Float64(1.0 - Float64(v * v))) * sqrt(Float64(2.0 - Float64(6.0 * Float64(v * v))))))
end
function tmp = code(v)
	tmp = 4.0 / (((3.0 * pi) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
end
code[v_] := N[(4.0 / N[(N[(N[(3.0 * Pi), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 - N[(6.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}
\end{array}

Alternative 1: 100.0% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{\frac{4}{\frac{1 - {v}^{4}}{1 + v \cdot v} \cdot \left(\pi \cdot 3\right)}}{{\left(\mathsf{fma}\left(-6, v \cdot v, 2\right)\right)}^{0.5}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/
  (/ 4.0 (* (/ (- 1.0 (pow v 4.0)) (+ 1.0 (* v v))) (* PI 3.0)))
  (pow (fma -6.0 (* v v) 2.0) 0.5)))
double code(double v) {
	return (4.0 / (((1.0 - pow(v, 4.0)) / (1.0 + (v * v))) * (((double) M_PI) * 3.0))) / pow(fma(-6.0, (v * v), 2.0), 0.5);
}
function code(v)
	return Float64(Float64(4.0 / Float64(Float64(Float64(1.0 - (v ^ 4.0)) / Float64(1.0 + Float64(v * v))) * Float64(pi * 3.0))) / (fma(-6.0, Float64(v * v), 2.0) ^ 0.5))
end
code[v_] := N[(N[(4.0 / N[(N[(N[(1.0 - N[Power[v, 4.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(Pi * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{4}{\frac{1 - {v}^{4}}{1 + v \cdot v} \cdot \left(\pi \cdot 3\right)}}{{\left(\mathsf{fma}\left(-6, v \cdot v, 2\right)\right)}^{0.5}}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4}{\color{blue}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right)} \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    4. lift-PI.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    5. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\color{blue}{\left(3 \cdot \mathsf{PI}\left(\right)\right)} \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    6. lift--.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\left(1 - v \cdot v\right)}\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - \color{blue}{v \cdot v}\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
    8. lift-sqrt.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \color{blue}{\sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    9. lift--.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    10. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - \color{blue}{6 \cdot \left(v \cdot v\right)}}} \]
    11. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \color{blue}{\left(v \cdot v\right)}}} \]
    12. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)}}{\sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    13. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{4}{\left(3 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(1 - v \cdot v\right)}}{\sqrt{2 - 6 \cdot \left(v \cdot v\right)}}} \]
  4. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{\frac{4}{\frac{1 - {v}^{4}}{1 + v \cdot v} \cdot \left(\pi \cdot 3\right)}}{{\left(\mathsf{fma}\left(-6, v \cdot v, 2\right)\right)}^{0.5}}} \]
  5. Add Preprocessing

Alternative 2: 98.5% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(v \cdot v\right)\\ \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {t\_0}^{3}}{4 + \left(t\_0 \cdot t\_0 - 2 \cdot t\_0\right)}}} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (* -6.0 (* v v))))
   (/
    4.0
    (*
     (* (* 3.0 PI) (- 1.0 (* v v)))
     (sqrt (/ (+ 8.0 (pow t_0 3.0)) (+ 4.0 (- (* t_0 t_0) (* 2.0 t_0)))))))))
double code(double v) {
	double t_0 = -6.0 * (v * v);
	return 4.0 / (((3.0 * ((double) M_PI)) * (1.0 - (v * v))) * sqrt(((8.0 + pow(t_0, 3.0)) / (4.0 + ((t_0 * t_0) - (2.0 * t_0))))));
}
public static double code(double v) {
	double t_0 = -6.0 * (v * v);
	return 4.0 / (((3.0 * Math.PI) * (1.0 - (v * v))) * Math.sqrt(((8.0 + Math.pow(t_0, 3.0)) / (4.0 + ((t_0 * t_0) - (2.0 * t_0))))));
}
def code(v):
	t_0 = -6.0 * (v * v)
	return 4.0 / (((3.0 * math.pi) * (1.0 - (v * v))) * math.sqrt(((8.0 + math.pow(t_0, 3.0)) / (4.0 + ((t_0 * t_0) - (2.0 * t_0))))))
function code(v)
	t_0 = Float64(-6.0 * Float64(v * v))
	return Float64(4.0 / Float64(Float64(Float64(3.0 * pi) * Float64(1.0 - Float64(v * v))) * sqrt(Float64(Float64(8.0 + (t_0 ^ 3.0)) / Float64(4.0 + Float64(Float64(t_0 * t_0) - Float64(2.0 * t_0)))))))
end
function tmp = code(v)
	t_0 = -6.0 * (v * v);
	tmp = 4.0 / (((3.0 * pi) * (1.0 - (v * v))) * sqrt(((8.0 + (t_0 ^ 3.0)) / (4.0 + ((t_0 * t_0) - (2.0 * t_0))))));
end
code[v_] := Block[{t$95$0 = N[(-6.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]}, N[(4.0 / N[(N[(N[(3.0 * Pi), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(8.0 + N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision] / N[(4.0 + N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -6 \cdot \left(v \cdot v\right)\\
\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {t\_0}^{3}}{4 + \left(t\_0 \cdot t\_0 - 2 \cdot t\_0\right)}}}
\end{array}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{2 - 6 \cdot \left(v \cdot v\right)}}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - \color{blue}{6 \cdot \left(v \cdot v\right)}}} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \color{blue}{\left(v \cdot v\right)}}} \]
    4. pow2N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \color{blue}{{v}^{2}}}} \]
    5. metadata-evalN/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - \color{blue}{\left(\mathsf{neg}\left(-6\right)\right)} \cdot {v}^{2}}} \]
    6. fp-cancel-sign-sub-invN/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{2 + -6 \cdot {v}^{2}}}} \]
    7. flip3-+N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\frac{{2}^{3} + {\left(-6 \cdot {v}^{2}\right)}^{3}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}}} \]
    8. lower-/.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\frac{{2}^{3} + {\left(-6 \cdot {v}^{2}\right)}^{3}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}}} \]
    9. lower-+.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{\color{blue}{{2}^{3} + {\left(-6 \cdot {v}^{2}\right)}^{3}}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    10. metadata-evalN/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{\color{blue}{8} + {\left(-6 \cdot {v}^{2}\right)}^{3}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    11. lower-pow.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + \color{blue}{{\left(-6 \cdot {v}^{2}\right)}^{3}}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    12. lower-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {\color{blue}{\left(-6 \cdot {v}^{2}\right)}}^{3}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    13. pow2N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {\left(-6 \cdot \color{blue}{\left(v \cdot v\right)}\right)}^{3}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    14. lift-*.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {\left(-6 \cdot \color{blue}{\left(v \cdot v\right)}\right)}^{3}}{2 \cdot 2 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    15. metadata-evalN/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {\left(-6 \cdot \left(v \cdot v\right)\right)}^{3}}{\color{blue}{4} + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}} \]
    16. lower-+.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {\left(-6 \cdot \left(v \cdot v\right)\right)}^{3}}{\color{blue}{4 + \left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}}} \]
    17. lower--.f64N/A

      \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\frac{8 + {\left(-6 \cdot \left(v \cdot v\right)\right)}^{3}}{4 + \color{blue}{\left(\left(-6 \cdot {v}^{2}\right) \cdot \left(-6 \cdot {v}^{2}\right) - 2 \cdot \left(-6 \cdot {v}^{2}\right)\right)}}}} \]
  4. Applied rewrites98.5%

    \[\leadsto \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\frac{8 + {\left(-6 \cdot \left(v \cdot v\right)\right)}^{3}}{4 + \left(\left(-6 \cdot \left(v \cdot v\right)\right) \cdot \left(-6 \cdot \left(v \cdot v\right)\right) - 2 \cdot \left(-6 \cdot \left(v \cdot v\right)\right)\right)}}}} \]
  5. Add Preprocessing

Alternative 3: 98.5% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))
double code(double v) {
	return 4.0 / (((3.0 * ((double) M_PI)) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
}
public static double code(double v) {
	return 4.0 / (((3.0 * Math.PI) * (1.0 - (v * v))) * Math.sqrt((2.0 - (6.0 * (v * v)))));
}
def code(v):
	return 4.0 / (((3.0 * math.pi) * (1.0 - (v * v))) * math.sqrt((2.0 - (6.0 * (v * v)))))
function code(v)
	return Float64(4.0 / Float64(Float64(Float64(3.0 * pi) * Float64(1.0 - Float64(v * v))) * sqrt(Float64(2.0 - Float64(6.0 * Float64(v * v))))))
end
function tmp = code(v)
	tmp = 4.0 / (((3.0 * pi) * (1.0 - (v * v))) * sqrt((2.0 - (6.0 * (v * v)))));
end
code[v_] := N[(4.0 / N[(N[(N[(3.0 * Pi), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 - N[(6.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 4: 98.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\pi}{{\left({2}^{0.5}\right)}^{3}}\\ t_1 := \frac{\pi}{{2}^{0.5}}\\ t_2 := {2}^{0.5} \cdot \pi\\ \frac{4}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(3 \cdot \left(v \cdot v\right), \mathsf{fma}\left(\frac{\pi}{{\left({2}^{0.5}\right)}^{5}}, -13.5, t\_0 \cdot 4.5\right), \mathsf{fma}\left(t\_0, -4.5, t\_1 \cdot 3\right) \cdot 3\right), v \cdot v, \mathsf{fma}\left(-1, t\_2, t\_1 \cdot -3\right) \cdot 3\right), v \cdot v, t\_2 \cdot 3\right)} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (/ PI (pow (pow 2.0 0.5) 3.0)))
        (t_1 (/ PI (pow 2.0 0.5)))
        (t_2 (* (pow 2.0 0.5) PI)))
   (/
    4.0
    (fma
     (fma
      (fma
       (* 3.0 (* v v))
       (fma (/ PI (pow (pow 2.0 0.5) 5.0)) -13.5 (* t_0 4.5))
       (* (fma t_0 -4.5 (* t_1 3.0)) 3.0))
      (* v v)
      (* (fma -1.0 t_2 (* t_1 -3.0)) 3.0))
     (* v v)
     (* t_2 3.0)))))
double code(double v) {
	double t_0 = ((double) M_PI) / pow(pow(2.0, 0.5), 3.0);
	double t_1 = ((double) M_PI) / pow(2.0, 0.5);
	double t_2 = pow(2.0, 0.5) * ((double) M_PI);
	return 4.0 / fma(fma(fma((3.0 * (v * v)), fma((((double) M_PI) / pow(pow(2.0, 0.5), 5.0)), -13.5, (t_0 * 4.5)), (fma(t_0, -4.5, (t_1 * 3.0)) * 3.0)), (v * v), (fma(-1.0, t_2, (t_1 * -3.0)) * 3.0)), (v * v), (t_2 * 3.0));
}
function code(v)
	t_0 = Float64(pi / ((2.0 ^ 0.5) ^ 3.0))
	t_1 = Float64(pi / (2.0 ^ 0.5))
	t_2 = Float64((2.0 ^ 0.5) * pi)
	return Float64(4.0 / fma(fma(fma(Float64(3.0 * Float64(v * v)), fma(Float64(pi / ((2.0 ^ 0.5) ^ 5.0)), -13.5, Float64(t_0 * 4.5)), Float64(fma(t_0, -4.5, Float64(t_1 * 3.0)) * 3.0)), Float64(v * v), Float64(fma(-1.0, t_2, Float64(t_1 * -3.0)) * 3.0)), Float64(v * v), Float64(t_2 * 3.0)))
end
code[v_] := Block[{t$95$0 = N[(Pi / N[Power[N[Power[2.0, 0.5], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(Pi / N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[2.0, 0.5], $MachinePrecision] * Pi), $MachinePrecision]}, N[(4.0 / N[(N[(N[(N[(3.0 * N[(v * v), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi / N[Power[N[Power[2.0, 0.5], $MachinePrecision], 5.0], $MachinePrecision]), $MachinePrecision] * -13.5 + N[(t$95$0 * 4.5), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 * -4.5 + N[(t$95$1 * 3.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] * N[(v * v), $MachinePrecision] + N[(N[(-1.0 * t$95$2 + N[(t$95$1 * -3.0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] * N[(v * v), $MachinePrecision] + N[(t$95$2 * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\pi}{{\left({2}^{0.5}\right)}^{3}}\\
t_1 := \frac{\pi}{{2}^{0.5}}\\
t_2 := {2}^{0.5} \cdot \pi\\
\frac{4}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(3 \cdot \left(v \cdot v\right), \mathsf{fma}\left(\frac{\pi}{{\left({2}^{0.5}\right)}^{5}}, -13.5, t\_0 \cdot 4.5\right), \mathsf{fma}\left(t\_0, -4.5, t\_1 \cdot 3\right) \cdot 3\right), v \cdot v, \mathsf{fma}\left(-1, t\_2, t\_1 \cdot -3\right) \cdot 3\right), v \cdot v, t\_2 \cdot 3\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\frac{4}{\left(\left(3 \cdot \pi\right) \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 - 6 \cdot \left(v \cdot v\right)}} \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \frac{4}{\color{blue}{3 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{2}\right) + {v}^{2} \cdot \left(3 \cdot \left(-3 \cdot \frac{\mathsf{PI}\left(\right)}{\sqrt{2}} + -1 \cdot \left(\mathsf{PI}\left(\right) \cdot \sqrt{2}\right)\right) + {v}^{2} \cdot \left(3 \cdot \left({v}^{2} \cdot \left(\frac{-27}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{\left(\sqrt{2}\right)}^{5}} + \frac{9}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{\left(\sqrt{2}\right)}^{3}}\right)\right) + 3 \cdot \left(\frac{-9}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{\left(\sqrt{2}\right)}^{3}} + 3 \cdot \frac{\mathsf{PI}\left(\right)}{\sqrt{2}}\right)\right)\right)}} \]
  4. Applied rewrites97.9%

    \[\leadsto \frac{4}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(3 \cdot \left(v \cdot v\right), \mathsf{fma}\left(\frac{\pi}{{\left({2}^{0.5}\right)}^{5}}, -13.5, \frac{\pi}{{\left({2}^{0.5}\right)}^{3}} \cdot 4.5\right), \mathsf{fma}\left(\frac{\pi}{{\left({2}^{0.5}\right)}^{3}}, -4.5, \frac{\pi}{{2}^{0.5}} \cdot 3\right) \cdot 3\right), v \cdot v, \mathsf{fma}\left(-1, {2}^{0.5} \cdot \pi, \frac{\pi}{{2}^{0.5}} \cdot -3\right) \cdot 3\right), v \cdot v, \left({2}^{0.5} \cdot \pi\right) \cdot 3\right)}} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 2025064 
(FPCore (v)
  :name "Falkner and Boettcher, Equation (22+)"
  :precision binary64
  (/ 4.0 (* (* (* 3.0 PI) (- 1.0 (* v v))) (sqrt (- 2.0 (* 6.0 (* v v)))))))