
(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:
Herbie found 4 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 (* (* PI (- 1.0 (* v v))) (sqrt (fma v (* v -6.0) 2.0)))))
double code(double v) {
return 1.3333333333333333 / ((((double) M_PI) * (1.0 - (v * v))) * sqrt(fma(v, (v * -6.0), 2.0)));
}
function code(v) return Float64(1.3333333333333333 / Float64(Float64(pi * Float64(1.0 - Float64(v * v))) * sqrt(fma(v, Float64(v * -6.0), 2.0)))) end
code[v_] := N[(1.3333333333333333 / N[(N[(Pi * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(v * N[(v * -6.0), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.3333333333333333}{\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}}
\end{array}
Initial program 98.5%
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
metadata-eval98.5
Applied rewrites98.5%
Applied rewrites100.0%
(FPCore (v) :precision binary64 (/ (/ 4.0 (* PI (sqrt (fma v (* v -6.0) 2.0)))) 3.0))
double code(double v) {
return (4.0 / (((double) M_PI) * sqrt(fma(v, (v * -6.0), 2.0)))) / 3.0;
}
function code(v) return Float64(Float64(4.0 / Float64(pi * sqrt(fma(v, Float64(v * -6.0), 2.0)))) / 3.0) end
code[v_] := N[(N[(4.0 / N[(Pi * N[Sqrt[N[(v * N[(v * -6.0), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{4}{\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}}}{3}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6497.3
Applied rewrites97.3%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
associate-/r*N/A
div-invN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
metadata-evalN/A
lift-PI.f64N/A
lift-*.f64N/A
flip-+N/A
flip-+N/A
lift-fma.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-/r*N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites98.8%
(FPCore (v) :precision binary64 (/ 1.3333333333333333 (* PI (sqrt (fma v (* v -6.0) 2.0)))))
double code(double v) {
return 1.3333333333333333 / (((double) M_PI) * sqrt(fma(v, (v * -6.0), 2.0)));
}
function code(v) return Float64(1.3333333333333333 / Float64(pi * sqrt(fma(v, Float64(v * -6.0), 2.0)))) end
code[v_] := N[(1.3333333333333333 / N[(Pi * N[Sqrt[N[(v * N[(v * -6.0), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.3333333333333333}{\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6497.3
Applied rewrites97.3%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
associate-/r*N/A
div-invN/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f6498.8
Applied rewrites98.8%
(FPCore (v) :precision binary64 (* (/ 1.3333333333333333 PI) (sqrt 0.5)))
double code(double v) {
return (1.3333333333333333 / ((double) M_PI)) * sqrt(0.5);
}
public static double code(double v) {
return (1.3333333333333333 / Math.PI) * Math.sqrt(0.5);
}
def code(v): return (1.3333333333333333 / math.pi) * math.sqrt(0.5)
function code(v) return Float64(Float64(1.3333333333333333 / pi) * sqrt(0.5)) end
function tmp = code(v) tmp = (1.3333333333333333 / pi) * sqrt(0.5); end
code[v_] := N[(N[(1.3333333333333333 / Pi), $MachinePrecision] * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.3333333333333333}{\pi} \cdot \sqrt{0.5}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-PI.f6497.2
Applied rewrites97.2%
lift-sqrt.f64N/A
lift-PI.f64N/A
*-rgt-identityN/A
times-fracN/A
metadata-evalN/A
associate-/r*N/A
*-commutativeN/A
lift-*.f64N/A
/-rgt-identityN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6498.7
Applied rewrites98.7%
herbie shell --seed 2024219
(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)))))))