
(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]
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
Herbie found 8 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]
\frac{\pi}{2} - 2 \cdot \sin^{-1} \left(\sqrt{\frac{1 - x}{2}}\right)
(FPCore (x)
:precision binary64
(let* ((t_0 (- PI (* 0.5 PI)))
(t_1 (* t_0 t_0))
(t_2 (* (* -0.5 PI) (* -0.5 PI)))
(t_3 (acos (sqrt (* (- 1.0 x) 0.5))))
(t_4 (pow t_3 2.0))
(t_5 (* t_4 4.0)))
(/
(/
(- (* t_1 t_1) (* t_5 t_5))
(* (- 1.0 (/ (* -4.0 t_4) t_2)) t_2))
(+ (- (* 0.5 PI) PI) (* t_3 -2.0)))))double code(double x) {
double t_0 = ((double) M_PI) - (0.5 * ((double) M_PI));
double t_1 = t_0 * t_0;
double t_2 = (-0.5 * ((double) M_PI)) * (-0.5 * ((double) M_PI));
double t_3 = acos(sqrt(((1.0 - x) * 0.5)));
double t_4 = pow(t_3, 2.0);
double t_5 = t_4 * 4.0;
return (((t_1 * t_1) - (t_5 * t_5)) / ((1.0 - ((-4.0 * t_4) / t_2)) * t_2)) / (((0.5 * ((double) M_PI)) - ((double) M_PI)) + (t_3 * -2.0));
}
public static double code(double x) {
double t_0 = Math.PI - (0.5 * Math.PI);
double t_1 = t_0 * t_0;
double t_2 = (-0.5 * Math.PI) * (-0.5 * Math.PI);
double t_3 = Math.acos(Math.sqrt(((1.0 - x) * 0.5)));
double t_4 = Math.pow(t_3, 2.0);
double t_5 = t_4 * 4.0;
return (((t_1 * t_1) - (t_5 * t_5)) / ((1.0 - ((-4.0 * t_4) / t_2)) * t_2)) / (((0.5 * Math.PI) - Math.PI) + (t_3 * -2.0));
}
def code(x): t_0 = math.pi - (0.5 * math.pi) t_1 = t_0 * t_0 t_2 = (-0.5 * math.pi) * (-0.5 * math.pi) t_3 = math.acos(math.sqrt(((1.0 - x) * 0.5))) t_4 = math.pow(t_3, 2.0) t_5 = t_4 * 4.0 return (((t_1 * t_1) - (t_5 * t_5)) / ((1.0 - ((-4.0 * t_4) / t_2)) * t_2)) / (((0.5 * math.pi) - math.pi) + (t_3 * -2.0))
function code(x) t_0 = Float64(pi - Float64(0.5 * pi)) t_1 = Float64(t_0 * t_0) t_2 = Float64(Float64(-0.5 * pi) * Float64(-0.5 * pi)) t_3 = acos(sqrt(Float64(Float64(1.0 - x) * 0.5))) t_4 = t_3 ^ 2.0 t_5 = Float64(t_4 * 4.0) return Float64(Float64(Float64(Float64(t_1 * t_1) - Float64(t_5 * t_5)) / Float64(Float64(1.0 - Float64(Float64(-4.0 * t_4) / t_2)) * t_2)) / Float64(Float64(Float64(0.5 * pi) - pi) + Float64(t_3 * -2.0))) end
function tmp = code(x) t_0 = pi - (0.5 * pi); t_1 = t_0 * t_0; t_2 = (-0.5 * pi) * (-0.5 * pi); t_3 = acos(sqrt(((1.0 - x) * 0.5))); t_4 = t_3 ^ 2.0; t_5 = t_4 * 4.0; tmp = (((t_1 * t_1) - (t_5 * t_5)) / ((1.0 - ((-4.0 * t_4) / t_2)) * t_2)) / (((0.5 * pi) - pi) + (t_3 * -2.0)); end
code[x_] := Block[{t$95$0 = N[(Pi - N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 * Pi), $MachinePrecision] * N[(-0.5 * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcCos[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[t$95$3, 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * 4.0), $MachinePrecision]}, N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$5 * t$95$5), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(N[(-4.0 * t$95$4), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(0.5 * Pi), $MachinePrecision] - Pi), $MachinePrecision] + N[(t$95$3 * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \pi - 0.5 \cdot \pi\\
t_1 := t\_0 \cdot t\_0\\
t_2 := \left(-0.5 \cdot \pi\right) \cdot \left(-0.5 \cdot \pi\right)\\
t_3 := \cos^{-1} \left(\sqrt{\left(1 - x\right) \cdot 0.5}\right)\\
t_4 := {t\_3}^{2}\\
t_5 := t\_4 \cdot 4\\
\frac{\frac{t\_1 \cdot t\_1 - t\_5 \cdot t\_5}{\left(1 - \frac{-4 \cdot t\_4}{t\_2}\right) \cdot t\_2}}{\left(0.5 \cdot \pi - \pi\right) + t\_3 \cdot -2}
\end{array}
Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
lift--.f64N/A
lift-+.f64N/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
lift-+.f64N/A
add-flipN/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites8.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (- PI (* 0.5 PI)))
(t_1 (* t_0 t_0))
(t_2 (acos (sqrt (* (- 1.0 x) 0.5))))
(t_3 (* (pow t_2 2.0) 4.0)))
(/
(/ (- (* t_1 t_1) (* t_3 t_3)) (+ t_1 t_3))
(+ (- (* 0.5 PI) PI) (* t_2 -2.0)))))double code(double x) {
double t_0 = ((double) M_PI) - (0.5 * ((double) M_PI));
double t_1 = t_0 * t_0;
double t_2 = acos(sqrt(((1.0 - x) * 0.5)));
double t_3 = pow(t_2, 2.0) * 4.0;
return (((t_1 * t_1) - (t_3 * t_3)) / (t_1 + t_3)) / (((0.5 * ((double) M_PI)) - ((double) M_PI)) + (t_2 * -2.0));
}
public static double code(double x) {
double t_0 = Math.PI - (0.5 * Math.PI);
double t_1 = t_0 * t_0;
double t_2 = Math.acos(Math.sqrt(((1.0 - x) * 0.5)));
double t_3 = Math.pow(t_2, 2.0) * 4.0;
return (((t_1 * t_1) - (t_3 * t_3)) / (t_1 + t_3)) / (((0.5 * Math.PI) - Math.PI) + (t_2 * -2.0));
}
def code(x): t_0 = math.pi - (0.5 * math.pi) t_1 = t_0 * t_0 t_2 = math.acos(math.sqrt(((1.0 - x) * 0.5))) t_3 = math.pow(t_2, 2.0) * 4.0 return (((t_1 * t_1) - (t_3 * t_3)) / (t_1 + t_3)) / (((0.5 * math.pi) - math.pi) + (t_2 * -2.0))
function code(x) t_0 = Float64(pi - Float64(0.5 * pi)) t_1 = Float64(t_0 * t_0) t_2 = acos(sqrt(Float64(Float64(1.0 - x) * 0.5))) t_3 = Float64((t_2 ^ 2.0) * 4.0) return Float64(Float64(Float64(Float64(t_1 * t_1) - Float64(t_3 * t_3)) / Float64(t_1 + t_3)) / Float64(Float64(Float64(0.5 * pi) - pi) + Float64(t_2 * -2.0))) end
function tmp = code(x) t_0 = pi - (0.5 * pi); t_1 = t_0 * t_0; t_2 = acos(sqrt(((1.0 - x) * 0.5))); t_3 = (t_2 ^ 2.0) * 4.0; tmp = (((t_1 * t_1) - (t_3 * t_3)) / (t_1 + t_3)) / (((0.5 * pi) - pi) + (t_2 * -2.0)); end
code[x_] := Block[{t$95$0 = N[(Pi - N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[ArcCos[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[t$95$2, 2.0], $MachinePrecision] * 4.0), $MachinePrecision]}, N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 + t$95$3), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(0.5 * Pi), $MachinePrecision] - Pi), $MachinePrecision] + N[(t$95$2 * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \pi - 0.5 \cdot \pi\\
t_1 := t\_0 \cdot t\_0\\
t_2 := \cos^{-1} \left(\sqrt{\left(1 - x\right) \cdot 0.5}\right)\\
t_3 := {t\_2}^{2} \cdot 4\\
\frac{\frac{t\_1 \cdot t\_1 - t\_3 \cdot t\_3}{t\_1 + t\_3}}{\left(0.5 \cdot \pi - \pi\right) + t\_2 \cdot -2}
\end{array}
Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
lift--.f64N/A
lift-+.f64N/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (acos (sqrt (* (- 1.0 x) 0.5)))))
(*
(-
(* (* 0.125 (* (* PI PI) PI)) (* 0.5 PI))
(* 16.0 (pow t_0 4.0)))
(/
-1.0
(*
(- (* 4.0 (pow t_0 2.0)) (* (* -0.5 PI) (* 0.5 PI)))
(- (* 2.0 t_0) (* -0.5 PI)))))))double code(double x) {
double t_0 = acos(sqrt(((1.0 - x) * 0.5)));
return (((0.125 * ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI))) * (0.5 * ((double) M_PI))) - (16.0 * pow(t_0, 4.0))) * (-1.0 / (((4.0 * pow(t_0, 2.0)) - ((-0.5 * ((double) M_PI)) * (0.5 * ((double) M_PI)))) * ((2.0 * t_0) - (-0.5 * ((double) M_PI)))));
}
public static double code(double x) {
double t_0 = Math.acos(Math.sqrt(((1.0 - x) * 0.5)));
return (((0.125 * ((Math.PI * Math.PI) * Math.PI)) * (0.5 * Math.PI)) - (16.0 * Math.pow(t_0, 4.0))) * (-1.0 / (((4.0 * Math.pow(t_0, 2.0)) - ((-0.5 * Math.PI) * (0.5 * Math.PI))) * ((2.0 * t_0) - (-0.5 * Math.PI))));
}
def code(x): t_0 = math.acos(math.sqrt(((1.0 - x) * 0.5))) return (((0.125 * ((math.pi * math.pi) * math.pi)) * (0.5 * math.pi)) - (16.0 * math.pow(t_0, 4.0))) * (-1.0 / (((4.0 * math.pow(t_0, 2.0)) - ((-0.5 * math.pi) * (0.5 * math.pi))) * ((2.0 * t_0) - (-0.5 * math.pi))))
function code(x) t_0 = acos(sqrt(Float64(Float64(1.0 - x) * 0.5))) return Float64(Float64(Float64(Float64(0.125 * Float64(Float64(pi * pi) * pi)) * Float64(0.5 * pi)) - Float64(16.0 * (t_0 ^ 4.0))) * Float64(-1.0 / Float64(Float64(Float64(4.0 * (t_0 ^ 2.0)) - Float64(Float64(-0.5 * pi) * Float64(0.5 * pi))) * Float64(Float64(2.0 * t_0) - Float64(-0.5 * pi))))) end
function tmp = code(x) t_0 = acos(sqrt(((1.0 - x) * 0.5))); tmp = (((0.125 * ((pi * pi) * pi)) * (0.5 * pi)) - (16.0 * (t_0 ^ 4.0))) * (-1.0 / (((4.0 * (t_0 ^ 2.0)) - ((-0.5 * pi) * (0.5 * pi))) * ((2.0 * t_0) - (-0.5 * pi)))); end
code[x_] := Block[{t$95$0 = N[ArcCos[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(0.125 * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - N[(16.0 * N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(N[(N[(4.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-0.5 * Pi), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * t$95$0), $MachinePrecision] - N[(-0.5 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos^{-1} \left(\sqrt{\left(1 - x\right) \cdot 0.5}\right)\\
\left(\left(0.125 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right) \cdot \left(0.5 \cdot \pi\right) - 16 \cdot {t\_0}^{4}\right) \cdot \frac{-1}{\left(4 \cdot {t\_0}^{2} - \left(-0.5 \cdot \pi\right) \cdot \left(0.5 \cdot \pi\right)\right) \cdot \left(2 \cdot t\_0 - -0.5 \cdot \pi\right)}
\end{array}
Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
lift--.f64N/A
lift-+.f64N/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
Applied rewrites8.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (acos (sqrt (* (- 1.0 x) 0.5)))))
(/
(-
(* (* 0.125 (* (* PI PI) PI)) (* 0.5 PI))
(* 16.0 (pow t_0 4.0)))
(*
(- (* -2.0 t_0) (* 0.5 PI))
(- (* 4.0 (pow t_0 2.0)) (* (* -0.5 PI) (* 0.5 PI)))))))double code(double x) {
double t_0 = acos(sqrt(((1.0 - x) * 0.5)));
return (((0.125 * ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI))) * (0.5 * ((double) M_PI))) - (16.0 * pow(t_0, 4.0))) / (((-2.0 * t_0) - (0.5 * ((double) M_PI))) * ((4.0 * pow(t_0, 2.0)) - ((-0.5 * ((double) M_PI)) * (0.5 * ((double) M_PI)))));
}
public static double code(double x) {
double t_0 = Math.acos(Math.sqrt(((1.0 - x) * 0.5)));
return (((0.125 * ((Math.PI * Math.PI) * Math.PI)) * (0.5 * Math.PI)) - (16.0 * Math.pow(t_0, 4.0))) / (((-2.0 * t_0) - (0.5 * Math.PI)) * ((4.0 * Math.pow(t_0, 2.0)) - ((-0.5 * Math.PI) * (0.5 * Math.PI))));
}
def code(x): t_0 = math.acos(math.sqrt(((1.0 - x) * 0.5))) return (((0.125 * ((math.pi * math.pi) * math.pi)) * (0.5 * math.pi)) - (16.0 * math.pow(t_0, 4.0))) / (((-2.0 * t_0) - (0.5 * math.pi)) * ((4.0 * math.pow(t_0, 2.0)) - ((-0.5 * math.pi) * (0.5 * math.pi))))
function code(x) t_0 = acos(sqrt(Float64(Float64(1.0 - x) * 0.5))) return Float64(Float64(Float64(Float64(0.125 * Float64(Float64(pi * pi) * pi)) * Float64(0.5 * pi)) - Float64(16.0 * (t_0 ^ 4.0))) / Float64(Float64(Float64(-2.0 * t_0) - Float64(0.5 * pi)) * Float64(Float64(4.0 * (t_0 ^ 2.0)) - Float64(Float64(-0.5 * pi) * Float64(0.5 * pi))))) end
function tmp = code(x) t_0 = acos(sqrt(((1.0 - x) * 0.5))); tmp = (((0.125 * ((pi * pi) * pi)) * (0.5 * pi)) - (16.0 * (t_0 ^ 4.0))) / (((-2.0 * t_0) - (0.5 * pi)) * ((4.0 * (t_0 ^ 2.0)) - ((-0.5 * pi) * (0.5 * pi)))); end
code[x_] := Block[{t$95$0 = N[ArcCos[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(0.125 * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] - N[(16.0 * N[Power[t$95$0, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(-2.0 * t$95$0), $MachinePrecision] - N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision] * N[(N[(4.0 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-0.5 * Pi), $MachinePrecision] * N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos^{-1} \left(\sqrt{\left(1 - x\right) \cdot 0.5}\right)\\
\frac{\left(0.125 \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right) \cdot \left(0.5 \cdot \pi\right) - 16 \cdot {t\_0}^{4}}{\left(-2 \cdot t\_0 - 0.5 \cdot \pi\right) \cdot \left(4 \cdot {t\_0}^{2} - \left(-0.5 \cdot \pi\right) \cdot \left(0.5 \cdot \pi\right)\right)}
\end{array}
Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
lift--.f64N/A
lift-+.f64N/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites8.5%
Applied rewrites8.5%
(FPCore (x) :precision binary64 (- (- 1.5707963267948966 PI) (* -2.0 (acos (sqrt (* (- 1.0 x) 0.5))))))
double code(double x) {
return (1.5707963267948966 - ((double) M_PI)) - (-2.0 * acos(sqrt(((1.0 - x) * 0.5))));
}
public static double code(double x) {
return (1.5707963267948966 - Math.PI) - (-2.0 * Math.acos(Math.sqrt(((1.0 - x) * 0.5))));
}
def code(x): return (1.5707963267948966 - math.pi) - (-2.0 * math.acos(math.sqrt(((1.0 - x) * 0.5))))
function code(x) return Float64(Float64(1.5707963267948966 - pi) - Float64(-2.0 * acos(sqrt(Float64(Float64(1.0 - x) * 0.5))))) end
function tmp = code(x) tmp = (1.5707963267948966 - pi) - (-2.0 * acos(sqrt(((1.0 - x) * 0.5)))); end
code[x_] := N[(N[(1.5707963267948966 - Pi), $MachinePrecision] - N[(-2.0 * N[ArcCos[N[Sqrt[N[(N[(1.0 - x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(1.5707963267948966 - \pi\right) - -2 \cdot \cos^{-1} \left(\sqrt{\left(1 - x\right) \cdot 0.5}\right)
Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
Evaluated real constant8.5%
lift--.f64N/A
lift-+.f64N/A
associate--r+N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-neg-outN/A
metadata-evalN/A
lift-*.f64N/A
Applied rewrites8.5%
(FPCore (x) :precision binary64 (if (<= x -1.15e-160) (- 1.5707963267948966 (* 2.0 (asin (sqrt (* 0.5 (- 1.0 x)))))) (- (- 1.5707963267948966 (* (acos (sqrt 0.5)) -2.0)) PI)))
double code(double x) {
double tmp;
if (x <= -1.15e-160) {
tmp = 1.5707963267948966 - (2.0 * asin(sqrt((0.5 * (1.0 - x)))));
} else {
tmp = (1.5707963267948966 - (acos(sqrt(0.5)) * -2.0)) - ((double) M_PI);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= -1.15e-160) {
tmp = 1.5707963267948966 - (2.0 * Math.asin(Math.sqrt((0.5 * (1.0 - x)))));
} else {
tmp = (1.5707963267948966 - (Math.acos(Math.sqrt(0.5)) * -2.0)) - Math.PI;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.15e-160: tmp = 1.5707963267948966 - (2.0 * math.asin(math.sqrt((0.5 * (1.0 - x))))) else: tmp = (1.5707963267948966 - (math.acos(math.sqrt(0.5)) * -2.0)) - math.pi return tmp
function code(x) tmp = 0.0 if (x <= -1.15e-160) tmp = Float64(1.5707963267948966 - Float64(2.0 * asin(sqrt(Float64(0.5 * Float64(1.0 - x)))))); else tmp = Float64(Float64(1.5707963267948966 - Float64(acos(sqrt(0.5)) * -2.0)) - pi); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.15e-160) tmp = 1.5707963267948966 - (2.0 * asin(sqrt((0.5 * (1.0 - x))))); else tmp = (1.5707963267948966 - (acos(sqrt(0.5)) * -2.0)) - pi; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.15e-160], N[(1.5707963267948966 - N[(2.0 * N[ArcSin[N[Sqrt[N[(0.5 * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.5707963267948966 - N[(N[ArcCos[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] - Pi), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-160}:\\
\;\;\;\;1.5707963267948966 - 2 \cdot \sin^{-1} \left(\sqrt{0.5 \cdot \left(1 - x\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1.5707963267948966 - \cos^{-1} \left(\sqrt{0.5}\right) \cdot -2\right) - \pi\\
\end{array}
if x < -1.1499999999999999e-160Initial program 7.0%
Taylor expanded in x around 0
Applied rewrites4.1%
Evaluated real constant4.1%
Taylor expanded in x around 0
lower-asin.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f647.0%
Applied rewrites7.0%
if -1.1499999999999999e-160 < x Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
Evaluated real constant8.5%
Taylor expanded in x around 0
Applied rewrites5.4%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f645.4%
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f645.4%
Applied rewrites5.4%
(FPCore (x) :precision binary64 (- (- 1.5707963267948966 (* (acos (sqrt 0.5)) -2.0)) PI))
double code(double x) {
return (1.5707963267948966 - (acos(sqrt(0.5)) * -2.0)) - ((double) M_PI);
}
public static double code(double x) {
return (1.5707963267948966 - (Math.acos(Math.sqrt(0.5)) * -2.0)) - Math.PI;
}
def code(x): return (1.5707963267948966 - (math.acos(math.sqrt(0.5)) * -2.0)) - math.pi
function code(x) return Float64(Float64(1.5707963267948966 - Float64(acos(sqrt(0.5)) * -2.0)) - pi) end
function tmp = code(x) tmp = (1.5707963267948966 - (acos(sqrt(0.5)) * -2.0)) - pi; end
code[x_] := N[(N[(1.5707963267948966 - N[(N[ArcCos[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] - Pi), $MachinePrecision]
\left(1.5707963267948966 - \cos^{-1} \left(\sqrt{0.5}\right) \cdot -2\right) - \pi
Initial program 7.0%
lift-*.f64N/A
lift-asin.f64N/A
asin-acosN/A
lift-PI.f64N/A
lift-/.f64N/A
sub-flip-reverseN/A
acos-asinN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-asin.f64N/A
sub-negate-revN/A
distribute-rgt-inN/A
Applied rewrites8.5%
Evaluated real constant8.5%
Taylor expanded in x around 0
Applied rewrites5.4%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
lower--.f645.4%
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f645.4%
Applied rewrites5.4%
(FPCore (x) :precision binary64 (- 1.5707963267948966 (* 2.0 (asin (sqrt 0.5)))))
double code(double x) {
return 1.5707963267948966 - (2.0 * asin(sqrt(0.5)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 1.5707963267948966d0 - (2.0d0 * asin(sqrt(0.5d0)))
end function
public static double code(double x) {
return 1.5707963267948966 - (2.0 * Math.asin(Math.sqrt(0.5)));
}
def code(x): return 1.5707963267948966 - (2.0 * math.asin(math.sqrt(0.5)))
function code(x) return Float64(1.5707963267948966 - Float64(2.0 * asin(sqrt(0.5)))) end
function tmp = code(x) tmp = 1.5707963267948966 - (2.0 * asin(sqrt(0.5))); end
code[x_] := N[(1.5707963267948966 - N[(2.0 * N[ArcSin[N[Sqrt[0.5], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1.5707963267948966 - 2 \cdot \sin^{-1} \left(\sqrt{0.5}\right)
Initial program 7.0%
Taylor expanded in x around 0
Applied rewrites4.1%
Evaluated real constant4.1%
herbie shell --seed 2025258
(FPCore (x)
:name "Ian Simplification"
:precision binary64
(- (/ PI 2.0) (* 2.0 (asin (sqrt (/ (- 1.0 x) 2.0))))))