
(FPCore (x) :precision binary64 (acos (- 1 x)))
double code(double x) {
return acos((1.0 - x));
}
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 = acos((1.0d0 - x))
end function
public static double code(double x) {
return Math.acos((1.0 - x));
}
def code(x): return math.acos((1.0 - x))
function code(x) return acos(Float64(1.0 - x)) end
function tmp = code(x) tmp = acos((1.0 - x)); end
code[x_] := N[ArcCos[N[(1 - x), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(1 - x\right)
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (acos (- 1 x)))
double code(double x) {
return acos((1.0 - x));
}
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 = acos((1.0d0 - x))
end function
public static double code(double x) {
return Math.acos((1.0 - x));
}
def code(x): return math.acos((1.0 - x))
function code(x) return acos(Float64(1.0 - x)) end
function tmp = code(x) tmp = acos((1.0 - x)); end
code[x_] := N[ArcCos[N[(1 - x), $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(1 - x\right)
(FPCore (x)
:precision binary64
(let* ((t_0 (* 7/8 (* (* PI PI) PI)))
(t_1 (* 7/4 (* PI PI)))
(t_2 (- (asin (- x 1)) (/ t_0 t_1)))
(t_3 (/ (* t_0 t_0) (* (* t_1 t_1) t_2)))
(t_4 (/ (pow (asin (- 1 x)) 2) t_2)))
(/ (- (* t_4 t_4) (* t_3 t_3)) (+ t_4 t_3))))double code(double x) {
double t_0 = 0.875 * ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI));
double t_1 = 1.75 * (((double) M_PI) * ((double) M_PI));
double t_2 = asin((x - 1.0)) - (t_0 / t_1);
double t_3 = (t_0 * t_0) / ((t_1 * t_1) * t_2);
double t_4 = pow(asin((1.0 - x)), 2.0) / t_2;
return ((t_4 * t_4) - (t_3 * t_3)) / (t_4 + t_3);
}
public static double code(double x) {
double t_0 = 0.875 * ((Math.PI * Math.PI) * Math.PI);
double t_1 = 1.75 * (Math.PI * Math.PI);
double t_2 = Math.asin((x - 1.0)) - (t_0 / t_1);
double t_3 = (t_0 * t_0) / ((t_1 * t_1) * t_2);
double t_4 = Math.pow(Math.asin((1.0 - x)), 2.0) / t_2;
return ((t_4 * t_4) - (t_3 * t_3)) / (t_4 + t_3);
}
def code(x): t_0 = 0.875 * ((math.pi * math.pi) * math.pi) t_1 = 1.75 * (math.pi * math.pi) t_2 = math.asin((x - 1.0)) - (t_0 / t_1) t_3 = (t_0 * t_0) / ((t_1 * t_1) * t_2) t_4 = math.pow(math.asin((1.0 - x)), 2.0) / t_2 return ((t_4 * t_4) - (t_3 * t_3)) / (t_4 + t_3)
function code(x) t_0 = Float64(0.875 * Float64(Float64(pi * pi) * pi)) t_1 = Float64(1.75 * Float64(pi * pi)) t_2 = Float64(asin(Float64(x - 1.0)) - Float64(t_0 / t_1)) t_3 = Float64(Float64(t_0 * t_0) / Float64(Float64(t_1 * t_1) * t_2)) t_4 = Float64((asin(Float64(1.0 - x)) ^ 2.0) / t_2) return Float64(Float64(Float64(t_4 * t_4) - Float64(t_3 * t_3)) / Float64(t_4 + t_3)) end
function tmp = code(x) t_0 = 0.875 * ((pi * pi) * pi); t_1 = 1.75 * (pi * pi); t_2 = asin((x - 1.0)) - (t_0 / t_1); t_3 = (t_0 * t_0) / ((t_1 * t_1) * t_2); t_4 = (asin((1.0 - x)) ^ 2.0) / t_2; tmp = ((t_4 * t_4) - (t_3 * t_3)) / (t_4 + t_3); end
code[x_] := Block[{t$95$0 = N[(7/8 * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(7/4 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[ArcSin[N[(x - 1), $MachinePrecision]], $MachinePrecision] - N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] / N[(N[(t$95$1 * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[N[ArcSin[N[(1 - x), $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision] / t$95$2), $MachinePrecision]}, N[(N[(N[(t$95$4 * t$95$4), $MachinePrecision] - N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] / N[(t$95$4 + t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{7}{8} \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\\
t_1 := \frac{7}{4} \cdot \left(\pi \cdot \pi\right)\\
t_2 := \sin^{-1} \left(x - 1\right) - \frac{t\_0}{t\_1}\\
t_3 := \frac{t\_0 \cdot t\_0}{\left(t\_1 \cdot t\_1\right) \cdot t\_2}\\
t_4 := \frac{{\sin^{-1} \left(1 - x\right)}^{2}}{t\_2}\\
\frac{t\_4 \cdot t\_4 - t\_3 \cdot t\_3}{t\_4 + t\_3}
\end{array}
Initial program 6.9%
lift-acos.f64N/A
acos-asinN/A
sub-flipN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-PI.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
lower-asin.f64N/A
lower--.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
Applied rewrites6.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift-PI.f64N/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites10.4%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
Applied rewrites10.4%
Applied rewrites10.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* PI PI) PI))
(t_1 (* 7/8 t_0))
(t_2 (* 7/4 (* PI PI))))
(/
(/ (- (* (pow (asin (- 1 x)) 2) t_2) (* (/ t_1 t_2) t_1)) t_2)
(-
(asin (- x 1))
(/ (- t_0 (* 1/8 t_0)) (+ (* (* PI PI) 3/4) (* PI PI)))))))double code(double x) {
double t_0 = (((double) M_PI) * ((double) M_PI)) * ((double) M_PI);
double t_1 = 0.875 * t_0;
double t_2 = 1.75 * (((double) M_PI) * ((double) M_PI));
return (((pow(asin((1.0 - x)), 2.0) * t_2) - ((t_1 / t_2) * t_1)) / t_2) / (asin((x - 1.0)) - ((t_0 - (0.125 * t_0)) / (((((double) M_PI) * ((double) M_PI)) * 0.75) + (((double) M_PI) * ((double) M_PI)))));
}
public static double code(double x) {
double t_0 = (Math.PI * Math.PI) * Math.PI;
double t_1 = 0.875 * t_0;
double t_2 = 1.75 * (Math.PI * Math.PI);
return (((Math.pow(Math.asin((1.0 - x)), 2.0) * t_2) - ((t_1 / t_2) * t_1)) / t_2) / (Math.asin((x - 1.0)) - ((t_0 - (0.125 * t_0)) / (((Math.PI * Math.PI) * 0.75) + (Math.PI * Math.PI))));
}
def code(x): t_0 = (math.pi * math.pi) * math.pi t_1 = 0.875 * t_0 t_2 = 1.75 * (math.pi * math.pi) return (((math.pow(math.asin((1.0 - x)), 2.0) * t_2) - ((t_1 / t_2) * t_1)) / t_2) / (math.asin((x - 1.0)) - ((t_0 - (0.125 * t_0)) / (((math.pi * math.pi) * 0.75) + (math.pi * math.pi))))
function code(x) t_0 = Float64(Float64(pi * pi) * pi) t_1 = Float64(0.875 * t_0) t_2 = Float64(1.75 * Float64(pi * pi)) return Float64(Float64(Float64(Float64((asin(Float64(1.0 - x)) ^ 2.0) * t_2) - Float64(Float64(t_1 / t_2) * t_1)) / t_2) / Float64(asin(Float64(x - 1.0)) - Float64(Float64(t_0 - Float64(0.125 * t_0)) / Float64(Float64(Float64(pi * pi) * 0.75) + Float64(pi * pi))))) end
function tmp = code(x) t_0 = (pi * pi) * pi; t_1 = 0.875 * t_0; t_2 = 1.75 * (pi * pi); tmp = ((((asin((1.0 - x)) ^ 2.0) * t_2) - ((t_1 / t_2) * t_1)) / t_2) / (asin((x - 1.0)) - ((t_0 - (0.125 * t_0)) / (((pi * pi) * 0.75) + (pi * pi)))); end
code[x_] := Block[{t$95$0 = N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]}, Block[{t$95$1 = N[(7/8 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(7/4 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(N[Power[N[ArcSin[N[(1 - x), $MachinePrecision]], $MachinePrecision], 2], $MachinePrecision] * t$95$2), $MachinePrecision] - N[(N[(t$95$1 / t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] / N[(N[ArcSin[N[(x - 1), $MachinePrecision]], $MachinePrecision] - N[(N[(t$95$0 - N[(1/8 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(Pi * Pi), $MachinePrecision] * 3/4), $MachinePrecision] + N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\pi \cdot \pi\right) \cdot \pi\\
t_1 := \frac{7}{8} \cdot t\_0\\
t_2 := \frac{7}{4} \cdot \left(\pi \cdot \pi\right)\\
\frac{\frac{{\sin^{-1} \left(1 - x\right)}^{2} \cdot t\_2 - \frac{t\_1}{t\_2} \cdot t\_1}{t\_2}}{\sin^{-1} \left(x - 1\right) - \frac{t\_0 - \frac{1}{8} \cdot t\_0}{\left(\pi \cdot \pi\right) \cdot \frac{3}{4} + \pi \cdot \pi}}
\end{array}
Initial program 6.9%
lift-acos.f64N/A
acos-asinN/A
sub-flipN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-PI.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
lower-asin.f64N/A
lower--.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
Applied rewrites6.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift-PI.f64N/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites10.4%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
Applied rewrites10.4%
lift--.f64N/A
lift-*.f64N/A
Applied rewrites10.4%
(FPCore (x)
:precision binary64
(let* ((t_0 (asin (- x 1)))
(t_1 (/ (* 7/8 (* (* PI PI) PI)) (* 7/4 (* PI PI)))))
(/ (- (* t_0 t_0) (* t_1 t_1)) (- t_0 t_1))))double code(double x) {
double t_0 = asin((x - 1.0));
double t_1 = (0.875 * ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI))) / (1.75 * (((double) M_PI) * ((double) M_PI)));
return ((t_0 * t_0) - (t_1 * t_1)) / (t_0 - t_1);
}
public static double code(double x) {
double t_0 = Math.asin((x - 1.0));
double t_1 = (0.875 * ((Math.PI * Math.PI) * Math.PI)) / (1.75 * (Math.PI * Math.PI));
return ((t_0 * t_0) - (t_1 * t_1)) / (t_0 - t_1);
}
def code(x): t_0 = math.asin((x - 1.0)) t_1 = (0.875 * ((math.pi * math.pi) * math.pi)) / (1.75 * (math.pi * math.pi)) return ((t_0 * t_0) - (t_1 * t_1)) / (t_0 - t_1)
function code(x) t_0 = asin(Float64(x - 1.0)) t_1 = Float64(Float64(0.875 * Float64(Float64(pi * pi) * pi)) / Float64(1.75 * Float64(pi * pi))) return Float64(Float64(Float64(t_0 * t_0) - Float64(t_1 * t_1)) / Float64(t_0 - t_1)) end
function tmp = code(x) t_0 = asin((x - 1.0)); t_1 = (0.875 * ((pi * pi) * pi)) / (1.75 * (pi * pi)); tmp = ((t_0 * t_0) - (t_1 * t_1)) / (t_0 - t_1); end
code[x_] := Block[{t$95$0 = N[ArcSin[N[(x - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(7/8 * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] / N[(7/4 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin^{-1} \left(x - 1\right)\\
t_1 := \frac{\frac{7}{8} \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)}{\frac{7}{4} \cdot \left(\pi \cdot \pi\right)}\\
\frac{t\_0 \cdot t\_0 - t\_1 \cdot t\_1}{t\_0 - t\_1}
\end{array}
Initial program 6.9%
lift-acos.f64N/A
acos-asinN/A
sub-flipN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-PI.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
lower-asin.f64N/A
lower--.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
Applied rewrites6.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift-PI.f64N/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites10.4%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
Applied rewrites10.4%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval10.4%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft1-inN/A
lower-*.f64N/A
metadata-eval10.4%
Applied rewrites10.4%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval10.4%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft1-inN/A
lower-*.f64N/A
metadata-eval10.4%
Applied rewrites10.4%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval10.4%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft1-inN/A
lower-*.f64N/A
metadata-eval10.4%
Applied rewrites10.4%
(FPCore (x) :precision binary64 (let* ((t_0 (* 7/4 (* PI PI)))) (/ (+ (* t_0 (asin (- x 1))) (* 7/8 (* (* PI PI) PI))) t_0)))
double code(double x) {
double t_0 = 1.75 * (((double) M_PI) * ((double) M_PI));
return ((t_0 * asin((x - 1.0))) + (0.875 * ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI)))) / t_0;
}
public static double code(double x) {
double t_0 = 1.75 * (Math.PI * Math.PI);
return ((t_0 * Math.asin((x - 1.0))) + (0.875 * ((Math.PI * Math.PI) * Math.PI))) / t_0;
}
def code(x): t_0 = 1.75 * (math.pi * math.pi) return ((t_0 * math.asin((x - 1.0))) + (0.875 * ((math.pi * math.pi) * math.pi))) / t_0
function code(x) t_0 = Float64(1.75 * Float64(pi * pi)) return Float64(Float64(Float64(t_0 * asin(Float64(x - 1.0))) + Float64(0.875 * Float64(Float64(pi * pi) * pi))) / t_0) end
function tmp = code(x) t_0 = 1.75 * (pi * pi); tmp = ((t_0 * asin((x - 1.0))) + (0.875 * ((pi * pi) * pi))) / t_0; end
code[x_] := Block[{t$95$0 = N[(7/4 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 * N[ArcSin[N[(x - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(7/8 * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{7}{4} \cdot \left(\pi \cdot \pi\right)\\
\frac{t\_0 \cdot \sin^{-1} \left(x - 1\right) + \frac{7}{8} \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)}{t\_0}
\end{array}
Initial program 6.9%
lift-acos.f64N/A
acos-asinN/A
sub-flipN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-PI.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
lower-asin.f64N/A
lower--.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
Applied rewrites6.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift-PI.f64N/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites10.4%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
Applied rewrites10.4%
Applied rewrites10.4%
(FPCore (x) :precision binary64 (+ (/ (* 7/8 (* (* PI PI) PI)) (* 7/4 (* PI PI))) (asin (- x 1))))
double code(double x) {
return ((0.875 * ((((double) M_PI) * ((double) M_PI)) * ((double) M_PI))) / (1.75 * (((double) M_PI) * ((double) M_PI)))) + asin((x - 1.0));
}
public static double code(double x) {
return ((0.875 * ((Math.PI * Math.PI) * Math.PI)) / (1.75 * (Math.PI * Math.PI))) + Math.asin((x - 1.0));
}
def code(x): return ((0.875 * ((math.pi * math.pi) * math.pi)) / (1.75 * (math.pi * math.pi))) + math.asin((x - 1.0))
function code(x) return Float64(Float64(Float64(0.875 * Float64(Float64(pi * pi) * pi)) / Float64(1.75 * Float64(pi * pi))) + asin(Float64(x - 1.0))) end
function tmp = code(x) tmp = ((0.875 * ((pi * pi) * pi)) / (1.75 * (pi * pi))) + asin((x - 1.0)); end
code[x_] := N[(N[(N[(7/8 * N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] / N[(7/4 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[ArcSin[N[(x - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{\frac{7}{8} \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)}{\frac{7}{4} \cdot \left(\pi \cdot \pi\right)} + \sin^{-1} \left(x - 1\right)
Initial program 6.9%
lift-acos.f64N/A
acos-asinN/A
sub-flipN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-PI.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
lower-asin.f64N/A
lower--.f64N/A
asin-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
Applied rewrites6.9%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-out--N/A
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift-PI.f64N/A
flip3--N/A
lower-unsound-/.f64N/A
Applied rewrites10.4%
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
Applied rewrites10.4%
Applied rewrites10.4%
(FPCore (x) :precision binary64 (if (<= x 8924260225606735/162259276829213363391578010288128) (acos 0) (/ (/ (* (* -3 (acos (- 1 x))) PI) -3) PI)))
double code(double x) {
double tmp;
if (x <= 5.5e-17) {
tmp = acos(0.0);
} else {
tmp = (((-3.0 * acos((1.0 - x))) * ((double) M_PI)) / -3.0) / ((double) M_PI);
}
return tmp;
}
public static double code(double x) {
double tmp;
if (x <= 5.5e-17) {
tmp = Math.acos(0.0);
} else {
tmp = (((-3.0 * Math.acos((1.0 - x))) * Math.PI) / -3.0) / Math.PI;
}
return tmp;
}
def code(x): tmp = 0 if x <= 5.5e-17: tmp = math.acos(0.0) else: tmp = (((-3.0 * math.acos((1.0 - x))) * math.pi) / -3.0) / math.pi return tmp
function code(x) tmp = 0.0 if (x <= 5.5e-17) tmp = acos(0.0); else tmp = Float64(Float64(Float64(Float64(-3.0 * acos(Float64(1.0 - x))) * pi) / -3.0) / pi); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5.5e-17) tmp = acos(0.0); else tmp = (((-3.0 * acos((1.0 - x))) * pi) / -3.0) / pi; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8924260225606735/162259276829213363391578010288128], N[ArcCos[0], $MachinePrecision], N[(N[(N[(N[(-3 * N[ArcCos[N[(1 - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] / -3), $MachinePrecision] / Pi), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{8924260225606735}{162259276829213363391578010288128}:\\
\;\;\;\;\cos^{-1} 0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(-3 \cdot \cos^{-1} \left(1 - x\right)\right) \cdot \pi}{-3}}{\pi}\\
\end{array}
if x < 5.5e-17Initial program 6.9%
Taylor expanded in x around 0
Applied rewrites3.8%
Taylor expanded in undef-var around zero
Applied rewrites6.9%
if 5.5e-17 < x Initial program 6.9%
lift-acos.f64N/A
lift--.f64N/A
sub-negate-revN/A
acos-negN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
lower-acos.f64N/A
lower--.f64N/A
lower-PI.f64N/A
lower-PI.f646.9%
Applied rewrites6.9%
lift-acos.f64N/A
acos-asinN/A
lift-asin.f64N/A
lower--.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f646.9%
Applied rewrites6.9%
lift--.f64N/A
lift-/.f64N/A
metadata-evalN/A
frac-subN/A
lower-/.f64N/A
Applied rewrites6.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites6.9%
(FPCore (x) :precision binary64 (if (<= x 8924260225606735/162259276829213363391578010288128) (acos 0) (acos (- 1 x))))
double code(double x) {
double tmp;
if (x <= 5.5e-17) {
tmp = acos(0.0);
} else {
tmp = acos((1.0 - x));
}
return tmp;
}
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
real(8) :: tmp
if (x <= 5.5d-17) then
tmp = acos(0.0d0)
else
tmp = acos((1.0d0 - x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 5.5e-17) {
tmp = Math.acos(0.0);
} else {
tmp = Math.acos((1.0 - x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5.5e-17: tmp = math.acos(0.0) else: tmp = math.acos((1.0 - x)) return tmp
function code(x) tmp = 0.0 if (x <= 5.5e-17) tmp = acos(0.0); else tmp = acos(Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5.5e-17) tmp = acos(0.0); else tmp = acos((1.0 - x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8924260225606735/162259276829213363391578010288128], N[ArcCos[0], $MachinePrecision], N[ArcCos[N[(1 - x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{8924260225606735}{162259276829213363391578010288128}:\\
\;\;\;\;\cos^{-1} 0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(1 - x\right)\\
\end{array}
if x < 5.5e-17Initial program 6.9%
Taylor expanded in x around 0
Applied rewrites3.8%
Taylor expanded in undef-var around zero
Applied rewrites6.9%
if 5.5e-17 < x Initial program 6.9%
(FPCore (x) :precision binary64 (acos 0))
double code(double x) {
return acos(0.0);
}
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 = acos(0.0d0)
end function
public static double code(double x) {
return Math.acos(0.0);
}
def code(x): return math.acos(0.0)
function code(x) return acos(0.0) end
function tmp = code(x) tmp = acos(0.0); end
code[x_] := N[ArcCos[0], $MachinePrecision]
\cos^{-1} 0
Initial program 6.9%
Taylor expanded in x around 0
Applied rewrites3.8%
Taylor expanded in undef-var around zero
Applied rewrites6.9%
(FPCore (x) :precision binary64 (acos 1))
double code(double x) {
return acos(1.0);
}
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 = acos(1.0d0)
end function
public static double code(double x) {
return Math.acos(1.0);
}
def code(x): return math.acos(1.0)
function code(x) return acos(1.0) end
function tmp = code(x) tmp = acos(1.0); end
code[x_] := N[ArcCos[1], $MachinePrecision]
\cos^{-1} 1
Initial program 6.9%
Taylor expanded in x around 0
Applied rewrites3.8%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (x)
:name "bug323 (missed optimization)"
:precision binary64
:pre (and (<= 0 x) (<= x 1/2))
(acos (- 1 x)))