
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - 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 - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - 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 - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ y (- z a)) (- z t))) (t_2 (+ x (/ (* y (- z t)) (- z a))))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+307) t_2 t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / (z - a)) * (z - t);
double t_2 = x + ((y * (z - t)) / (z - a));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+307) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y / (z - a)) * (z - t);
double t_2 = x + ((y * (z - t)) / (z - a));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 2e+307) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y / (z - a)) * (z - t) t_2 = x + ((y * (z - t)) / (z - a)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 2e+307: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y / Float64(z - a)) * Float64(z - t)) t_2 = Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+307) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y / (z - a)) * (z - t); t_2 = x + ((y * (z - t)) / (z - a)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 2e+307) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+307], t$95$2, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{z - a} \cdot \left(z - t\right)\\
t_2 := x + \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < -inf.0 or 1.99999999999999997e307 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) Initial program 39.3%
Taylor expanded in x around 0
distribute-rgt-out--N/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
distribute-lft-neg-outN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
div-add-revN/A
associate-*r*N/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-outN/A
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
Applied rewrites87.8%
if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < 1.99999999999999997e307Initial program 99.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ z (- z a)) y x)))
(if (<= z -2.05e+58)
t_1
(if (<= z 1.72e-23) (+ x (/ (* y (- t)) (- z a))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / (z - a)), y, x);
double tmp;
if (z <= -2.05e+58) {
tmp = t_1;
} else if (z <= 1.72e-23) {
tmp = x + ((y * -t) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(z - a)), y, x) tmp = 0.0 if (z <= -2.05e+58) tmp = t_1; elseif (z <= 1.72e-23) tmp = Float64(x + Float64(Float64(y * Float64(-t)) / Float64(z - a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -2.05e+58], t$95$1, If[LessEqual[z, 1.72e-23], N[(x + N[(N[(y * (-t)), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{if}\;z \leq -2.05 \cdot 10^{+58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.72 \cdot 10^{-23}:\\
\;\;\;\;x + \frac{y \cdot \left(-t\right)}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.05e58 or 1.7200000000000001e-23 < z Initial program 73.7%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6486.6
Applied rewrites86.6%
if -2.05e58 < z < 1.7200000000000001e-23Initial program 95.4%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6486.7
Applied rewrites86.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z t) z) y x)))
(if (<= z -9.8e+26)
t_1
(if (<= z 2.6e-123)
(+ x (* (- y) (/ (- z t) a)))
(if (<= z 3.5e+89) t_1 (fma z (/ y (- z a)) x))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - t) / z), y, x);
double tmp;
if (z <= -9.8e+26) {
tmp = t_1;
} else if (z <= 2.6e-123) {
tmp = x + (-y * ((z - t) / a));
} else if (z <= 3.5e+89) {
tmp = t_1;
} else {
tmp = fma(z, (y / (z - a)), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - t) / z), y, x) tmp = 0.0 if (z <= -9.8e+26) tmp = t_1; elseif (z <= 2.6e-123) tmp = Float64(x + Float64(Float64(-y) * Float64(Float64(z - t) / a))); elseif (z <= 3.5e+89) tmp = t_1; else tmp = fma(z, Float64(y / Float64(z - a)), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -9.8e+26], t$95$1, If[LessEqual[z, 2.6e-123], N[(x + N[((-y) * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.5e+89], t$95$1, N[(z * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{if}\;z \leq -9.8 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-123}:\\
\;\;\;\;x + \left(-y\right) \cdot \frac{z - t}{a}\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+89}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{z - a}, x\right)\\
\end{array}
\end{array}
if z < -9.79999999999999947e26 or 2.59999999999999995e-123 < z < 3.5000000000000001e89Initial program 82.7%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6480.2
Applied rewrites80.2%
if -9.79999999999999947e26 < z < 2.59999999999999995e-123Initial program 95.3%
Taylor expanded in a around inf
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift--.f6482.4
Applied rewrites82.4%
if 3.5000000000000001e89 < z Initial program 82.7%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6480.2
Applied rewrites80.2%
lift--.f64N/A
lift-/.f64N/A
lower-fma.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6478.4
Applied rewrites78.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -9.8e+26) (fma (/ (- z t) z) y x) (if (<= z 2.06e-137) (fma y (/ t a) x) (fma (/ z (- z a)) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -9.8e+26) {
tmp = fma(((z - t) / z), y, x);
} else if (z <= 2.06e-137) {
tmp = fma(y, (t / a), x);
} else {
tmp = fma((z / (z - a)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -9.8e+26) tmp = fma(Float64(Float64(z - t) / z), y, x); elseif (z <= 2.06e-137) tmp = fma(y, Float64(t / a), x); else tmp = fma(Float64(z / Float64(z - a)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -9.8e+26], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 2.06e-137], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.8 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{elif}\;z \leq 2.06 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\end{array}
\end{array}
if z < -9.79999999999999947e26Initial program 74.4%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6487.6
Applied rewrites87.6%
if -9.79999999999999947e26 < z < 2.06000000000000003e-137Initial program 95.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6480.0
Applied rewrites80.0%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
if 2.06000000000000003e-137 < z Initial program 80.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6479.7
Applied rewrites79.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ z (- z a)) y x))) (if (<= z -5.2e+39) t_1 (if (<= z 2.06e-137) (fma y (/ t a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / (z - a)), y, x);
double tmp;
if (z <= -5.2e+39) {
tmp = t_1;
} else if (z <= 2.06e-137) {
tmp = fma(y, (t / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(z - a)), y, x) tmp = 0.0 if (z <= -5.2e+39) tmp = t_1; elseif (z <= 2.06e-137) tmp = fma(y, Float64(t / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -5.2e+39], t$95$1, If[LessEqual[z, 2.06e-137], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.06 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.2e39 or 2.06000000000000003e-137 < z Initial program 77.8%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6482.7
Applied rewrites82.7%
if -5.2e39 < z < 2.06000000000000003e-137Initial program 95.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6479.4
Applied rewrites79.4%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.1
Applied rewrites79.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.5e+108) (+ x y) (if (<= z 2.06e-137) (fma y (/ t a) x) (fma z (/ y (- z a)) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.5e+108) {
tmp = x + y;
} else if (z <= 2.06e-137) {
tmp = fma(y, (t / a), x);
} else {
tmp = fma(z, (y / (z - a)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.5e+108) tmp = Float64(x + y); elseif (z <= 2.06e-137) tmp = fma(y, Float64(t / a), x); else tmp = fma(z, Float64(y / Float64(z - a)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.5e+108], N[(x + y), $MachinePrecision], If[LessEqual[z, 2.06e-137], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+108}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 2.06 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{z - a}, x\right)\\
\end{array}
\end{array}
if z < -1.49999999999999992e108Initial program 68.0%
Taylor expanded in z around inf
Applied rewrites83.9%
if -1.49999999999999992e108 < z < 2.06000000000000003e-137Initial program 94.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6476.0
Applied rewrites76.0%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6475.7
Applied rewrites75.7%
if 2.06000000000000003e-137 < z Initial program 80.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6479.7
Applied rewrites79.7%
lift--.f64N/A
lift-/.f64N/A
lower-fma.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lift-/.f64N/A
lift--.f6478.1
Applied rewrites78.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.5e+108) (+ x y) (if (<= z 1e-34) (fma y (/ t a) x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.5e+108) {
tmp = x + y;
} else if (z <= 1e-34) {
tmp = fma(y, (t / a), x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.5e+108) tmp = Float64(x + y); elseif (z <= 1e-34) tmp = fma(y, Float64(t / a), x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.5e+108], N[(x + y), $MachinePrecision], If[LessEqual[z, 1e-34], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+108}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 10^{-34}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -1.49999999999999992e108 or 9.99999999999999928e-35 < z Initial program 72.9%
Taylor expanded in z around inf
Applied rewrites77.9%
if -1.49999999999999992e108 < z < 9.99999999999999928e-35Initial program 94.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6475.0
Applied rewrites75.0%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.8
Applied rewrites74.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -2.2e+148) x (if (<= a 3.6e+186) (+ x y) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.2e+148) {
tmp = x;
} else if (a <= 3.6e+186) {
tmp = x + y;
} else {
tmp = 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, 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 (a <= (-2.2d+148)) then
tmp = x
else if (a <= 3.6d+186) then
tmp = x + y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.2e+148) {
tmp = x;
} else if (a <= 3.6e+186) {
tmp = x + y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -2.2e+148: tmp = x elif a <= 3.6e+186: tmp = x + y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.2e+148) tmp = x; elseif (a <= 3.6e+186) tmp = Float64(x + y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -2.2e+148) tmp = x; elseif (a <= 3.6e+186) tmp = x + y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.2e+148], x, If[LessEqual[a, 3.6e+186], N[(x + y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.2 \cdot 10^{+148}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 3.6 \cdot 10^{+186}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -2.1999999999999999e148 or 3.6000000000000002e186 < a Initial program 80.5%
Taylor expanded in x around inf
Applied rewrites68.1%
if -2.1999999999999999e148 < a < 3.6000000000000002e186Initial program 86.6%
Taylor expanded in z around inf
Applied rewrites62.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) (- z a)))) (if (<= t_1 -2e+188) y (if (<= t_1 1e+265) x y))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / (z - a);
double tmp;
if (t_1 <= -2e+188) {
tmp = y;
} else if (t_1 <= 1e+265) {
tmp = x;
} else {
tmp = 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, 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 = (y * (z - t)) / (z - a)
if (t_1 <= (-2d+188)) then
tmp = y
else if (t_1 <= 1d+265) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / (z - a);
double tmp;
if (t_1 <= -2e+188) {
tmp = y;
} else if (t_1 <= 1e+265) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / (z - a) tmp = 0 if t_1 <= -2e+188: tmp = y elif t_1 <= 1e+265: tmp = x else: tmp = y return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / Float64(z - a)) tmp = 0.0 if (t_1 <= -2e+188) tmp = y; elseif (t_1 <= 1e+265) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / (z - a); tmp = 0.0; if (t_1 <= -2e+188) tmp = y; elseif (t_1 <= 1e+265) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+188], y, If[LessEqual[t$95$1, 1e+265], x, y]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+188}:\\
\;\;\;\;y\\
\mathbf{elif}\;t\_1 \leq 10^{+265}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < -2e188 or 1.00000000000000007e265 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) Initial program 47.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6447.3
Applied rewrites47.3%
Taylor expanded in x around 0
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6435.6
Applied rewrites35.6%
Taylor expanded in z around inf
Applied rewrites30.8%
if -2e188 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 1.00000000000000007e265Initial program 99.6%
Taylor expanded in x around inf
Applied rewrites65.0%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
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, 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
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 85.2%
Taylor expanded in x around inf
Applied rewrites50.7%
herbie shell --seed 2025130
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
(+ x (/ (* y (- z t)) (- z a))))