
(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 12 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 (fma (- z t) (/ y (- z a)) x))
(t_2 (+ x (/ (* y (- z t)) (- z a)))))
(if (<= t_2 -5e+190)
t_1
(if (<= t_2 2e+268) (+ x (/ (fma (- t) y (* z y)) (- z a))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z - t), (y / (z - a)), x);
double t_2 = x + ((y * (z - t)) / (z - a));
double tmp;
if (t_2 <= -5e+190) {
tmp = t_1;
} else if (t_2 <= 2e+268) {
tmp = x + (fma(-t, y, (z * y)) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z - t), Float64(y / Float64(z - a)), x) t_2 = Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) tmp = 0.0 if (t_2 <= -5e+190) tmp = t_1; elseif (t_2 <= 2e+268) tmp = Float64(x + Float64(fma(Float64(-t), y, Float64(z * y)) / Float64(z - a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $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, -5e+190], t$95$1, If[LessEqual[t$95$2, 2e+268], N[(x + N[(N[((-t) * y + N[(z * y), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - t, \frac{y}{z - a}, x\right)\\
t_2 := x + \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+268}:\\
\;\;\;\;x + \frac{\mathsf{fma}\left(-t, y, z \cdot y\right)}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < -5.00000000000000036e190 or 1.9999999999999999e268 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) Initial program 60.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6497.5
Applied rewrites97.5%
if -5.00000000000000036e190 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < 1.9999999999999999e268Initial program 99.6%
Taylor expanded in z around 0
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- z t) (/ y (- z a)) x))
(t_2 (+ x (/ (* y (- z t)) (- z a)))))
(if (<= t_2 -5e+190) t_1 (if (<= t_2 2e+268) t_2 t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z - t), (y / (z - a)), x);
double t_2 = x + ((y * (z - t)) / (z - a));
double tmp;
if (t_2 <= -5e+190) {
tmp = t_1;
} else if (t_2 <= 2e+268) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z - t), Float64(y / Float64(z - a)), x) t_2 = Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) tmp = 0.0 if (t_2 <= -5e+190) tmp = t_1; elseif (t_2 <= 2e+268) tmp = t_2; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $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, -5e+190], t$95$1, If[LessEqual[t$95$2, 2e+268], t$95$2, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z - t, \frac{y}{z - a}, x\right)\\
t_2 := x + \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+268}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < -5.00000000000000036e190 or 1.9999999999999999e268 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) Initial program 60.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6475.9
Applied rewrites75.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6497.5
Applied rewrites97.5%
if -5.00000000000000036e190 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < 1.9999999999999999e268Initial program 99.6%
(FPCore (x y z t a) :precision binary64 (fma (- z t) (/ y (- z a)) x))
double code(double x, double y, double z, double t, double a) {
return fma((z - t), (y / (z - a)), x);
}
function code(x, y, z, t, a) return fma(Float64(z - t), Float64(y / Float64(z - a)), x) end
code[x_, y_, z_, t_, a_] := N[(N[(z - t), $MachinePrecision] * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - t, \frac{y}{z - a}, x\right)
\end{array}
Initial program 85.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6484.5
Applied rewrites84.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6496.0
Applied rewrites96.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) (- z a))))
(if (<= t_1 -4e+24)
(* (- z t) (/ y (- z a)))
(if (<= t_1 6e-6) (fma y (/ z (- z a)) x) (fma (- z t) (/ y z) x)))))
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 <= -4e+24) {
tmp = (z - t) * (y / (z - a));
} else if (t_1 <= 6e-6) {
tmp = fma(y, (z / (z - a)), x);
} else {
tmp = fma((z - t), (y / z), x);
}
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 <= -4e+24) tmp = Float64(Float64(z - t) * Float64(y / Float64(z - a))); elseif (t_1 <= 6e-6) tmp = fma(y, Float64(z / Float64(z - a)), x); else tmp = fma(Float64(z - t), Float64(y / z), x); end return 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, -4e+24], N[(N[(z - t), $MachinePrecision] * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 6e-6], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(z - t), $MachinePrecision] * N[(y / z), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{z - a}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+24}:\\
\;\;\;\;\left(z - t\right) \cdot \frac{y}{z - a}\\
\mathbf{elif}\;t\_1 \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{z}, x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < -3.9999999999999999e24Initial program 69.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6456.5
Applied rewrites56.5%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6477.8
Applied rewrites77.8%
if -3.9999999999999999e24 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) < 6.0000000000000002e-6Initial program 99.6%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6490.2
Applied rewrites90.2%
if 6.0000000000000002e-6 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a)) Initial program 71.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6472.8
Applied rewrites72.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6496.7
Applied rewrites96.7%
Taylor expanded in z around inf
Applied rewrites63.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma y (/ z (- z a)) x))) (if (<= a -9e-148) t_1 (if (<= a 3.5e+37) (fma (- z t) (/ y z) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (z / (z - a)), x);
double tmp;
if (a <= -9e-148) {
tmp = t_1;
} else if (a <= 3.5e+37) {
tmp = fma((z - t), (y / z), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(z / Float64(z - a)), x) tmp = 0.0 if (a <= -9e-148) tmp = t_1; elseif (a <= 3.5e+37) tmp = fma(Float64(z - t), Float64(y / z), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -9e-148], t$95$1, If[LessEqual[a, 3.5e+37], N[(N[(z - t), $MachinePrecision] * N[(y / z), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{if}\;a \leq -9 \cdot 10^{-148}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -9.00000000000000029e-148 or 3.5e37 < a Initial program 84.1%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6476.7
Applied rewrites76.7%
if -9.00000000000000029e-148 < a < 3.5e37Initial program 87.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6481.0
Applied rewrites81.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6495.0
Applied rewrites95.0%
Taylor expanded in z around inf
Applied rewrites81.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma y (/ z (- z a)) x))) (if (<= a -1.35e-77) t_1 (if (<= a 3.5e+37) (fma y (/ (- z t) z) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (z / (z - a)), x);
double tmp;
if (a <= -1.35e-77) {
tmp = t_1;
} else if (a <= 3.5e+37) {
tmp = fma(y, ((z - t) / z), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(z / Float64(z - a)), x) tmp = 0.0 if (a <= -1.35e-77) tmp = t_1; elseif (a <= 3.5e+37) tmp = fma(y, Float64(Float64(z - t) / z), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -1.35e-77], t$95$1, If[LessEqual[a, 3.5e+37], N[(y * N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{if}\;a \leq -1.35 \cdot 10^{-77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.35e-77 or 3.5e37 < a Initial program 83.7%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6477.9
Applied rewrites77.9%
if -1.35e-77 < a < 3.5e37Initial program 87.6%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6483.0
Applied rewrites83.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (+ x (/ (* (- t) y) z)))) (if (<= t -1.9e+164) t_1 (if (<= t 5.8e+180) (fma y (/ z (- z a)) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + ((-t * y) / z);
double tmp;
if (t <= -1.9e+164) {
tmp = t_1;
} else if (t <= 5.8e+180) {
tmp = fma(y, (z / (z - a)), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(-t) * y) / z)) tmp = 0.0 if (t <= -1.9e+164) tmp = t_1; elseif (t <= 5.8e+180) tmp = fma(y, Float64(z / Float64(z - a)), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[((-t) * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.9e+164], t$95$1, If[LessEqual[t, 5.8e+180], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(-t\right) \cdot y}{z}\\
\mathbf{if}\;t \leq -1.9 \cdot 10^{+164}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 5.8 \cdot 10^{+180}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.90000000000000011e164 or 5.80000000000000015e180 < t Initial program 80.4%
Taylor expanded in z around inf
associate--l+N/A
associate-*r/N/A
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6453.5
Applied rewrites53.5%
Taylor expanded in t around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lower-*.f6451.4
Applied rewrites51.4%
if -1.90000000000000011e164 < t < 5.80000000000000015e180Initial program 87.0%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6481.0
Applied rewrites81.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -0.011) (+ x y) (if (<= z 1.9e-110) (fma t (/ y a) x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -0.011) {
tmp = x + y;
} else if (z <= 1.9e-110) {
tmp = fma(t, (y / a), x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -0.011) tmp = Float64(x + y); elseif (z <= 1.9e-110) tmp = fma(t, Float64(y / a), x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -0.011], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.9e-110], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.011:\\
\;\;\;\;x + y\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-110}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if z < -0.010999999999999999 or 1.8999999999999999e-110 < z Initial program 78.4%
Taylor expanded in z around inf
Applied rewrites72.1%
if -0.010999999999999999 < z < 1.8999999999999999e-110Initial program 95.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
(FPCore (x y z t a) :precision binary64 (if (<= t 1.75e+239) (+ x y) (* (- t) (/ y z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 1.75e+239) {
tmp = x + y;
} else {
tmp = -t * (y / z);
}
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 (t <= 1.75d+239) then
tmp = x + y
else
tmp = -t * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 1.75e+239) {
tmp = x + y;
} else {
tmp = -t * (y / z);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 1.75e+239: tmp = x + y else: tmp = -t * (y / z) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 1.75e+239) tmp = Float64(x + y); else tmp = Float64(Float64(-t) * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= 1.75e+239) tmp = x + y; else tmp = -t * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 1.75e+239], N[(x + y), $MachinePrecision], N[((-t) * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 1.75 \cdot 10^{+239}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\left(-t\right) \cdot \frac{y}{z}\\
\end{array}
\end{array}
if t < 1.7500000000000001e239Initial program 85.9%
Taylor expanded in z around inf
Applied rewrites62.3%
if 1.7500000000000001e239 < t Initial program 79.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6459.4
Applied rewrites59.4%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lower-*.f6433.8
Applied rewrites33.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.8
Applied rewrites38.8%
(FPCore (x y z t a) :precision binary64 (if (<= a -8.6e+94) x (+ x y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -8.6e+94) {
tmp = x;
} else {
tmp = x + 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) :: tmp
if (a <= (-8.6d+94)) then
tmp = x
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -8.6e+94) {
tmp = x;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -8.6e+94: tmp = x else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -8.6e+94) tmp = x; else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= -8.6e+94) tmp = x; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -8.6e+94], x, N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.6 \cdot 10^{+94}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if a < -8.6e94Initial program 81.9%
Taylor expanded in x around inf
Applied rewrites65.2%
if -8.6e94 < a Initial program 86.3%
Taylor expanded in z around inf
Applied rewrites61.4%
(FPCore (x y z t a) :precision binary64 (if (<= (+ x (/ (* y (- z t)) (- z a))) (- INFINITY)) y x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y * (z - t)) / (z - a))) <= -((double) INFINITY)) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x + ((y * (z - t)) / (z - a))) <= -Double.POSITIVE_INFINITY) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x + ((y * (z - t)) / (z - a))) <= -math.inf: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) <= Float64(-Inf)) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x + ((y * (z - t)) / (z - a))) <= -Inf) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], y, x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \frac{y \cdot \left(z - t\right)}{z - a} \leq -\infty:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) < -inf.0Initial program 40.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6440.7
Applied rewrites40.7%
Taylor expanded in z around inf
Applied rewrites5.9%
Taylor expanded in z around inf
associate-*r/31.1
Applied rewrites31.1%
if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 z a))) Initial program 91.5%
Taylor expanded in x around inf
Applied rewrites55.8%
(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.5%
Taylor expanded in x around inf
Applied rewrites50.8%
herbie shell --seed 2025112
(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))))