
(FPCore (x y z)
:precision binary64
(+
x
(/
(*
y
(+
(* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
0.279195317918525))
(+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
double code(double x, double y, double z) {
return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((y * ((((z * 0.0692910599291889d0) + 0.4917317610505968d0) * z) + 0.279195317918525d0)) / (((z + 6.012459259764103d0) * z) + 3.350343815022304d0))
end function
public static double code(double x, double y, double z) {
return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
def code(x, y, z): return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304))
function code(x, y, z) return Float64(x + Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304))) end
function tmp = code(x, y, z) tmp = x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304)); end
code[x_, y_, z_] := N[(x + N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z)
:precision binary64
(+
x
(/
(*
y
(+
(* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
0.279195317918525))
(+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
double code(double x, double y, double z) {
return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((y * ((((z * 0.0692910599291889d0) + 0.4917317610505968d0) * z) + 0.279195317918525d0)) / (((z + 6.012459259764103d0) * z) + 3.350343815022304d0))
end function
public static double code(double x, double y, double z) {
return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304));
}
def code(x, y, z): return x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304))
function code(x, y, z) return Float64(x + Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304))) end
function tmp = code(x, y, z) tmp = x + ((y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304)); end
code[x_, y_, z_] := N[(x + N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(/
(* (- (/ 0.005643327829101921 (* z z)) 0.004801250986110448) y)
(- (/ 0.07512208616047561 z) 0.0692910599291889))
x)))
(if (<= z -1.55e+63)
t_0
(if (<= z 270000000.0)
(fma
(fma (fma 0.0692910599291889 z 0.4917317610505968) z 0.279195317918525)
(/ y (fma (+ 6.012459259764103 z) z 3.350343815022304))
x)
t_0))))
double code(double x, double y, double z) {
double t_0 = ((((0.005643327829101921 / (z * z)) - 0.004801250986110448) * y) / ((0.07512208616047561 / z) - 0.0692910599291889)) + x;
double tmp;
if (z <= -1.55e+63) {
tmp = t_0;
} else if (z <= 270000000.0) {
tmp = fma(fma(fma(0.0692910599291889, z, 0.4917317610505968), z, 0.279195317918525), (y / fma((6.012459259764103 + z), z, 3.350343815022304)), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(Float64(0.005643327829101921 / Float64(z * z)) - 0.004801250986110448) * y) / Float64(Float64(0.07512208616047561 / z) - 0.0692910599291889)) + x) tmp = 0.0 if (z <= -1.55e+63) tmp = t_0; elseif (z <= 270000000.0) tmp = fma(fma(fma(0.0692910599291889, z, 0.4917317610505968), z, 0.279195317918525), Float64(y / fma(Float64(6.012459259764103 + z), z, 3.350343815022304)), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(N[(0.005643327829101921 / N[(z * z), $MachinePrecision]), $MachinePrecision] - 0.004801250986110448), $MachinePrecision] * y), $MachinePrecision] / N[(N[(0.07512208616047561 / z), $MachinePrecision] - 0.0692910599291889), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -1.55e+63], t$95$0, If[LessEqual[z, 270000000.0], N[(N[(N[(0.0692910599291889 * z + 0.4917317610505968), $MachinePrecision] * z + 0.279195317918525), $MachinePrecision] * N[(y / N[(N[(6.012459259764103 + z), $MachinePrecision] * z + 3.350343815022304), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left(\frac{0.005643327829101921}{z \cdot z} - 0.004801250986110448\right) \cdot y}{\frac{0.07512208616047561}{z} - 0.0692910599291889} + x\\
\mathbf{if}\;z \leq -1.55 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 270000000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0692910599291889, z, 0.4917317610505968\right), z, 0.279195317918525\right), \frac{y}{\mathsf{fma}\left(6.012459259764103 + z, z, 3.350343815022304\right)}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.55e63 or 2.7e8 < z Initial program 32.5%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval99.6
Applied rewrites99.6%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
lift-+.f64N/A
lift-/.f64N/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
frac-timesN/A
pow2N/A
lower-/.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
metadata-evalN/A
lower--.f64N/A
lift-/.f6499.4
Applied rewrites99.4%
Applied rewrites99.6%
if -1.55e63 < z < 2.7e8Initial program 98.8%
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f6498.8
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lower-fma.f64N/A
+-commutativeN/A
lower-+.f6498.8
Applied rewrites98.8%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lower-/.f64N/A
lift-fma.f64N/A
lift-+.f6499.6
Applied rewrites99.6%
(FPCore (x y z)
:precision binary64
(if (<= z -50000.0)
(+ (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) x)
(if (<= z 7e-20)
(fma (fma -0.00277777777751721 z 0.08333333333333323) y x)
(+
(/
(* (- (/ 0.005643327829101921 (* z z)) 0.004801250986110448) y)
(- (/ 0.07512208616047561 z) 0.0692910599291889))
x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -50000.0) {
tmp = (((0.07512208616047561 / z) + 0.0692910599291889) * y) + x;
} else if (z <= 7e-20) {
tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x);
} else {
tmp = ((((0.005643327829101921 / (z * z)) - 0.004801250986110448) * y) / ((0.07512208616047561 / z) - 0.0692910599291889)) + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -50000.0) tmp = Float64(Float64(Float64(Float64(0.07512208616047561 / z) + 0.0692910599291889) * y) + x); elseif (z <= 7e-20) tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x); else tmp = Float64(Float64(Float64(Float64(Float64(0.005643327829101921 / Float64(z * z)) - 0.004801250986110448) * y) / Float64(Float64(0.07512208616047561 / z) - 0.0692910599291889)) + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -50000.0], N[(N[(N[(N[(0.07512208616047561 / z), $MachinePrecision] + 0.0692910599291889), $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 7e-20], N[(N[(-0.00277777777751721 * z + 0.08333333333333323), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(N[(N[(0.005643327829101921 / N[(z * z), $MachinePrecision]), $MachinePrecision] - 0.004801250986110448), $MachinePrecision] * y), $MachinePrecision] / N[(N[(0.07512208616047561 / z), $MachinePrecision] - 0.0692910599291889), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50000:\\
\;\;\;\;\left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.00277777777751721, z, 0.08333333333333323\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{0.005643327829101921}{z \cdot z} - 0.004801250986110448\right) \cdot y}{\frac{0.07512208616047561}{z} - 0.0692910599291889} + x\\
\end{array}
\end{array}
if z < -5e4Initial program 38.5%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval99.5
Applied rewrites99.5%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.5
Applied rewrites99.5%
if -5e4 < z < 7.00000000000000007e-20Initial program 99.7%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval30.1
Applied rewrites30.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6430.1
Applied rewrites30.1%
Taylor expanded in z around inf
Applied rewrites60.3%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
if 7.00000000000000007e-20 < z Initial program 42.9%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval96.7
Applied rewrites96.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6496.7
Applied rewrites96.7%
lift-+.f64N/A
lift-/.f64N/A
flip-+N/A
lower-/.f64N/A
lower--.f64N/A
frac-timesN/A
pow2N/A
lower-/.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
metadata-evalN/A
lower--.f64N/A
lift-/.f6496.5
Applied rewrites96.5%
Applied rewrites96.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* (+ (/ 0.07512208616047561 z) 0.0692910599291889) y) x)))
(if (<= z -50000.0)
t_0
(if (<= z 7e-20)
(fma (fma -0.00277777777751721 z 0.08333333333333323) y x)
t_0))))
double code(double x, double y, double z) {
double t_0 = (((0.07512208616047561 / z) + 0.0692910599291889) * y) + x;
double tmp;
if (z <= -50000.0) {
tmp = t_0;
} else if (z <= 7e-20) {
tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(0.07512208616047561 / z) + 0.0692910599291889) * y) + x) tmp = 0.0 if (z <= -50000.0) tmp = t_0; elseif (z <= 7e-20) tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(0.07512208616047561 / z), $MachinePrecision] + 0.0692910599291889), $MachinePrecision] * y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -50000.0], t$95$0, If[LessEqual[z, 7e-20], N[(N[(-0.00277777777751721 * z + 0.08333333333333323), $MachinePrecision] * y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{0.07512208616047561}{z} + 0.0692910599291889\right) \cdot y + x\\
\mathbf{if}\;z \leq -50000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.00277777777751721, z, 0.08333333333333323\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5e4 or 7.00000000000000007e-20 < z Initial program 40.8%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval98.1
Applied rewrites98.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.1
Applied rewrites98.0%
if -5e4 < z < 7.00000000000000007e-20Initial program 99.7%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval30.1
Applied rewrites30.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6430.1
Applied rewrites30.1%
Taylor expanded in z around inf
Applied rewrites60.3%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
(FPCore (x y z)
:precision binary64
(if (<= z -50000.0)
(fma 0.0692910599291889 y x)
(if (<= z 7e-20)
(fma (fma -0.00277777777751721 z 0.08333333333333323) y x)
(- x (* -0.0692910599291889 y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -50000.0) {
tmp = fma(0.0692910599291889, y, x);
} else if (z <= 7e-20) {
tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x);
} else {
tmp = x - (-0.0692910599291889 * y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -50000.0) tmp = fma(0.0692910599291889, y, x); elseif (z <= 7e-20) tmp = fma(fma(-0.00277777777751721, z, 0.08333333333333323), y, x); else tmp = Float64(x - Float64(-0.0692910599291889 * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -50000.0], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[z, 7e-20], N[(N[(-0.00277777777751721 * z + 0.08333333333333323), $MachinePrecision] * y + x), $MachinePrecision], N[(x - N[(-0.0692910599291889 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50000:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.00277777777751721, z, 0.08333333333333323\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - -0.0692910599291889 \cdot y\\
\end{array}
\end{array}
if z < -5e4Initial program 38.5%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
if -5e4 < z < 7.00000000000000007e-20Initial program 99.7%
Taylor expanded in z around inf
associate--l+N/A
lower-fma.f64N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
metadata-eval30.1
Applied rewrites30.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6430.1
Applied rewrites30.1%
Taylor expanded in z around inf
Applied rewrites60.3%
Taylor expanded in z around 0
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
if 7.00000000000000007e-20 < z Initial program 42.9%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6496.6
Applied rewrites96.6%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6496.6
Applied rewrites96.6%
(FPCore (x y z)
:precision binary64
(if (<= z -50000.0)
(fma 0.0692910599291889 y x)
(if (<= z 7e-20)
(fma 0.08333333333333323 y x)
(- x (* -0.0692910599291889 y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -50000.0) {
tmp = fma(0.0692910599291889, y, x);
} else if (z <= 7e-20) {
tmp = fma(0.08333333333333323, y, x);
} else {
tmp = x - (-0.0692910599291889 * y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -50000.0) tmp = fma(0.0692910599291889, y, x); elseif (z <= 7e-20) tmp = fma(0.08333333333333323, y, x); else tmp = Float64(x - Float64(-0.0692910599291889 * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -50000.0], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[z, 7e-20], N[(0.08333333333333323 * y + x), $MachinePrecision], N[(x - N[(-0.0692910599291889 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50000:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(0.08333333333333323, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - -0.0692910599291889 \cdot y\\
\end{array}
\end{array}
if z < -5e4Initial program 38.5%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6498.9
Applied rewrites98.9%
if -5e4 < z < 7.00000000000000007e-20Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6499.1
Applied rewrites99.1%
if 7.00000000000000007e-20 < z Initial program 42.9%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6496.6
Applied rewrites96.6%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f6496.6
Applied rewrites96.6%
(FPCore (x y z)
:precision binary64
(if (<= z -50000.0)
(fma 0.0692910599291889 y x)
(if (<= z 7e-20)
(fma 0.08333333333333323 y x)
(fma 0.0692910599291889 y x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -50000.0) {
tmp = fma(0.0692910599291889, y, x);
} else if (z <= 7e-20) {
tmp = fma(0.08333333333333323, y, x);
} else {
tmp = fma(0.0692910599291889, y, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -50000.0) tmp = fma(0.0692910599291889, y, x); elseif (z <= 7e-20) tmp = fma(0.08333333333333323, y, x); else tmp = fma(0.0692910599291889, y, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -50000.0], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[z, 7e-20], N[(0.08333333333333323 * y + x), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50000:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\
\mathbf{elif}\;z \leq 7 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(0.08333333333333323, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\
\end{array}
\end{array}
if z < -5e4 or 7.00000000000000007e-20 < z Initial program 40.8%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6497.7
Applied rewrites97.7%
if -5e4 < z < 7.00000000000000007e-20Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6499.1
Applied rewrites99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(/
(*
y
(+
(* (+ (* z 0.0692910599291889) 0.4917317610505968) z)
0.279195317918525))
(+ (* (+ z 6.012459259764103) z) 3.350343815022304))))
(if (<= t_0 (- INFINITY))
(fma 0.0692910599291889 y x)
(if (<= t_0 -2e+92)
(* 0.08333333333333323 y)
(fma 0.0692910599291889 y x)))))
double code(double x, double y, double z) {
double t_0 = (y * ((((z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / (((z + 6.012459259764103) * z) + 3.350343815022304);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(0.0692910599291889, y, x);
} else if (t_0 <= -2e+92) {
tmp = 0.08333333333333323 * y;
} else {
tmp = fma(0.0692910599291889, y, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(y * Float64(Float64(Float64(Float64(z * 0.0692910599291889) + 0.4917317610505968) * z) + 0.279195317918525)) / Float64(Float64(Float64(z + 6.012459259764103) * z) + 3.350343815022304)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = fma(0.0692910599291889, y, x); elseif (t_0 <= -2e+92) tmp = Float64(0.08333333333333323 * y); else tmp = fma(0.0692910599291889, y, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * N[(N[(N[(N[(z * 0.0692910599291889), $MachinePrecision] + 0.4917317610505968), $MachinePrecision] * z), $MachinePrecision] + 0.279195317918525), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(z + 6.012459259764103), $MachinePrecision] * z), $MachinePrecision] + 3.350343815022304), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(0.0692910599291889 * y + x), $MachinePrecision], If[LessEqual[t$95$0, -2e+92], N[(0.08333333333333323 * y), $MachinePrecision], N[(0.0692910599291889 * y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot \left(\left(z \cdot 0.0692910599291889 + 0.4917317610505968\right) \cdot z + 0.279195317918525\right)}{\left(z + 6.012459259764103\right) \cdot z + 3.350343815022304}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\
\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{+92}:\\
\;\;\;\;0.08333333333333323 \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.0692910599291889, y, x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z #s(literal 692910599291889/10000000000000000 binary64)) #s(literal 307332350656623/625000000000000 binary64)) z) #s(literal 11167812716741/40000000000000 binary64))) (+.f64 (*.f64 (+.f64 z #s(literal 6012459259764103/1000000000000000 binary64)) z) #s(literal 104698244219447/31250000000000 binary64))) < -inf.0 or -2.0000000000000001e92 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z #s(literal 692910599291889/10000000000000000 binary64)) #s(literal 307332350656623/625000000000000 binary64)) z) #s(literal 11167812716741/40000000000000 binary64))) (+.f64 (*.f64 (+.f64 z #s(literal 6012459259764103/1000000000000000 binary64)) z) #s(literal 104698244219447/31250000000000 binary64))) Initial program 66.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6483.6
Applied rewrites83.6%
if -inf.0 < (/.f64 (*.f64 y (+.f64 (*.f64 (+.f64 (*.f64 z #s(literal 692910599291889/10000000000000000 binary64)) #s(literal 307332350656623/625000000000000 binary64)) z) #s(literal 11167812716741/40000000000000 binary64))) (+.f64 (*.f64 (+.f64 z #s(literal 6012459259764103/1000000000000000 binary64)) z) #s(literal 104698244219447/31250000000000 binary64))) < -2.0000000000000001e92Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6489.3
Applied rewrites89.3%
Taylor expanded in x around 0
lower-*.f6472.1
Applied rewrites72.1%
(FPCore (x y z)
:precision binary64
(if (<= y -1.35e+104)
(* 0.08333333333333323 y)
(if (<= y 1.1e+121)
x
(if (<= y 1e+224) (* 0.08333333333333323 y) (* 0.0692910599291889 y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+104) {
tmp = 0.08333333333333323 * y;
} else if (y <= 1.1e+121) {
tmp = x;
} else if (y <= 1e+224) {
tmp = 0.08333333333333323 * y;
} else {
tmp = 0.0692910599291889 * y;
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.35d+104)) then
tmp = 0.08333333333333323d0 * y
else if (y <= 1.1d+121) then
tmp = x
else if (y <= 1d+224) then
tmp = 0.08333333333333323d0 * y
else
tmp = 0.0692910599291889d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+104) {
tmp = 0.08333333333333323 * y;
} else if (y <= 1.1e+121) {
tmp = x;
} else if (y <= 1e+224) {
tmp = 0.08333333333333323 * y;
} else {
tmp = 0.0692910599291889 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.35e+104: tmp = 0.08333333333333323 * y elif y <= 1.1e+121: tmp = x elif y <= 1e+224: tmp = 0.08333333333333323 * y else: tmp = 0.0692910599291889 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+104) tmp = Float64(0.08333333333333323 * y); elseif (y <= 1.1e+121) tmp = x; elseif (y <= 1e+224) tmp = Float64(0.08333333333333323 * y); else tmp = Float64(0.0692910599291889 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.35e+104) tmp = 0.08333333333333323 * y; elseif (y <= 1.1e+121) tmp = x; elseif (y <= 1e+224) tmp = 0.08333333333333323 * y; else tmp = 0.0692910599291889 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+104], N[(0.08333333333333323 * y), $MachinePrecision], If[LessEqual[y, 1.1e+121], x, If[LessEqual[y, 1e+224], N[(0.08333333333333323 * y), $MachinePrecision], N[(0.0692910599291889 * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+104}:\\
\;\;\;\;0.08333333333333323 \cdot y\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+121}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 10^{+224}:\\
\;\;\;\;0.08333333333333323 \cdot y\\
\mathbf{else}:\\
\;\;\;\;0.0692910599291889 \cdot y\\
\end{array}
\end{array}
if y < -1.34999999999999992e104 or 1.10000000000000001e121 < y < 9.9999999999999997e223Initial program 58.8%
Taylor expanded in z around 0
+-commutativeN/A
lower-fma.f6466.6
Applied rewrites66.6%
Taylor expanded in x around 0
lower-*.f6448.4
Applied rewrites48.4%
if -1.34999999999999992e104 < y < 1.10000000000000001e121Initial program 74.5%
Taylor expanded in x around inf
Applied rewrites66.6%
if 9.9999999999999997e223 < y Initial program 58.8%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6467.1
Applied rewrites67.1%
Taylor expanded in x around 0
lower-*.f6448.5
Applied rewrites48.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.35e+104) (* 0.0692910599291889 y) (if (<= y 6.6e+224) x (* 0.0692910599291889 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+104) {
tmp = 0.0692910599291889 * y;
} else if (y <= 6.6e+224) {
tmp = x;
} else {
tmp = 0.0692910599291889 * y;
}
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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.35d+104)) then
tmp = 0.0692910599291889d0 * y
else if (y <= 6.6d+224) then
tmp = x
else
tmp = 0.0692910599291889d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+104) {
tmp = 0.0692910599291889 * y;
} else if (y <= 6.6e+224) {
tmp = x;
} else {
tmp = 0.0692910599291889 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.35e+104: tmp = 0.0692910599291889 * y elif y <= 6.6e+224: tmp = x else: tmp = 0.0692910599291889 * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+104) tmp = Float64(0.0692910599291889 * y); elseif (y <= 6.6e+224) tmp = x; else tmp = Float64(0.0692910599291889 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.35e+104) tmp = 0.0692910599291889 * y; elseif (y <= 6.6e+224) tmp = x; else tmp = 0.0692910599291889 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+104], N[(0.0692910599291889 * y), $MachinePrecision], If[LessEqual[y, 6.6e+224], x, N[(0.0692910599291889 * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+104}:\\
\;\;\;\;0.0692910599291889 \cdot y\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+224}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0.0692910599291889 \cdot y\\
\end{array}
\end{array}
if y < -1.34999999999999992e104 or 6.59999999999999992e224 < y Initial program 57.8%
Taylor expanded in z around inf
+-commutativeN/A
lower-fma.f6464.4
Applied rewrites64.4%
Taylor expanded in x around 0
lower-*.f6451.4
Applied rewrites51.4%
if -1.34999999999999992e104 < y < 6.59999999999999992e224Initial program 72.9%
Taylor expanded in x around inf
Applied rewrites61.9%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return 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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 69.4%
Taylor expanded in x around inf
Applied rewrites51.2%
herbie shell --seed 2025119
(FPCore (x y z)
:name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, B"
:precision binary64
(+ x (/ (* y (+ (* (+ (* z 0.0692910599291889) 0.4917317610505968) z) 0.279195317918525)) (+ (* (+ z 6.012459259764103) z) 3.350343815022304))))