
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
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) * y) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
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) * y) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (- (+ (/ t (- a t)) 1.0) (/ z (- a t))) y x))
double code(double x, double y, double z, double t, double a) {
return fma((((t / (a - t)) + 1.0) - (z / (a - t))), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(Float64(t / Float64(a - t)) + 1.0) - Float64(z / Float64(a - t))), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\frac{t}{a - t} + 1\right) - \frac{z}{a - t}, y, x\right)
\end{array}
Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- (* -1.0 (/ a t)) (/ z (- a t))) y x)))
(if (<= t -2.8e+99)
t_1
(if (<= t 6.4e+101) (+ x (- y (* (- z t) (/ y (- a t))))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((-1.0 * (a / t)) - (z / (a - t))), y, x);
double tmp;
if (t <= -2.8e+99) {
tmp = t_1;
} else if (t <= 6.4e+101) {
tmp = x + (y - ((z - t) * (y / (a - t))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(-1.0 * Float64(a / t)) - Float64(z / Float64(a - t))), y, x) tmp = 0.0 if (t <= -2.8e+99) tmp = t_1; elseif (t <= 6.4e+101) tmp = Float64(x + Float64(y - Float64(Float64(z - t) * Float64(y / Float64(a - t))))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(-1.0 * N[(a / t), $MachinePrecision]), $MachinePrecision] - N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.8e+99], t$95$1, If[LessEqual[t, 6.4e+101], N[(x + N[(y - N[(N[(z - t), $MachinePrecision] * N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-1 \cdot \frac{a}{t} - \frac{z}{a - t}, y, x\right)\\
\mathbf{if}\;t \leq -2.8 \cdot 10^{+99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 6.4 \cdot 10^{+101}:\\
\;\;\;\;x + \left(y - \left(z - t\right) \cdot \frac{y}{a - t}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.8e99 or 6.4000000000000001e101 < t Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in t around inf
lower-*.f64N/A
lower-/.f6465.5
Applied rewrites65.5%
if -2.8e99 < t < 6.4000000000000001e101Initial program 76.9%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate--l+N/A
*-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6487.3
Applied rewrites87.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (* -1.0 (/ (- a z) t)) y x)))
(if (<= t -2.8e+99)
t_1
(if (<= t 7.7e+101) (+ x (- y (* (- z t) (/ y (- a t))))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((-1.0 * ((a - z) / t)), y, x);
double tmp;
if (t <= -2.8e+99) {
tmp = t_1;
} else if (t <= 7.7e+101) {
tmp = x + (y - ((z - t) * (y / (a - t))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(-1.0 * Float64(Float64(a - z) / t)), y, x) tmp = 0.0 if (t <= -2.8e+99) tmp = t_1; elseif (t <= 7.7e+101) tmp = Float64(x + Float64(y - Float64(Float64(z - t) * Float64(y / Float64(a - t))))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(-1.0 * N[(N[(a - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.8e+99], t$95$1, If[LessEqual[t, 7.7e+101], N[(x + N[(y - N[(N[(z - t), $MachinePrecision] * N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-1 \cdot \frac{a - z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -2.8 \cdot 10^{+99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7.7 \cdot 10^{+101}:\\
\;\;\;\;x + \left(y - \left(z - t\right) \cdot \frac{y}{a - t}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.8e99 or 7.6999999999999996e101 < t Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in t around -inf
lower-*.f64N/A
lower-/.f64N/A
lower--.f6459.8
Applied rewrites59.8%
if -2.8e99 < t < 7.6999999999999996e101Initial program 76.9%
lift-+.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate--l+N/A
*-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6487.3
Applied rewrites87.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (* -1.0 (/ (- a z) t)) y x)))
(if (<= t -4.05e+62)
t_1
(if (<= t 3.7e+101) (fma (- 1.0 (/ z (- a t))) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((-1.0 * ((a - z) / t)), y, x);
double tmp;
if (t <= -4.05e+62) {
tmp = t_1;
} else if (t <= 3.7e+101) {
tmp = fma((1.0 - (z / (a - t))), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(-1.0 * Float64(Float64(a - z) / t)), y, x) tmp = 0.0 if (t <= -4.05e+62) tmp = t_1; elseif (t <= 3.7e+101) tmp = fma(Float64(1.0 - Float64(z / Float64(a - t))), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(-1.0 * N[(N[(a - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -4.05e+62], t$95$1, If[LessEqual[t, 3.7e+101], N[(N[(1.0 - N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(-1 \cdot \frac{a - z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -4.05 \cdot 10^{+62}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.7 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.04999999999999999e62 or 3.6999999999999997e101 < t Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in t around -inf
lower-*.f64N/A
lower-/.f64N/A
lower--.f6459.8
Applied rewrites59.8%
if -4.04999999999999999e62 < t < 3.6999999999999997e101Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in t around 0
Applied rewrites81.7%
(FPCore (x y z t a)
:precision binary64
(if (<= t -1.02e+124)
(fma (/ z t) y x)
(if (<= t 3.65e+104)
(fma (- 1.0 (/ z (- a t))) y x)
(fma (* z (/ 1.0 t)) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.02e+124) {
tmp = fma((z / t), y, x);
} else if (t <= 3.65e+104) {
tmp = fma((1.0 - (z / (a - t))), y, x);
} else {
tmp = fma((z * (1.0 / t)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.02e+124) tmp = fma(Float64(z / t), y, x); elseif (t <= 3.65e+104) tmp = fma(Float64(1.0 - Float64(z / Float64(a - t))), y, x); else tmp = fma(Float64(z * Float64(1.0 / t)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.02e+124], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 3.65e+104], N[(N[(1.0 - N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(z * N[(1.0 / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.02 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 3.65 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \frac{1}{t}, y, x\right)\\
\end{array}
\end{array}
if t < -1.01999999999999994e124Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in a around 0
lower-/.f6461.2
Applied rewrites61.2%
if -1.01999999999999994e124 < t < 3.65000000000000025e104Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in t around 0
Applied rewrites81.7%
if 3.65000000000000025e104 < t Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6486.0
Applied rewrites86.0%
Taylor expanded in a around 0
lower-/.f6461.2
Applied rewrites61.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (- 1.0 (/ z a)) y x))) (if (<= a -1.85e+17) t_1 (if (<= a 15500000000.0) (fma (/ z t) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / a)), y, x);
double tmp;
if (a <= -1.85e+17) {
tmp = t_1;
} else if (a <= 15500000000.0) {
tmp = fma((z / t), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / a)), y, x) tmp = 0.0 if (a <= -1.85e+17) tmp = t_1; elseif (a <= 15500000000.0) tmp = fma(Float64(z / t), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[a, -1.85e+17], t$95$1, If[LessEqual[a, 15500000000.0], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{a}, y, x\right)\\
\mathbf{if}\;a \leq -1.85 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 15500000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -1.85e17 or 1.55e10 < a Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in t around 0
lower--.f64N/A
lower-/.f6467.5
Applied rewrites67.5%
if -1.85e17 < a < 1.55e10Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in a around 0
lower-/.f6461.2
Applied rewrites61.2%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.12e+23) (+ x y) (if (<= a 2.5e+17) (fma (/ z t) y x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.12e+23) {
tmp = x + y;
} else if (a <= 2.5e+17) {
tmp = fma((z / t), y, x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.12e+23) tmp = Float64(x + y); elseif (a <= 2.5e+17) tmp = fma(Float64(z / t), y, x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.12e+23], N[(x + y), $MachinePrecision], If[LessEqual[a, 2.5e+17], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.12 \cdot 10^{+23}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;a \leq 2.5 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if a < -1.12e23 or 2.5e17 < a Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6486.0
Applied rewrites86.0%
Taylor expanded in a around inf
lower-+.f6460.7
Applied rewrites60.7%
if -1.12e23 < a < 2.5e17Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in a around 0
lower-/.f6461.2
Applied rewrites61.2%
(FPCore (x y z t a) :precision binary64 (if (<= (- (+ x y) (/ (* (- z t) y) (- a t))) 1e+307) (+ x y) (/ (* y z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x + y) - (((z - t) * y) / (a - t))) <= 1e+307) {
tmp = x + y;
} else {
tmp = (y * z) / t;
}
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 (((x + y) - (((z - t) * y) / (a - t))) <= 1d+307) then
tmp = x + y
else
tmp = (y * z) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x + y) - (((z - t) * y) / (a - t))) <= 1e+307) {
tmp = x + y;
} else {
tmp = (y * z) / t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((x + y) - (((z - t) * y) / (a - t))) <= 1e+307: tmp = x + y else: tmp = (y * z) / t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) <= 1e+307) tmp = Float64(x + y); else tmp = Float64(Float64(y * z) / t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((x + y) - (((z - t) * y) / (a - t))) <= 1e+307) tmp = x + y; else tmp = (y * z) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+307], N[(x + y), $MachinePrecision], N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \leq 10^{+307}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot z}{t}\\
\end{array}
\end{array}
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 9.99999999999999986e306Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6486.0
Applied rewrites86.0%
Taylor expanded in a around inf
lower-+.f6460.7
Applied rewrites60.7%
if 9.99999999999999986e306 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 76.9%
Taylor expanded in z around inf
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6426.2
Applied rewrites26.2%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6418.5
Applied rewrites18.5%
(FPCore (x y z t a) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a) {
return x + y;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
return x + y;
}
def code(x, y, z, t, a): return x + y
function code(x, y, z, t, a) return Float64(x + y) end
function tmp = code(x, y, z, t, a) tmp = x + y; end
code[x_, y_, z_, t_, a_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6486.0
Applied rewrites86.0%
Taylor expanded in a around inf
lower-+.f6460.7
Applied rewrites60.7%
(FPCore (x y z t a) :precision binary64 y)
double code(double x, double y, double z, double t, double a) {
return y;
}
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 = y
end function
public static double code(double x, double y, double z, double t, double a) {
return y;
}
def code(x, y, z, t, a): return y
function code(x, y, z, t, a) return y end
function tmp = code(x, y, z, t, a) tmp = y; end
code[x_, y_, z_, t_, a_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 76.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6493.6
Applied rewrites93.6%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6486.0
Applied rewrites86.0%
Taylor expanded in a around inf
lower-+.f6460.7
Applied rewrites60.7%
Taylor expanded in x around 0
Applied rewrites19.5%
herbie shell --seed 2025134
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:precision binary64
(- (+ x y) (/ (* (- z t) y) (- a t))))