
(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}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (v) :precision binary64 (/ (/ 1.3333333333333333 (* (- 1.0 (* v v)) PI)) (sqrt (fma -6.0 (* v v) 2.0))))
double code(double v) {
return (1.3333333333333333 / ((1.0 - (v * v)) * ((double) M_PI))) / sqrt(fma(-6.0, (v * v), 2.0));
}
function code(v) return Float64(Float64(1.3333333333333333 / Float64(Float64(1.0 - Float64(v * v)) * pi)) / sqrt(fma(-6.0, Float64(v * v), 2.0))) end
code[v_] := N[(N[(1.3333333333333333 / N[(N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1.3333333333333333}{\left(1 - v \cdot v\right) \cdot \pi}}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64100.0
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
(FPCore (v) :precision binary64 (/ (/ -1.3333333333333333 (fma v v -1.0)) (* PI (sqrt (fma -6.0 (* v v) 2.0)))))
double code(double v) {
return (-1.3333333333333333 / fma(v, v, -1.0)) / (((double) M_PI) * sqrt(fma(-6.0, (v * v), 2.0)));
}
function code(v) return Float64(Float64(-1.3333333333333333 / fma(v, v, -1.0)) / Float64(pi * sqrt(fma(-6.0, Float64(v * v), 2.0)))) end
code[v_] := N[(N[(-1.3333333333333333 / N[(v * v + -1.0), $MachinePrecision]), $MachinePrecision] / N[(Pi * N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1.3333333333333333}{\mathsf{fma}\left(v, v, -1\right)}}{\pi \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64100.0
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-/l/N/A
lower-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
metadata-evalN/A
sub-flipN/A
lift-*.f64N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (v) :precision binary64 (/ -1.3333333333333333 (* (* (fma v v -1.0) PI) (sqrt (fma -6.0 (* v v) 2.0)))))
double code(double v) {
return -1.3333333333333333 / ((fma(v, v, -1.0) * ((double) M_PI)) * sqrt(fma(-6.0, (v * v), 2.0)));
}
function code(v) return Float64(-1.3333333333333333 / Float64(Float64(fma(v, v, -1.0) * pi) * sqrt(fma(-6.0, Float64(v * v), 2.0)))) end
code[v_] := N[(-1.3333333333333333 / N[(N[(N[(v * v + -1.0), $MachinePrecision] * Pi), $MachinePrecision] * N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1.3333333333333333}{\left(\mathsf{fma}\left(v, v, -1\right) \cdot \pi\right) \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64100.0
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
lift-/.f64N/A
lift-/.f64N/A
frac-2negN/A
associate-/l/N/A
lower-/.f64N/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
sub-flipN/A
lift-*.f64N/A
metadata-evalN/A
lower-fma.f64100.0
Applied rewrites100.0%
(FPCore (v) :precision binary64 (/ (/ 4.0 (* 3.0 PI)) (sqrt (+ (fma (* v v) -6.0 1.0) 1.0))))
double code(double v) {
return (4.0 / (3.0 * ((double) M_PI))) / sqrt((fma((v * v), -6.0, 1.0) + 1.0));
}
function code(v) return Float64(Float64(4.0 / Float64(3.0 * pi)) / sqrt(Float64(fma(Float64(v * v), -6.0, 1.0) + 1.0))) end
code[v_] := N[(N[(4.0 / N[(3.0 * Pi), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(v * v), $MachinePrecision] * -6.0 + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{4}{3 \cdot \pi}}{\sqrt{\mathsf{fma}\left(v \cdot v, -6, 1\right) + 1}}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
lower-*.f64N/A
lower-PI.f6497.4
Applied rewrites97.4%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lift-fma.f64N/A
lower-*.f6497.4
Applied rewrites97.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f64N/A
lower-/.f6498.9
lift-*.f64N/A
lift-fma.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6498.9
Applied rewrites98.9%
lift-fma.f64N/A
metadata-evalN/A
associate-+r+N/A
lower-+.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f6498.9
Applied rewrites98.9%
(FPCore (v) :precision binary64 (/ (/ 4.0 (* 3.0 PI)) (sqrt (fma -6.0 (* v v) 2.0))))
double code(double v) {
return (4.0 / (3.0 * ((double) M_PI))) / sqrt(fma(-6.0, (v * v), 2.0));
}
function code(v) return Float64(Float64(4.0 / Float64(3.0 * pi)) / sqrt(fma(-6.0, Float64(v * v), 2.0))) end
code[v_] := N[(N[(4.0 / N[(3.0 * Pi), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{4}{3 \cdot \pi}}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
lower-*.f64N/A
lower-PI.f6497.4
Applied rewrites97.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lift-fma.f64N/A
lower-/.f64N/A
lower-/.f6498.9
Applied rewrites98.9%
(FPCore (v) :precision binary64 (* 1.3333333333333333 (/ (/ 1.0 PI) (sqrt (fma (* v -6.0) v 2.0)))))
double code(double v) {
return 1.3333333333333333 * ((1.0 / ((double) M_PI)) / sqrt(fma((v * -6.0), v, 2.0)));
}
function code(v) return Float64(1.3333333333333333 * Float64(Float64(1.0 / pi) / sqrt(fma(Float64(v * -6.0), v, 2.0)))) end
code[v_] := N[(1.3333333333333333 * N[(N[(1.0 / Pi), $MachinePrecision] / N[Sqrt[N[(N[(v * -6.0), $MachinePrecision] * v + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1.3333333333333333 \cdot \frac{\frac{1}{\pi}}{\sqrt{\mathsf{fma}\left(v \cdot -6, v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64100.0
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
Taylor expanded in v around 0
lower-PI.f6498.9
Applied rewrites98.9%
lift-/.f64N/A
lift-/.f64N/A
mult-flipN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6498.9
lift-*.f64N/A
lift-fma.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-fma.f6498.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
(FPCore (v) :precision binary64 (/ (/ 1.3333333333333333 (sqrt (fma (* v -6.0) v 2.0))) PI))
double code(double v) {
return (1.3333333333333333 / sqrt(fma((v * -6.0), v, 2.0))) / ((double) M_PI);
}
function code(v) return Float64(Float64(1.3333333333333333 / sqrt(fma(Float64(v * -6.0), v, 2.0))) / pi) end
code[v_] := N[(N[(1.3333333333333333 / N[Sqrt[N[(N[(v * -6.0), $MachinePrecision] * v + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1.3333333333333333}{\sqrt{\mathsf{fma}\left(v \cdot -6, v, 2\right)}}}{\pi}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64100.0
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-/l/N/A
lower-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
metadata-evalN/A
sub-flipN/A
lift-*.f64N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in v around 0
Applied rewrites98.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6498.9
lift-*.f64N/A
lift-fma.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-fma.f6498.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
(FPCore (v) :precision binary64 (/ 1.3333333333333333 (* PI (sqrt (fma -6.0 (* v v) 2.0)))))
double code(double v) {
return 1.3333333333333333 / (((double) M_PI) * sqrt(fma(-6.0, (v * v), 2.0)));
}
function code(v) return Float64(1.3333333333333333 / Float64(pi * sqrt(fma(-6.0, Float64(v * v), 2.0)))) end
code[v_] := N[(1.3333333333333333 / N[(Pi * N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.3333333333333333}{\pi \cdot \sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64100.0
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
Applied rewrites100.0%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-/l/N/A
lower-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
metadata-evalN/A
sub-flipN/A
lift-*.f64N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in v around 0
Applied rewrites98.9%
(FPCore (v) :precision binary64 (/ 1.3333333333333333 (* PI (sqrt 2.0))))
double code(double v) {
return 1.3333333333333333 / (((double) M_PI) * sqrt(2.0));
}
public static double code(double v) {
return 1.3333333333333333 / (Math.PI * Math.sqrt(2.0));
}
def code(v): return 1.3333333333333333 / (math.pi * math.sqrt(2.0))
function code(v) return Float64(1.3333333333333333 / Float64(pi * sqrt(2.0))) end
function tmp = code(v) tmp = 1.3333333333333333 / (pi * sqrt(2.0)); end
code[v_] := N[(1.3333333333333333 / N[(Pi * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.3333333333333333}{\pi \cdot \sqrt{2}}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6498.9
Applied rewrites98.9%
herbie shell --seed 2025142
(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)))))))