
(FPCore (x) :precision binary64 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
double code(double x) {
return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
public static double code(double x) {
return (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
def code(x): return (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
function code(x) return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0))))) end
function tmp = code(x) tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0)))); end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))
double code(double x) {
return (((double) M_PI) / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0))));
}
public static double code(double x) {
return (Math.PI / 2.0) - (2.0 * Math.asin(Math.sqrt(((1.0 - x) / 2.0))));
}
def code(x): return (math.pi / 2.0) - (2.0 * math.asin(math.sqrt(((1.0 - x) / 2.0))))
function code(x) return Float64(Float64(pi / 2.0) - Float64(2.0 * asin(sqrt(Float64(Float64(1.0 - x) / 2.0))))) end
function tmp = code(x) tmp = (pi / 2.0) - (2.0 * asin(sqrt(((1.0 - x) / 2.0)))); end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(2.0 * N[ArcSin[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* PI PI) 0.25))
(t_1 (acos (sqrt (+ 0.5 (* -0.5 x)))))
(t_2 (pow t_1 2.0)))
(*
(/
(+ t_0 (* t_1 (- (* t_1 4.0) PI)))
(- (pow (+ t_0 (* 4.0 t_2)) 2.0) (* (* PI PI) t_2)))
(+ (* (* PI (* PI PI)) -0.125) (* (pow t_1 3.0) 8.0)))))
double code(double x) {
double t_0 = (((double) M_PI) * ((double) M_PI)) * 0.25;
double t_1 = acos(sqrt((0.5 + (-0.5 * x))));
double t_2 = pow(t_1, 2.0);
return ((t_0 + (t_1 * ((t_1 * 4.0) - ((double) M_PI)))) / (pow((t_0 + (4.0 * t_2)), 2.0) - ((((double) M_PI) * ((double) M_PI)) * t_2))) * (((((double) M_PI) * (((double) M_PI) * ((double) M_PI))) * -0.125) + (pow(t_1, 3.0) * 8.0));
}
public static double code(double x) {
double t_0 = (Math.PI * Math.PI) * 0.25;
double t_1 = Math.acos(Math.sqrt((0.5 + (-0.5 * x))));
double t_2 = Math.pow(t_1, 2.0);
return ((t_0 + (t_1 * ((t_1 * 4.0) - Math.PI))) / (Math.pow((t_0 + (4.0 * t_2)), 2.0) - ((Math.PI * Math.PI) * t_2))) * (((Math.PI * (Math.PI * Math.PI)) * -0.125) + (Math.pow(t_1, 3.0) * 8.0));
}
def code(x): t_0 = (math.pi * math.pi) * 0.25 t_1 = math.acos(math.sqrt((0.5 + (-0.5 * x)))) t_2 = math.pow(t_1, 2.0) return ((t_0 + (t_1 * ((t_1 * 4.0) - math.pi))) / (math.pow((t_0 + (4.0 * t_2)), 2.0) - ((math.pi * math.pi) * t_2))) * (((math.pi * (math.pi * math.pi)) * -0.125) + (math.pow(t_1, 3.0) * 8.0))
function code(x) t_0 = Float64(Float64(pi * pi) * 0.25) t_1 = acos(sqrt(Float64(0.5 + Float64(-0.5 * x)))) t_2 = t_1 ^ 2.0 return Float64(Float64(Float64(t_0 + Float64(t_1 * Float64(Float64(t_1 * 4.0) - pi))) / Float64((Float64(t_0 + Float64(4.0 * t_2)) ^ 2.0) - Float64(Float64(pi * pi) * t_2))) * Float64(Float64(Float64(pi * Float64(pi * pi)) * -0.125) + Float64((t_1 ^ 3.0) * 8.0))) end
function tmp = code(x) t_0 = (pi * pi) * 0.25; t_1 = acos(sqrt((0.5 + (-0.5 * x)))); t_2 = t_1 ^ 2.0; tmp = ((t_0 + (t_1 * ((t_1 * 4.0) - pi))) / (((t_0 + (4.0 * t_2)) ^ 2.0) - ((pi * pi) * t_2))) * (((pi * (pi * pi)) * -0.125) + ((t_1 ^ 3.0) * 8.0)); end
code[x_] := Block[{t$95$0 = N[(N[(Pi * Pi), $MachinePrecision] * 0.25), $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[Sqrt[N[(0.5 + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 2.0], $MachinePrecision]}, N[(N[(N[(t$95$0 + N[(t$95$1 * N[(N[(t$95$1 * 4.0), $MachinePrecision] - Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[N[(t$95$0 + N[(4.0 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(N[(Pi * Pi), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(Pi * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] + N[(N[Power[t$95$1, 3.0], $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\pi \cdot \pi\right) \cdot 0.25\\
t_1 := \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right)\\
t_2 := {t\_1}^{2}\\
\frac{t\_0 + t\_1 \cdot \left(t\_1 \cdot 4 - \pi\right)}{{\left(t\_0 + 4 \cdot t\_2\right)}^{2} - \left(\pi \cdot \pi\right) \cdot t\_2} \cdot \left(\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.125 + {t\_1}^{3} \cdot 8\right)
\end{array}
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Applied egg-rr9.3%
Applied egg-rr9.3%
Taylor expanded in x around 0
Simplified9.3%
Final simplification9.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (* PI PI) 4.0))
(t_1 (+ 0.5 (/ x -2.0)))
(t_2 (* -2.0 (acos (sqrt t_1))))
(t_3 (* 2.0 (acos (pow t_1 0.5))))
(t_4 (- PI t_3)))
(+
(* (/ (* PI PI) (+ t_0 (* (+ PI t_2) (+ t_2 (* PI 1.5))))) (/ PI 8.0))
(/ (pow t_4 3.0) (- (* t_4 (- (- t_3 PI) (/ PI 2.0))) t_0)))))
double code(double x) {
double t_0 = (((double) M_PI) * ((double) M_PI)) / 4.0;
double t_1 = 0.5 + (x / -2.0);
double t_2 = -2.0 * acos(sqrt(t_1));
double t_3 = 2.0 * acos(pow(t_1, 0.5));
double t_4 = ((double) M_PI) - t_3;
return (((((double) M_PI) * ((double) M_PI)) / (t_0 + ((((double) M_PI) + t_2) * (t_2 + (((double) M_PI) * 1.5))))) * (((double) M_PI) / 8.0)) + (pow(t_4, 3.0) / ((t_4 * ((t_3 - ((double) M_PI)) - (((double) M_PI) / 2.0))) - t_0));
}
public static double code(double x) {
double t_0 = (Math.PI * Math.PI) / 4.0;
double t_1 = 0.5 + (x / -2.0);
double t_2 = -2.0 * Math.acos(Math.sqrt(t_1));
double t_3 = 2.0 * Math.acos(Math.pow(t_1, 0.5));
double t_4 = Math.PI - t_3;
return (((Math.PI * Math.PI) / (t_0 + ((Math.PI + t_2) * (t_2 + (Math.PI * 1.5))))) * (Math.PI / 8.0)) + (Math.pow(t_4, 3.0) / ((t_4 * ((t_3 - Math.PI) - (Math.PI / 2.0))) - t_0));
}
def code(x): t_0 = (math.pi * math.pi) / 4.0 t_1 = 0.5 + (x / -2.0) t_2 = -2.0 * math.acos(math.sqrt(t_1)) t_3 = 2.0 * math.acos(math.pow(t_1, 0.5)) t_4 = math.pi - t_3 return (((math.pi * math.pi) / (t_0 + ((math.pi + t_2) * (t_2 + (math.pi * 1.5))))) * (math.pi / 8.0)) + (math.pow(t_4, 3.0) / ((t_4 * ((t_3 - math.pi) - (math.pi / 2.0))) - t_0))
function code(x) t_0 = Float64(Float64(pi * pi) / 4.0) t_1 = Float64(0.5 + Float64(x / -2.0)) t_2 = Float64(-2.0 * acos(sqrt(t_1))) t_3 = Float64(2.0 * acos((t_1 ^ 0.5))) t_4 = Float64(pi - t_3) return Float64(Float64(Float64(Float64(pi * pi) / Float64(t_0 + Float64(Float64(pi + t_2) * Float64(t_2 + Float64(pi * 1.5))))) * Float64(pi / 8.0)) + Float64((t_4 ^ 3.0) / Float64(Float64(t_4 * Float64(Float64(t_3 - pi) - Float64(pi / 2.0))) - t_0))) end
function tmp = code(x) t_0 = (pi * pi) / 4.0; t_1 = 0.5 + (x / -2.0); t_2 = -2.0 * acos(sqrt(t_1)); t_3 = 2.0 * acos((t_1 ^ 0.5)); t_4 = pi - t_3; tmp = (((pi * pi) / (t_0 + ((pi + t_2) * (t_2 + (pi * 1.5))))) * (pi / 8.0)) + ((t_4 ^ 3.0) / ((t_4 * ((t_3 - pi) - (pi / 2.0))) - t_0)); end
code[x_] := Block[{t$95$0 = N[(N[(Pi * Pi), $MachinePrecision] / 4.0), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 + N[(x / -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-2.0 * N[ArcCos[N[Sqrt[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(2.0 * N[ArcCos[N[Power[t$95$1, 0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(Pi - t$95$3), $MachinePrecision]}, N[(N[(N[(N[(Pi * Pi), $MachinePrecision] / N[(t$95$0 + N[(N[(Pi + t$95$2), $MachinePrecision] * N[(t$95$2 + N[(Pi * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(Pi / 8.0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[t$95$4, 3.0], $MachinePrecision] / N[(N[(t$95$4 * N[(N[(t$95$3 - Pi), $MachinePrecision] - N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\pi \cdot \pi}{4}\\
t_1 := 0.5 + \frac{x}{-2}\\
t_2 := -2 \cdot \cos^{-1} \left(\sqrt{t\_1}\right)\\
t_3 := 2 \cdot \cos^{-1} \left({t\_1}^{0.5}\right)\\
t_4 := \pi - t\_3\\
\frac{\pi \cdot \pi}{t\_0 + \left(\pi + t\_2\right) \cdot \left(t\_2 + \pi \cdot 1.5\right)} \cdot \frac{\pi}{8} + \frac{{t\_4}^{3}}{t\_4 \cdot \left(\left(t\_3 - \pi\right) - \frac{\pi}{2}\right) - t\_0}
\end{array}
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Applied egg-rr9.3%
Applied egg-rr9.3%
Final simplification9.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (acos (pow (+ 0.5 (/ x -2.0)) 0.5))))
(/
(- (* (* PI (* PI PI)) -0.125) (pow (* -2.0 t_0) 3.0))
(+ (pow (* 2.0 t_0) 2.0) (+ (/ (* PI PI) 4.0) (* PI t_0))))))
double code(double x) {
double t_0 = acos(pow((0.5 + (x / -2.0)), 0.5));
return (((((double) M_PI) * (((double) M_PI) * ((double) M_PI))) * -0.125) - pow((-2.0 * t_0), 3.0)) / (pow((2.0 * t_0), 2.0) + (((((double) M_PI) * ((double) M_PI)) / 4.0) + (((double) M_PI) * t_0)));
}
public static double code(double x) {
double t_0 = Math.acos(Math.pow((0.5 + (x / -2.0)), 0.5));
return (((Math.PI * (Math.PI * Math.PI)) * -0.125) - Math.pow((-2.0 * t_0), 3.0)) / (Math.pow((2.0 * t_0), 2.0) + (((Math.PI * Math.PI) / 4.0) + (Math.PI * t_0)));
}
def code(x): t_0 = math.acos(math.pow((0.5 + (x / -2.0)), 0.5)) return (((math.pi * (math.pi * math.pi)) * -0.125) - math.pow((-2.0 * t_0), 3.0)) / (math.pow((2.0 * t_0), 2.0) + (((math.pi * math.pi) / 4.0) + (math.pi * t_0)))
function code(x) t_0 = acos((Float64(0.5 + Float64(x / -2.0)) ^ 0.5)) return Float64(Float64(Float64(Float64(pi * Float64(pi * pi)) * -0.125) - (Float64(-2.0 * t_0) ^ 3.0)) / Float64((Float64(2.0 * t_0) ^ 2.0) + Float64(Float64(Float64(pi * pi) / 4.0) + Float64(pi * t_0)))) end
function tmp = code(x) t_0 = acos(((0.5 + (x / -2.0)) ^ 0.5)); tmp = (((pi * (pi * pi)) * -0.125) - ((-2.0 * t_0) ^ 3.0)) / (((2.0 * t_0) ^ 2.0) + (((pi * pi) / 4.0) + (pi * t_0))); end
code[x_] := Block[{t$95$0 = N[ArcCos[N[Power[N[(0.5 + N[(x / -2.0), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(Pi * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] - N[Power[N[(-2.0 * t$95$0), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[N[(2.0 * t$95$0), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(Pi * Pi), $MachinePrecision] / 4.0), $MachinePrecision] + N[(Pi * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left({\left(0.5 + \frac{x}{-2}\right)}^{0.5}\right)\\
\frac{\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.125 - {\left(-2 \cdot t\_0\right)}^{3}}{{\left(2 \cdot t\_0\right)}^{2} + \left(\frac{\pi \cdot \pi}{4} + \pi \cdot t\_0\right)}
\end{array}
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Applied egg-rr9.3%
unpow2N/A
flip3--N/A
Applied egg-rr9.3%
Applied egg-rr9.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (acos (sqrt (+ 0.5 (* -0.5 x))))))
(/
(+ (* (* PI (* PI PI)) -0.125) (* (pow t_0 3.0) 8.0))
(+ (* t_0 (+ PI (* t_0 4.0))) (* PI (* PI 0.25))))))
double code(double x) {
double t_0 = acos(sqrt((0.5 + (-0.5 * x))));
return (((((double) M_PI) * (((double) M_PI) * ((double) M_PI))) * -0.125) + (pow(t_0, 3.0) * 8.0)) / ((t_0 * (((double) M_PI) + (t_0 * 4.0))) + (((double) M_PI) * (((double) M_PI) * 0.25)));
}
public static double code(double x) {
double t_0 = Math.acos(Math.sqrt((0.5 + (-0.5 * x))));
return (((Math.PI * (Math.PI * Math.PI)) * -0.125) + (Math.pow(t_0, 3.0) * 8.0)) / ((t_0 * (Math.PI + (t_0 * 4.0))) + (Math.PI * (Math.PI * 0.25)));
}
def code(x): t_0 = math.acos(math.sqrt((0.5 + (-0.5 * x)))) return (((math.pi * (math.pi * math.pi)) * -0.125) + (math.pow(t_0, 3.0) * 8.0)) / ((t_0 * (math.pi + (t_0 * 4.0))) + (math.pi * (math.pi * 0.25)))
function code(x) t_0 = acos(sqrt(Float64(0.5 + Float64(-0.5 * x)))) return Float64(Float64(Float64(Float64(pi * Float64(pi * pi)) * -0.125) + Float64((t_0 ^ 3.0) * 8.0)) / Float64(Float64(t_0 * Float64(pi + Float64(t_0 * 4.0))) + Float64(pi * Float64(pi * 0.25)))) end
function tmp = code(x) t_0 = acos(sqrt((0.5 + (-0.5 * x)))); tmp = (((pi * (pi * pi)) * -0.125) + ((t_0 ^ 3.0) * 8.0)) / ((t_0 * (pi + (t_0 * 4.0))) + (pi * (pi * 0.25))); end
code[x_] := Block[{t$95$0 = N[ArcCos[N[Sqrt[N[(0.5 + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(Pi * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] + N[(N[Power[t$95$0, 3.0], $MachinePrecision] * 8.0), $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$0 * N[(Pi + N[(t$95$0 * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(Pi * N[(Pi * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos^{-1} \left(\sqrt{0.5 + -0.5 \cdot x}\right)\\
\frac{\left(\pi \cdot \left(\pi \cdot \pi\right)\right) \cdot -0.125 + {t\_0}^{3} \cdot 8}{t\_0 \cdot \left(\pi + t\_0 \cdot 4\right) + \pi \cdot \left(\pi \cdot 0.25\right)}
\end{array}
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Applied egg-rr9.3%
Taylor expanded in x around 0
Simplified9.3%
Final simplification9.3%
(FPCore (x) :precision binary64 (- (/ PI 2.0) (+ PI (* -2.0 (acos (sqrt (- 0.5 (* 0.5 x))))))))
double code(double x) {
return (((double) M_PI) / 2.0) - (((double) M_PI) + (-2.0 * acos(sqrt((0.5 - (0.5 * x))))));
}
public static double code(double x) {
return (Math.PI / 2.0) - (Math.PI + (-2.0 * Math.acos(Math.sqrt((0.5 - (0.5 * x))))));
}
def code(x): return (math.pi / 2.0) - (math.pi + (-2.0 * math.acos(math.sqrt((0.5 - (0.5 * x))))))
function code(x) return Float64(Float64(pi / 2.0) - Float64(pi + Float64(-2.0 * acos(sqrt(Float64(0.5 - Float64(0.5 * x))))))) end
function tmp = code(x) tmp = (pi / 2.0) - (pi + (-2.0 * acos(sqrt((0.5 - (0.5 * x)))))); end
code[x_] := N[(N[(Pi / 2.0), $MachinePrecision] - N[(Pi + N[(-2.0 * N[ArcCos[N[Sqrt[N[(0.5 - N[(0.5 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\pi}{2} - \left(\pi + -2 \cdot \cos^{-1} \left(\sqrt{0.5 - 0.5 \cdot x}\right)\right)
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Taylor expanded in x around 0
metadata-evalN/A
cancel-sign-sub-invN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
acos-lowering-acos.f64N/A
sqrt-lowering-sqrt.f64N/A
--lowering--.f64N/A
*-lowering-*.f649.3%
Simplified9.3%
(FPCore (x) :precision binary64 (- (* PI -0.5) (* -2.0 (acos (sqrt (+ 0.5 (/ x -2.0)))))))
double code(double x) {
return (((double) M_PI) * -0.5) - (-2.0 * acos(sqrt((0.5 + (x / -2.0)))));
}
public static double code(double x) {
return (Math.PI * -0.5) - (-2.0 * Math.acos(Math.sqrt((0.5 + (x / -2.0)))));
}
def code(x): return (math.pi * -0.5) - (-2.0 * math.acos(math.sqrt((0.5 + (x / -2.0)))))
function code(x) return Float64(Float64(pi * -0.5) - Float64(-2.0 * acos(sqrt(Float64(0.5 + Float64(x / -2.0)))))) end
function tmp = code(x) tmp = (pi * -0.5) - (-2.0 * acos(sqrt((0.5 + (x / -2.0))))); end
code[x_] := N[(N[(Pi * -0.5), $MachinePrecision] - N[(-2.0 * N[ArcCos[N[Sqrt[N[(0.5 + N[(x / -2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot -0.5 - -2 \cdot \cos^{-1} \left(\sqrt{0.5 + \frac{x}{-2}}\right)
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Applied egg-rr9.3%
unpow2N/A
flip3--N/A
--lowering--.f64N/A
Applied egg-rr9.3%
(FPCore (x) :precision binary64 (+ (* PI -0.5) (* 2.0 (acos (sqrt 0.5)))))
double code(double x) {
return (((double) M_PI) * -0.5) + (2.0 * acos(sqrt(0.5)));
}
public static double code(double x) {
return (Math.PI * -0.5) + (2.0 * Math.acos(Math.sqrt(0.5)));
}
def code(x): return (math.pi * -0.5) + (2.0 * math.acos(math.sqrt(0.5)))
function code(x) return Float64(Float64(pi * -0.5) + Float64(2.0 * acos(sqrt(0.5)))) end
function tmp = code(x) tmp = (pi * -0.5) + (2.0 * acos(sqrt(0.5))); end
code[x_] := N[(N[(Pi * -0.5), $MachinePrecision] + N[(2.0 * N[ArcCos[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\pi \cdot -0.5 + 2 \cdot \cos^{-1} \left(\sqrt{0.5}\right)
\end{array}
Initial program 8.2%
asin-acosN/A
sub-negN/A
distribute-rgt-inN/A
div-invN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
*-rgt-identityN/A
+-lowering-+.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
Applied egg-rr9.3%
Taylor expanded in x around 0
sqrt-lowering-sqrt.f645.2%
Simplified5.2%
associate--r+N/A
sub0-negN/A
cancel-sign-subN/A
+-lowering-+.f64N/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
*-un-lft-identityN/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
metadata-evalN/A
*-lowering-*.f64N/A
acos-lowering-acos.f64N/A
sqrt-lowering-sqrt.f645.2%
Applied egg-rr5.2%
Final simplification5.2%
(FPCore (x) :precision binary64 (asin x))
double code(double x) {
return asin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = asin(x)
end function
public static double code(double x) {
return Math.asin(x);
}
def code(x): return math.asin(x)
function code(x) return asin(x) end
function tmp = code(x) tmp = asin(x); end
code[x_] := N[ArcSin[x], $MachinePrecision]
\begin{array}{l}
\\
\sin^{-1} x
\end{array}
herbie shell --seed 2024148
(FPCore (x)
:name "Ian Simplification"
:precision binary64
:alt
(! :herbie-platform default (asin x))
(- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))