
(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 6 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 (/ (/ 4.0 (* (- 1.0 (* v v)) (* PI 3.0))) (sqrt (fma -6.0 (* v v) 2.0))))
double code(double v) {
return (4.0 / ((1.0 - (v * v)) * (((double) M_PI) * 3.0))) / sqrt(fma(-6.0, (v * v), 2.0));
}
function code(v) return Float64(Float64(4.0 / Float64(Float64(1.0 - Float64(v * v)) * Float64(pi * 3.0))) / sqrt(fma(-6.0, Float64(v * v), 2.0))) end
code[v_] := N[(N[(4.0 / N[(N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision] * N[(Pi * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{4}{\left(1 - v \cdot v\right) \cdot \left(\pi \cdot 3\right)}}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites100.0%
(FPCore (v) :precision binary64 (/ (fma (/ (* v v) PI) 1.3333333333333333 (/ 1.3333333333333333 PI)) (sqrt (fma -6.0 (* v v) 2.0))))
double code(double v) {
return fma(((v * v) / ((double) M_PI)), 1.3333333333333333, (1.3333333333333333 / ((double) M_PI))) / sqrt(fma(-6.0, (v * v), 2.0));
}
function code(v) return Float64(fma(Float64(Float64(v * v) / pi), 1.3333333333333333, Float64(1.3333333333333333 / pi)) / sqrt(fma(-6.0, Float64(v * v), 2.0))) end
code[v_] := N[(N[(N[(N[(v * v), $MachinePrecision] / Pi), $MachinePrecision] * 1.3333333333333333 + N[(1.3333333333333333 / Pi), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\frac{v \cdot v}{\pi}, 1.3333333333333333, \frac{1.3333333333333333}{\pi}\right)}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in v around 0
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-PI.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lift-PI.f6499.5
Applied rewrites99.5%
(FPCore (v) :precision binary64 (/ (/ 4.0 (* PI 3.0)) (sqrt (fma (* -6.0 v) v 2.0))))
double code(double v) {
return (4.0 / (((double) M_PI) * 3.0)) / sqrt(fma((-6.0 * v), v, 2.0));
}
function code(v) return Float64(Float64(4.0 / Float64(pi * 3.0)) / sqrt(fma(Float64(-6.0 * v), v, 2.0))) end
code[v_] := N[(N[(4.0 / N[(Pi * 3.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(-6.0 * v), $MachinePrecision] * v + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{4}{\pi \cdot 3}}{\sqrt{\mathsf{fma}\left(-6 \cdot v, v, 2\right)}}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6497.5
Applied rewrites97.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
Applied rewrites99.0%
(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(Float64(1.3333333333333333 / pi) / sqrt(fma(-6.0, Float64(v * v), 2.0))) end
code[v_] := N[(N[(1.3333333333333333 / Pi), $MachinePrecision] / N[Sqrt[N[(-6.0 * N[(v * v), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1.3333333333333333}{\pi}}{\sqrt{\mathsf{fma}\left(-6, v \cdot v, 2\right)}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in v around 0
lower-/.f64N/A
lift-PI.f6499.0
Applied rewrites99.0%
(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(Float64(1.3333333333333333 / pi) / sqrt(2.0)) end
function tmp = code(v) tmp = (1.3333333333333333 / pi) / sqrt(2.0); end
code[v_] := N[(N[(1.3333333333333333 / Pi), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1.3333333333333333}{\pi}}{\sqrt{2}}
\end{array}
Initial program 98.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in v around 0
lower-/.f64N/A
lift-PI.f6499.0
Applied rewrites99.0%
Taylor expanded in v around 0
Applied rewrites99.0%
(FPCore (v) :precision binary64 (* (/ (sqrt 0.5) PI) 1.3333333333333333))
double code(double v) {
return (sqrt(0.5) / ((double) M_PI)) * 1.3333333333333333;
}
public static double code(double v) {
return (Math.sqrt(0.5) / Math.PI) * 1.3333333333333333;
}
def code(v): return (math.sqrt(0.5) / math.pi) * 1.3333333333333333
function code(v) return Float64(Float64(sqrt(0.5) / pi) * 1.3333333333333333) end
function tmp = code(v) tmp = (sqrt(0.5) / pi) * 1.3333333333333333; end
code[v_] := N[(N[(N[Sqrt[0.5], $MachinePrecision] / Pi), $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{0.5}}{\pi} \cdot 1.3333333333333333
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-PI.f6497.5
Applied rewrites97.5%
herbie shell --seed 2025131
(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)))))))