
(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 7 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 (sqrt (- 2.0 (* (* v v) 6.0)))) (- 1.0 (* v v))) PI))
double code(double v) {
return ((1.3333333333333333 / sqrt((2.0 - ((v * v) * 6.0)))) / (1.0 - (v * v))) / ((double) M_PI);
}
public static double code(double v) {
return ((1.3333333333333333 / Math.sqrt((2.0 - ((v * v) * 6.0)))) / (1.0 - (v * v))) / Math.PI;
}
def code(v): return ((1.3333333333333333 / math.sqrt((2.0 - ((v * v) * 6.0)))) / (1.0 - (v * v))) / math.pi
function code(v) return Float64(Float64(Float64(1.3333333333333333 / sqrt(Float64(2.0 - Float64(Float64(v * v) * 6.0)))) / Float64(1.0 - Float64(v * v))) / pi) end
function tmp = code(v) tmp = ((1.3333333333333333 / sqrt((2.0 - ((v * v) * 6.0)))) / (1.0 - (v * v))) / pi; end
code[v_] := N[(N[(N[(1.3333333333333333 / N[Sqrt[N[(2.0 - N[(N[(v * v), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{1.3333333333333333}{\sqrt{2 - \left(v \cdot v\right) \cdot 6}}}{1 - v \cdot v}}{\pi}
\end{array}
Initial program 98.5%
associate-/r*N/A
associate-*l*N/A
associate-/r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l/N/A
sub-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
associate-*r*N/A
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
Applied egg-rr100.0%
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f64N/A
Applied egg-rr100.0%
(FPCore (v) :precision binary64 (/ (/ (/ 1.3333333333333333 PI) (sqrt (+ 2.0 (* (* v v) -6.0)))) (- 1.0 (* v v))))
double code(double v) {
return ((1.3333333333333333 / ((double) M_PI)) / sqrt((2.0 + ((v * v) * -6.0)))) / (1.0 - (v * v));
}
public static double code(double v) {
return ((1.3333333333333333 / Math.PI) / Math.sqrt((2.0 + ((v * v) * -6.0)))) / (1.0 - (v * v));
}
def code(v): return ((1.3333333333333333 / math.pi) / math.sqrt((2.0 + ((v * v) * -6.0)))) / (1.0 - (v * v))
function code(v) return Float64(Float64(Float64(1.3333333333333333 / pi) / sqrt(Float64(2.0 + Float64(Float64(v * v) * -6.0)))) / Float64(1.0 - Float64(v * v))) end
function tmp = code(v) tmp = ((1.3333333333333333 / pi) / sqrt((2.0 + ((v * v) * -6.0)))) / (1.0 - (v * v)); end
code[v_] := N[(N[(N[(1.3333333333333333 / Pi), $MachinePrecision] / N[Sqrt[N[(2.0 + N[(N[(v * v), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{1.3333333333333333}{\pi}}{\sqrt{2 + \left(v \cdot v\right) \cdot -6}}}{1 - v \cdot v}
\end{array}
Initial program 98.5%
associate-/r*N/A
associate-*l*N/A
associate-/r*N/A
metadata-evalN/A
*-commutativeN/A
associate-/l/N/A
sub-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
associate-*r*N/A
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f64N/A
Applied egg-rr100.0%
(FPCore (v) :precision binary64 (/ (/ 4.0 PI) (* (sqrt (- 2.0 (* (* v v) 6.0))) 3.0)))
double code(double v) {
return (4.0 / ((double) M_PI)) / (sqrt((2.0 - ((v * v) * 6.0))) * 3.0);
}
public static double code(double v) {
return (4.0 / Math.PI) / (Math.sqrt((2.0 - ((v * v) * 6.0))) * 3.0);
}
def code(v): return (4.0 / math.pi) / (math.sqrt((2.0 - ((v * v) * 6.0))) * 3.0)
function code(v) return Float64(Float64(4.0 / pi) / Float64(sqrt(Float64(2.0 - Float64(Float64(v * v) * 6.0))) * 3.0)) end
function tmp = code(v) tmp = (4.0 / pi) / (sqrt((2.0 - ((v * v) * 6.0))) * 3.0); end
code[v_] := N[(N[(4.0 / Pi), $MachinePrecision] / N[(N[Sqrt[N[(2.0 - N[(N[(v * v), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{4}{\pi}}{\sqrt{2 - \left(v \cdot v\right) \cdot 6} \cdot 3}
\end{array}
Initial program 98.5%
associate-/r*N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
PI-lowering-PI.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sub-negN/A
+-lowering-+.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0
/-lowering-/.f64N/A
PI-lowering-PI.f6499.4%
Simplified99.4%
div-invN/A
associate-/l*N/A
metadata-evalN/A
times-fracN/A
div-invN/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (v) :precision binary64 (/ (/ 1.3333333333333333 (sqrt (- 2.0 (* (* v v) 6.0)))) PI))
double code(double v) {
return (1.3333333333333333 / sqrt((2.0 - ((v * v) * 6.0)))) / ((double) M_PI);
}
public static double code(double v) {
return (1.3333333333333333 / Math.sqrt((2.0 - ((v * v) * 6.0)))) / Math.PI;
}
def code(v): return (1.3333333333333333 / math.sqrt((2.0 - ((v * v) * 6.0)))) / math.pi
function code(v) return Float64(Float64(1.3333333333333333 / sqrt(Float64(2.0 - Float64(Float64(v * v) * 6.0)))) / pi) end
function tmp = code(v) tmp = (1.3333333333333333 / sqrt((2.0 - ((v * v) * 6.0)))) / pi; end
code[v_] := N[(N[(1.3333333333333333 / N[Sqrt[N[(2.0 - N[(N[(v * v), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1.3333333333333333}{\sqrt{2 - \left(v \cdot v\right) \cdot 6}}}{\pi}
\end{array}
Initial program 98.5%
associate-/r*N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
PI-lowering-PI.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sub-negN/A
+-lowering-+.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0
/-lowering-/.f64N/A
PI-lowering-PI.f6499.4%
Simplified99.4%
div-invN/A
pow1/2N/A
pow-flipN/A
associate-*r*N/A
metadata-evalN/A
associate-*l/N/A
*-commutativeN/A
/-lowering-/.f64N/A
Applied egg-rr99.4%
(FPCore (v) :precision binary64 (/ (/ 1.3333333333333333 PI) (sqrt (+ 2.0 (* v (* v -6.0))))))
double code(double v) {
return (1.3333333333333333 / ((double) M_PI)) / sqrt((2.0 + (v * (v * -6.0))));
}
public static double code(double v) {
return (1.3333333333333333 / Math.PI) / Math.sqrt((2.0 + (v * (v * -6.0))));
}
def code(v): return (1.3333333333333333 / math.pi) / math.sqrt((2.0 + (v * (v * -6.0))))
function code(v) return Float64(Float64(1.3333333333333333 / pi) / sqrt(Float64(2.0 + Float64(v * Float64(v * -6.0))))) end
function tmp = code(v) tmp = (1.3333333333333333 / pi) / sqrt((2.0 + (v * (v * -6.0)))); end
code[v_] := N[(N[(1.3333333333333333 / Pi), $MachinePrecision] / N[Sqrt[N[(2.0 + N[(v * N[(v * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1.3333333333333333}{\pi}}{\sqrt{2 + v \cdot \left(v \cdot -6\right)}}
\end{array}
Initial program 98.5%
associate-/r*N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
associate-/r*N/A
/-lowering-/.f64N/A
metadata-evalN/A
PI-lowering-PI.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
sub-negN/A
+-lowering-+.f64N/A
associate-*r*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
metadata-eval100.0%
Simplified100.0%
Taylor expanded in v around 0
/-lowering-/.f64N/A
PI-lowering-PI.f6499.4%
Simplified99.4%
(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%
Taylor expanded in v around 0
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f6499.3%
Simplified99.3%
associate-*r*N/A
associate-/r*N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6499.3%
Applied egg-rr99.3%
(FPCore (v) :precision binary64 (/ (* 1.3333333333333333 (sqrt 0.5)) PI))
double code(double v) {
return (1.3333333333333333 * sqrt(0.5)) / ((double) M_PI);
}
public static double code(double v) {
return (1.3333333333333333 * Math.sqrt(0.5)) / Math.PI;
}
def code(v): return (1.3333333333333333 * math.sqrt(0.5)) / math.pi
function code(v) return Float64(Float64(1.3333333333333333 * sqrt(0.5)) / pi) end
function tmp = code(v) tmp = (1.3333333333333333 * sqrt(0.5)) / pi; end
code[v_] := N[(N[(1.3333333333333333 * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]
\begin{array}{l}
\\
\frac{1.3333333333333333 \cdot \sqrt{0.5}}{\pi}
\end{array}
Initial program 98.5%
Taylor expanded in v around 0
associate-*r/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
PI-lowering-PI.f6497.8%
Simplified97.8%
herbie shell --seed 2024139
(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)))))))