
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
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, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
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, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- z y) (- (- t z) -1.0)) a x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - y) / ((t - z) - -1.0)), a, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - y) / Float64(Float64(t - z) - -1.0)), a, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - y), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - y}{\left(t - z\right) - -1}, a, x\right)
\end{array}
Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
(FPCore (x y z t a) :precision binary64 (fma (/ a (- (- t z) -1.0)) (- z y) x))
double code(double x, double y, double z, double t, double a) {
return fma((a / ((t - z) - -1.0)), (z - y), x);
}
function code(x, y, z, t, a) return fma(Float64(a / Float64(Float64(t - z) - -1.0)), Float64(z - y), x) end
code[x_, y_, z_, t_, a_] := N[(N[(a / N[(N[(t - z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{a}{\left(t - z\right) - -1}, z - y, x\right)
\end{array}
Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6497.5
Applied rewrites97.5%
(FPCore (x y z t a)
:precision binary64
(if (<= t -3.2e+67)
(fma (/ (- z y) t) a x)
(if (<= t 1.1e+49)
(fma (/ (- z y) (- 1.0 z)) a x)
(fma (/ a t) (- z y) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -3.2e+67) {
tmp = fma(((z - y) / t), a, x);
} else if (t <= 1.1e+49) {
tmp = fma(((z - y) / (1.0 - z)), a, x);
} else {
tmp = fma((a / t), (z - y), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -3.2e+67) tmp = fma(Float64(Float64(z - y) / t), a, x); elseif (t <= 1.1e+49) tmp = fma(Float64(Float64(z - y) / Float64(1.0 - z)), a, x); else tmp = fma(Float64(a / t), Float64(z - y), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -3.2e+67], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, 1.1e+49], N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(a / t), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.2 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{elif}\;t \leq 1.1 \cdot 10^{+49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{t}, z - y, x\right)\\
\end{array}
\end{array}
if t < -3.19999999999999983e67Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f6453.2
Applied rewrites53.2%
if -3.19999999999999983e67 < t < 1.1e49Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in t around 0
lower--.f6480.4
Applied rewrites80.4%
if 1.1e49 < t Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6497.5
Applied rewrites97.5%
Taylor expanded in t around inf
lower-/.f6454.0
Applied rewrites54.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ z (- (- t z) -1.0)) a x)))
(if (<= z -0.88)
t_1
(if (<= z 2.15e+55) (- x (/ (* a y) (- t -1.0))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / ((t - z) - -1.0)), a, x);
double tmp;
if (z <= -0.88) {
tmp = t_1;
} else if (z <= 2.15e+55) {
tmp = x - ((a * y) / (t - -1.0));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(Float64(t - z) - -1.0)), a, x) tmp = 0.0 if (z <= -0.88) tmp = t_1; elseif (z <= 2.15e+55) tmp = Float64(x - Float64(Float64(a * y) / Float64(t - -1.0))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(N[(t - z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -0.88], t$95$1, If[LessEqual[z, 2.15e+55], N[(x - N[(N[(a * y), $MachinePrecision] / N[(t - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{\left(t - z\right) - -1}, a, x\right)\\
\mathbf{if}\;z \leq -0.88:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{+55}:\\
\;\;\;\;x - \frac{a \cdot y}{t - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -0.880000000000000004 or 2.1499999999999999e55 < z Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in y around 0
Applied rewrites75.1%
if -0.880000000000000004 < z < 2.1499999999999999e55Initial program 97.3%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6469.5
Applied rewrites69.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6469.5
Applied rewrites69.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.82e+107)
(- x a)
(if (<= z -3.3e+22)
(fma (/ (- z y) t) a x)
(if (<= z 6.2e+28) (- x (/ (* a y) (- t -1.0))) (- x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.82e+107) {
tmp = x - a;
} else if (z <= -3.3e+22) {
tmp = fma(((z - y) / t), a, x);
} else if (z <= 6.2e+28) {
tmp = x - ((a * y) / (t - -1.0));
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.82e+107) tmp = Float64(x - a); elseif (z <= -3.3e+22) tmp = fma(Float64(Float64(z - y) / t), a, x); elseif (z <= 6.2e+28) tmp = Float64(x - Float64(Float64(a * y) / Float64(t - -1.0))); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.82e+107], N[(x - a), $MachinePrecision], If[LessEqual[z, -3.3e+22], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[z, 6.2e+28], N[(x - N[(N[(a * y), $MachinePrecision] / N[(t - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.82 \cdot 10^{+107}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq -3.3 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+28}:\\
\;\;\;\;x - \frac{a \cdot y}{t - -1}\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -1.82e107 or 6.2000000000000001e28 < z Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
if -1.82e107 < z < -3.2999999999999998e22Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f6453.2
Applied rewrites53.2%
if -3.2999999999999998e22 < z < 6.2000000000000001e28Initial program 97.3%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6469.5
Applied rewrites69.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6469.5
Applied rewrites69.5%
(FPCore (x y z t a)
:precision binary64
(if (<= t -1.72e+59)
(fma (/ (- z y) t) a x)
(if (<= t -2.9e-160)
(- x (/ (* a y) (- 1.0 z)))
(if (<= t 1.72e+47) (- x a) (fma (/ a t) (- z y) x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.72e+59) {
tmp = fma(((z - y) / t), a, x);
} else if (t <= -2.9e-160) {
tmp = x - ((a * y) / (1.0 - z));
} else if (t <= 1.72e+47) {
tmp = x - a;
} else {
tmp = fma((a / t), (z - y), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.72e+59) tmp = fma(Float64(Float64(z - y) / t), a, x); elseif (t <= -2.9e-160) tmp = Float64(x - Float64(Float64(a * y) / Float64(1.0 - z))); elseif (t <= 1.72e+47) tmp = Float64(x - a); else tmp = fma(Float64(a / t), Float64(z - y), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.72e+59], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, -2.9e-160], N[(x - N[(N[(a * y), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.72e+47], N[(x - a), $MachinePrecision], N[(N[(a / t), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.72 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{elif}\;t \leq -2.9 \cdot 10^{-160}:\\
\;\;\;\;x - \frac{a \cdot y}{1 - z}\\
\mathbf{elif}\;t \leq 1.72 \cdot 10^{+47}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{t}, z - y, x\right)\\
\end{array}
\end{array}
if t < -1.71999999999999996e59Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f6453.2
Applied rewrites53.2%
if -1.71999999999999996e59 < t < -2.8999999999999999e-160Initial program 97.3%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6470.2
Applied rewrites70.2%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6464.1
Applied rewrites64.1%
if -2.8999999999999999e-160 < t < 1.72000000000000002e47Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
if 1.72000000000000002e47 < t Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6497.5
Applied rewrites97.5%
Taylor expanded in t around inf
lower-/.f6454.0
Applied rewrites54.0%
(FPCore (x y z t a) :precision binary64 (if (<= t -2.7e+51) (fma (/ (- z y) t) a x) (if (<= t 1.72e+47) (- x a) (fma (/ a t) (- z y) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -2.7e+51) {
tmp = fma(((z - y) / t), a, x);
} else if (t <= 1.72e+47) {
tmp = x - a;
} else {
tmp = fma((a / t), (z - y), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -2.7e+51) tmp = fma(Float64(Float64(z - y) / t), a, x); elseif (t <= 1.72e+47) tmp = Float64(x - a); else tmp = fma(Float64(a / t), Float64(z - y), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -2.7e+51], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[t, 1.72e+47], N[(x - a), $MachinePrecision], N[(N[(a / t), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.7 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{elif}\;t \leq 1.72 \cdot 10^{+47}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{t}, z - y, x\right)\\
\end{array}
\end{array}
if t < -2.69999999999999992e51Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f6453.2
Applied rewrites53.2%
if -2.69999999999999992e51 < t < 1.72000000000000002e47Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
if 1.72000000000000002e47 < t Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6497.5
Applied rewrites97.5%
Taylor expanded in t around inf
lower-/.f6454.0
Applied rewrites54.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ a t) (- z y) x))) (if (<= t -2.7e+51) t_1 (if (<= t 1.72e+47) (- x a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((a / t), (z - y), x);
double tmp;
if (t <= -2.7e+51) {
tmp = t_1;
} else if (t <= 1.72e+47) {
tmp = x - a;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(a / t), Float64(z - y), x) tmp = 0.0 if (t <= -2.7e+51) tmp = t_1; elseif (t <= 1.72e+47) tmp = Float64(x - a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(a / t), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -2.7e+51], t$95$1, If[LessEqual[t, 1.72e+47], N[(x - a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{a}{t}, z - y, x\right)\\
\mathbf{if}\;t \leq -2.7 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.72 \cdot 10^{+47}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.69999999999999992e51 or 1.72000000000000002e47 < t Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-/.f64N/A
div-flip-revN/A
lower-/.f64N/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6497.5
Applied rewrites97.5%
Taylor expanded in t around inf
lower-/.f6454.0
Applied rewrites54.0%
if -2.69999999999999992e51 < t < 1.72000000000000002e47Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (- x (/ (* a y) t)))) (if (<= t -7.5) t_1 (if (<= t 2.7e+46) (- x a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((a * y) / t);
double tmp;
if (t <= -7.5) {
tmp = t_1;
} else if (t <= 2.7e+46) {
tmp = x - a;
} else {
tmp = t_1;
}
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, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = x - ((a * y) / t)
if (t <= (-7.5d0)) then
tmp = t_1
else if (t <= 2.7d+46) then
tmp = x - a
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((a * y) / t);
double tmp;
if (t <= -7.5) {
tmp = t_1;
} else if (t <= 2.7e+46) {
tmp = x - a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x - ((a * y) / t) tmp = 0 if t <= -7.5: tmp = t_1 elif t <= 2.7e+46: tmp = x - a else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(a * y) / t)) tmp = 0.0 if (t <= -7.5) tmp = t_1; elseif (t <= 2.7e+46) tmp = Float64(x - a); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x - ((a * y) / t); tmp = 0.0; if (t <= -7.5) tmp = t_1; elseif (t <= 2.7e+46) tmp = x - a; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(N[(a * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -7.5], t$95$1, If[LessEqual[t, 2.7e+46], N[(x - a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{a \cdot y}{t}\\
\mathbf{if}\;t \leq -7.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.7 \cdot 10^{+46}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -7.5 or 2.7000000000000002e46 < t Initial program 97.3%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f6469.5
Applied rewrites69.5%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6454.2
Applied rewrites54.2%
if -7.5 < t < 2.7000000000000002e46Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ z t) a x))) (if (<= t -9e+58) t_1 (if (<= t 1.05e+76) (- x a) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / t), a, x);
double tmp;
if (t <= -9e+58) {
tmp = t_1;
} else if (t <= 1.05e+76) {
tmp = x - a;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / t), a, x) tmp = 0.0 if (t <= -9e+58) tmp = t_1; elseif (t <= 1.05e+76) tmp = Float64(x - a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[t, -9e+58], t$95$1, If[LessEqual[t, 1.05e+76], N[(x - a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t}, a, x\right)\\
\mathbf{if}\;t \leq -9 \cdot 10^{+58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.05 \cdot 10^{+76}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -8.9999999999999996e58 or 1.05000000000000003e76 < t Initial program 97.3%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
frac-2negN/A
distribute-neg-frac2N/A
remove-double-negN/A
lift-/.f64N/A
associate-/r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6499.7
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
metadata-eval99.7
Applied rewrites99.7%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f6453.2
Applied rewrites53.2%
Taylor expanded in y around 0
lower-/.f6446.9
Applied rewrites46.9%
if -8.9999999999999996e58 < t < 1.05000000000000003e76Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -1750000000.0) (- x a) (if (<= z 3.6e-11) (* 1.0 x) (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1750000000.0) {
tmp = x - a;
} else if (z <= 3.6e-11) {
tmp = 1.0 * x;
} else {
tmp = x - a;
}
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, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-1750000000.0d0)) then
tmp = x - a
else if (z <= 3.6d-11) then
tmp = 1.0d0 * x
else
tmp = x - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1750000000.0) {
tmp = x - a;
} else if (z <= 3.6e-11) {
tmp = 1.0 * x;
} else {
tmp = x - a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1750000000.0: tmp = x - a elif z <= 3.6e-11: tmp = 1.0 * x else: tmp = x - a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1750000000.0) tmp = Float64(x - a); elseif (z <= 3.6e-11) tmp = Float64(1.0 * x); else tmp = Float64(x - a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1750000000.0) tmp = x - a; elseif (z <= 3.6e-11) tmp = 1.0 * x; else tmp = x - a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1750000000.0], N[(x - a), $MachinePrecision], If[LessEqual[z, 3.6e-11], N[(1.0 * x), $MachinePrecision], N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1750000000:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-11}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -1.75e9 or 3.59999999999999985e-11 < z Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
if -1.75e9 < z < 3.59999999999999985e-11Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6458.5
Applied rewrites58.5%
Taylor expanded in x around inf
Applied rewrites54.9%
(FPCore (x y z t a) :precision binary64 (- x a))
double code(double x, double y, double z, double t, double a) {
return x - a;
}
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, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - a
end function
public static double code(double x, double y, double z, double t, double a) {
return x - a;
}
def code(x, y, z, t, a): return x - a
function code(x, y, z, t, a) return Float64(x - a) end
function tmp = code(x, y, z, t, a) tmp = x - a; end
code[x_, y_, z_, t_, a_] := N[(x - a), $MachinePrecision]
\begin{array}{l}
\\
x - a
\end{array}
Initial program 97.3%
Taylor expanded in z around inf
Applied rewrites60.8%
herbie shell --seed 2025159
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))