
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - 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, b)
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), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - 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, b)
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), intent (in) :: b
code = ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y)))
(t_2 (fma (- b y) z y))
(t_3 (+ (* x y) (* z (- t a))))
(t_4 (/ t_3 (+ y (* z (- b y)))))
(t_5 (/ (- t a) t_2)))
(if (<= t_4 (- INFINITY))
(fma t_5 z (* (/ x t_2) y))
(if (<= t_4 -1e-285)
(/ t_3 (- (fma b z y) (* z y)))
(if (<= t_4 0.0)
t_1
(if (<= t_4 INFINITY) (fma (/ y t_2) x (* t_5 z)) t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double t_2 = fma((b - y), z, y);
double t_3 = (x * y) + (z * (t - a));
double t_4 = t_3 / (y + (z * (b - y)));
double t_5 = (t - a) / t_2;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = fma(t_5, z, ((x / t_2) * y));
} else if (t_4 <= -1e-285) {
tmp = t_3 / (fma(b, z, y) - (z * y));
} else if (t_4 <= 0.0) {
tmp = t_1;
} else if (t_4 <= ((double) INFINITY)) {
tmp = fma((y / t_2), x, (t_5 * z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) t_2 = fma(Float64(b - y), z, y) t_3 = Float64(Float64(x * y) + Float64(z * Float64(t - a))) t_4 = Float64(t_3 / Float64(y + Float64(z * Float64(b - y)))) t_5 = Float64(Float64(t - a) / t_2) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = fma(t_5, z, Float64(Float64(x / t_2) * y)); elseif (t_4 <= -1e-285) tmp = Float64(t_3 / Float64(fma(b, z, y) - Float64(z * y))); elseif (t_4 <= 0.0) tmp = t_1; elseif (t_4 <= Inf) tmp = fma(Float64(y / t_2), x, Float64(t_5 * z)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(t - a), $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(t$95$5 * z + N[(N[(x / t$95$2), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -1e-285], N[(t$95$3 / N[(N[(b * z + y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.0], t$95$1, If[LessEqual[t$95$4, Infinity], N[(N[(y / t$95$2), $MachinePrecision] * x + N[(t$95$5 * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
t_2 := \mathsf{fma}\left(b - y, z, y\right)\\
t_3 := x \cdot y + z \cdot \left(t - a\right)\\
t_4 := \frac{t\_3}{y + z \cdot \left(b - y\right)}\\
t_5 := \frac{t - a}{t\_2}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(t\_5, z, \frac{x}{t\_2} \cdot y\right)\\
\mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;\frac{t\_3}{\mathsf{fma}\left(b, z, y\right) - z \cdot y}\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t\_2}, x, t\_5 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0Initial program 66.5%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
remove-double-negN/A
*-rgt-identityN/A
associate-*r/N/A
mult-flipN/A
Applied rewrites69.9%
if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -1.00000000000000007e-285Initial program 66.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f6466.4
Applied rewrites66.4%
if -1.00000000000000007e-285 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0 or +inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < +inf.0Initial program 66.5%
Applied rewrites75.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y)))
(t_2 (+ (* x y) (* z (- t a))))
(t_3 (/ t_2 (+ y (* z (- b y)))))
(t_4 (fma (- b y) z y))
(t_5 (fma (/ y t_4) x (* (/ (- t a) t_4) z))))
(if (<= t_3 -1e+304)
t_5
(if (<= t_3 -1e-285)
(/ t_2 (- (fma b z y) (* z y)))
(if (<= t_3 0.0) t_1 (if (<= t_3 INFINITY) t_5 t_1))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double t_2 = (x * y) + (z * (t - a));
double t_3 = t_2 / (y + (z * (b - y)));
double t_4 = fma((b - y), z, y);
double t_5 = fma((y / t_4), x, (((t - a) / t_4) * z));
double tmp;
if (t_3 <= -1e+304) {
tmp = t_5;
} else if (t_3 <= -1e-285) {
tmp = t_2 / (fma(b, z, y) - (z * y));
} else if (t_3 <= 0.0) {
tmp = t_1;
} else if (t_3 <= ((double) INFINITY)) {
tmp = t_5;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) t_2 = Float64(Float64(x * y) + Float64(z * Float64(t - a))) t_3 = Float64(t_2 / Float64(y + Float64(z * Float64(b - y)))) t_4 = fma(Float64(b - y), z, y) t_5 = fma(Float64(y / t_4), x, Float64(Float64(Float64(t - a) / t_4) * z)) tmp = 0.0 if (t_3 <= -1e+304) tmp = t_5; elseif (t_3 <= -1e-285) tmp = Float64(t_2 / Float64(fma(b, z, y) - Float64(z * y))); elseif (t_3 <= 0.0) tmp = t_1; elseif (t_3 <= Inf) tmp = t_5; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, Block[{t$95$5 = N[(N[(y / t$95$4), $MachinePrecision] * x + N[(N[(N[(t - a), $MachinePrecision] / t$95$4), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+304], t$95$5, If[LessEqual[t$95$3, -1e-285], N[(t$95$2 / N[(N[(b * z + y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], t$95$1, If[LessEqual[t$95$3, Infinity], t$95$5, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
t_2 := x \cdot y + z \cdot \left(t - a\right)\\
t_3 := \frac{t\_2}{y + z \cdot \left(b - y\right)}\\
t_4 := \mathsf{fma}\left(b - y, z, y\right)\\
t_5 := \mathsf{fma}\left(\frac{y}{t\_4}, x, \frac{t - a}{t\_4} \cdot z\right)\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{+304}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;t\_3 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;\frac{t\_2}{\mathsf{fma}\left(b, z, y\right) - z \cdot y}\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;t\_5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -9.9999999999999994e303 or 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < +inf.0Initial program 66.5%
Applied rewrites75.4%
if -9.9999999999999994e303 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -1.00000000000000007e-285Initial program 66.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f6466.4
Applied rewrites66.4%
if -1.00000000000000007e-285 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0 or +inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y)))
(t_2 (+ (* x y) (* z (- t a))))
(t_3 (/ t_2 (+ y (* z (- b y)))))
(t_4 (fma (- b y) z y))
(t_5 (fma 1.0 x (* (/ (- t a) t_4) z))))
(if (<= t_3 -1e+304)
t_5
(if (<= t_3 -1e-285)
(/ t_2 (- (fma b z y) (* z y)))
(if (<= t_3 0.0)
t_1
(if (<= t_3 1e+287)
(/ (fma (- t a) z (* y x)) t_4)
(if (<= t_3 INFINITY) t_5 t_1)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double t_2 = (x * y) + (z * (t - a));
double t_3 = t_2 / (y + (z * (b - y)));
double t_4 = fma((b - y), z, y);
double t_5 = fma(1.0, x, (((t - a) / t_4) * z));
double tmp;
if (t_3 <= -1e+304) {
tmp = t_5;
} else if (t_3 <= -1e-285) {
tmp = t_2 / (fma(b, z, y) - (z * y));
} else if (t_3 <= 0.0) {
tmp = t_1;
} else if (t_3 <= 1e+287) {
tmp = fma((t - a), z, (y * x)) / t_4;
} else if (t_3 <= ((double) INFINITY)) {
tmp = t_5;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) t_2 = Float64(Float64(x * y) + Float64(z * Float64(t - a))) t_3 = Float64(t_2 / Float64(y + Float64(z * Float64(b - y)))) t_4 = fma(Float64(b - y), z, y) t_5 = fma(1.0, x, Float64(Float64(Float64(t - a) / t_4) * z)) tmp = 0.0 if (t_3 <= -1e+304) tmp = t_5; elseif (t_3 <= -1e-285) tmp = Float64(t_2 / Float64(fma(b, z, y) - Float64(z * y))); elseif (t_3 <= 0.0) tmp = t_1; elseif (t_3 <= 1e+287) tmp = Float64(fma(Float64(t - a), z, Float64(y * x)) / t_4); elseif (t_3 <= Inf) tmp = t_5; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, Block[{t$95$5 = N[(1.0 * x + N[(N[(N[(t - a), $MachinePrecision] / t$95$4), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+304], t$95$5, If[LessEqual[t$95$3, -1e-285], N[(t$95$2 / N[(N[(b * z + y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], t$95$1, If[LessEqual[t$95$3, 1e+287], N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[t$95$3, Infinity], t$95$5, t$95$1]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
t_2 := x \cdot y + z \cdot \left(t - a\right)\\
t_3 := \frac{t\_2}{y + z \cdot \left(b - y\right)}\\
t_4 := \mathsf{fma}\left(b - y, z, y\right)\\
t_5 := \mathsf{fma}\left(1, x, \frac{t - a}{t\_4} \cdot z\right)\\
\mathbf{if}\;t\_3 \leq -1 \cdot 10^{+304}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;t\_3 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;\frac{t\_2}{\mathsf{fma}\left(b, z, y\right) - z \cdot y}\\
\mathbf{elif}\;t\_3 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq 10^{+287}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{t\_4}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;t\_5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -9.9999999999999994e303 or 1.0000000000000001e287 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < +inf.0Initial program 66.5%
Applied rewrites75.4%
Taylor expanded in z around 0
Applied rewrites55.8%
if -9.9999999999999994e303 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -1.00000000000000007e-285Initial program 66.5%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-*.f6466.4
Applied rewrites66.4%
if -1.00000000000000007e-285 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0 or +inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 1.0000000000000001e287Initial program 66.5%
*-lft-identityN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.5
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y)))
(t_2 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
(t_3 (fma (- b y) z y))
(t_4 (fma 1.0 x (* (/ (- t a) t_3) z)))
(t_5 (/ (fma (- t a) z (* y x)) t_3)))
(if (<= t_2 -1e+304)
t_4
(if (<= t_2 -1e-285)
t_5
(if (<= t_2 0.0)
t_1
(if (<= t_2 1e+287) t_5 (if (<= t_2 INFINITY) t_4 t_1)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double t_2 = ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
double t_3 = fma((b - y), z, y);
double t_4 = fma(1.0, x, (((t - a) / t_3) * z));
double t_5 = fma((t - a), z, (y * x)) / t_3;
double tmp;
if (t_2 <= -1e+304) {
tmp = t_4;
} else if (t_2 <= -1e-285) {
tmp = t_5;
} else if (t_2 <= 0.0) {
tmp = t_1;
} else if (t_2 <= 1e+287) {
tmp = t_5;
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_4;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) t_2 = Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) t_3 = fma(Float64(b - y), z, y) t_4 = fma(1.0, x, Float64(Float64(Float64(t - a) / t_3) * z)) t_5 = Float64(fma(Float64(t - a), z, Float64(y * x)) / t_3) tmp = 0.0 if (t_2 <= -1e+304) tmp = t_4; elseif (t_2 <= -1e-285) tmp = t_5; elseif (t_2 <= 0.0) tmp = t_1; elseif (t_2 <= 1e+287) tmp = t_5; elseif (t_2 <= Inf) tmp = t_4; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 * x + N[(N[(N[(t - a), $MachinePrecision] / t$95$3), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+304], t$95$4, If[LessEqual[t$95$2, -1e-285], t$95$5, If[LessEqual[t$95$2, 0.0], t$95$1, If[LessEqual[t$95$2, 1e+287], t$95$5, If[LessEqual[t$95$2, Infinity], t$95$4, t$95$1]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
t_2 := \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\
t_3 := \mathsf{fma}\left(b - y, z, y\right)\\
t_4 := \mathsf{fma}\left(1, x, \frac{t - a}{t\_3} \cdot z\right)\\
t_5 := \frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{t\_3}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+304}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-285}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+287}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -9.9999999999999994e303 or 1.0000000000000001e287 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < +inf.0Initial program 66.5%
Applied rewrites75.4%
Taylor expanded in z around 0
Applied rewrites55.8%
if -9.9999999999999994e303 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -1.00000000000000007e-285 or 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 1.0000000000000001e287Initial program 66.5%
*-lft-identityN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.5
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
if -1.00000000000000007e-285 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0 or +inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -3e+35)
t_1
(if (<= z 4800000000000.0)
(/ (fma (- t a) z (* y x)) (fma (- b y) z y))
t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -3e+35) {
tmp = t_1;
} else if (z <= 4800000000000.0) {
tmp = fma((t - a), z, (y * x)) / fma((b - y), z, y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -3e+35) tmp = t_1; elseif (z <= 4800000000000.0) tmp = Float64(fma(Float64(t - a), z, Float64(y * x)) / fma(Float64(b - y), z, y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3e+35], t$95$1, If[LessEqual[z, 4800000000000.0], N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(N[(b - y), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -3 \cdot 10^{+35}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4800000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{\mathsf{fma}\left(b - y, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.99999999999999991e35 or 4.8e12 < z Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if -2.99999999999999991e35 < z < 4.8e12Initial program 66.5%
*-lft-identityN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.5
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -2050.0)
t_1
(if (<= z 2600000000000.0) (/ (fma (- t a) z (* y x)) (fma b z y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -2050.0) {
tmp = t_1;
} else if (z <= 2600000000000.0) {
tmp = fma((t - a), z, (y * x)) / fma(b, z, y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -2050.0) tmp = t_1; elseif (z <= 2600000000000.0) tmp = Float64(fma(Float64(t - a), z, Float64(y * x)) / fma(b, z, y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2050.0], t$95$1, If[LessEqual[z, 2600000000000.0], N[(N[(N[(t - a), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision] / N[(b * z + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -2050:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2600000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(t - a, z, y \cdot x\right)}{\mathsf{fma}\left(b, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2050 or 2.6e12 < z Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if -2050 < z < 2.6e12Initial program 66.5%
*-lft-identityN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-rgt-identityN/A
remove-double-negN/A
remove-double-negN/A
*-rgt-identityN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.5
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
Taylor expanded in y around 0
Applied rewrites57.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -4.2e-12)
t_1
(if (<= z 1.4e-66)
(fma 1.0 x (/ (* z (- t a)) y))
(if (<= z 2600000000000.0) (fma (/ y z) (/ x b) (/ (- t a) b)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -4.2e-12) {
tmp = t_1;
} else if (z <= 1.4e-66) {
tmp = fma(1.0, x, ((z * (t - a)) / y));
} else if (z <= 2600000000000.0) {
tmp = fma((y / z), (x / b), ((t - a) / b));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -4.2e-12) tmp = t_1; elseif (z <= 1.4e-66) tmp = fma(1.0, x, Float64(Float64(z * Float64(t - a)) / y)); elseif (z <= 2600000000000.0) tmp = fma(Float64(y / z), Float64(x / b), Float64(Float64(t - a) / b)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e-12], t$95$1, If[LessEqual[z, 1.4e-66], N[(1.0 * x + N[(N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2600000000000.0], N[(N[(y / z), $MachinePrecision] * N[(x / b), $MachinePrecision] + N[(N[(t - a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-66}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \frac{z \cdot \left(t - a\right)}{y}\right)\\
\mathbf{elif}\;z \leq 2600000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, \frac{x}{b}, \frac{t - a}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.19999999999999988e-12 or 2.6e12 < z Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if -4.19999999999999988e-12 < z < 1.4e-66Initial program 66.5%
Applied rewrites75.4%
Taylor expanded in z around 0
Applied rewrites55.8%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f6437.8
Applied rewrites37.8%
if 1.4e-66 < z < 2.6e12Initial program 66.5%
lift-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
remove-double-negN/A
*-rgt-identityN/A
associate-*r/N/A
mult-flipN/A
Applied rewrites69.9%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f64N/A
lower-*.f6438.5
Applied rewrites38.5%
Taylor expanded in b around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f6439.3
Applied rewrites39.3%
lift-/.f64N/A
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lift--.f64N/A
div-addN/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lower-/.f6439.2
Applied rewrites39.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -4.2e-12)
t_1
(if (<= z 8e-21) (fma 1.0 x (/ (* z (- t a)) y)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -4.2e-12) {
tmp = t_1;
} else if (z <= 8e-21) {
tmp = fma(1.0, x, ((z * (t - a)) / y));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -4.2e-12) tmp = t_1; elseif (z <= 8e-21) tmp = fma(1.0, x, Float64(Float64(z * Float64(t - a)) / y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e-12], t$95$1, If[LessEqual[z, 8e-21], N[(1.0 * x + N[(N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \frac{z \cdot \left(t - a\right)}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.19999999999999988e-12 or 7.99999999999999926e-21 < z Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if -4.19999999999999988e-12 < z < 7.99999999999999926e-21Initial program 66.5%
Applied rewrites75.4%
Taylor expanded in z around 0
Applied rewrites55.8%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f6437.8
Applied rewrites37.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (- t a) (- b y))))
(if (<= z -1.15e-17)
t_1
(if (<= z 1.52e-66) (* -1.0 (/ x (- z 1.0))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -1.15e-17) {
tmp = t_1;
} else if (z <= 1.52e-66) {
tmp = -1.0 * (x / (z - 1.0));
} 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, b)
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), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = (t - a) / (b - y)
if (z <= (-1.15d-17)) then
tmp = t_1
else if (z <= 1.52d-66) then
tmp = (-1.0d0) * (x / (z - 1.0d0))
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 b) {
double t_1 = (t - a) / (b - y);
double tmp;
if (z <= -1.15e-17) {
tmp = t_1;
} else if (z <= 1.52e-66) {
tmp = -1.0 * (x / (z - 1.0));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (t - a) / (b - y) tmp = 0 if z <= -1.15e-17: tmp = t_1 elif z <= 1.52e-66: tmp = -1.0 * (x / (z - 1.0)) else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t - a) / Float64(b - y)) tmp = 0.0 if (z <= -1.15e-17) tmp = t_1; elseif (z <= 1.52e-66) tmp = Float64(-1.0 * Float64(x / Float64(z - 1.0))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (t - a) / (b - y); tmp = 0.0; if (z <= -1.15e-17) tmp = t_1; elseif (z <= 1.52e-66) tmp = -1.0 * (x / (z - 1.0)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e-17], t$95$1, If[LessEqual[z, 1.52e-66], N[(-1.0 * N[(x / N[(z - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - a}{b - y}\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.52 \cdot 10^{-66}:\\
\;\;\;\;-1 \cdot \frac{x}{z - 1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.15000000000000004e-17 or 1.51999999999999995e-66 < z Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
if -1.15000000000000004e-17 < z < 1.51999999999999995e-66Initial program 66.5%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-/.f64N/A
lower--.f6433.0
Applied rewrites33.0%
(FPCore (x y z t a b) :precision binary64 (/ (- t a) (- b y)))
double code(double x, double y, double z, double t, double a, double b) {
return (t - a) / (b - 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, b)
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), intent (in) :: b
code = (t - a) / (b - y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (t - a) / (b - y);
}
def code(x, y, z, t, a, b): return (t - a) / (b - y)
function code(x, y, z, t, a, b) return Float64(Float64(t - a) / Float64(b - y)) end
function tmp = code(x, y, z, t, a, b) tmp = (t - a) / (b - y); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{t - a}{b - y}
\end{array}
Initial program 66.5%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f64N/A
lower--.f6451.2
Applied rewrites51.2%
(FPCore (x y z t a b) :precision binary64 (/ (- t a) b))
double code(double x, double y, double z, double t, double a, double b) {
return (t - a) / b;
}
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, b)
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), intent (in) :: b
code = (t - a) / b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (t - a) / b;
}
def code(x, y, z, t, a, b): return (t - a) / b
function code(x, y, z, t, a, b) return Float64(Float64(t - a) / b) end
function tmp = code(x, y, z, t, a, b) tmp = (t - a) / b; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(t - a), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{t - a}{b}
\end{array}
Initial program 66.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f6434.2
Applied rewrites34.2%
(FPCore (x y z t a b) :precision binary64 (/ t b))
double code(double x, double y, double z, double t, double a, double b) {
return t / b;
}
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, b)
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), intent (in) :: b
code = t / b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return t / b;
}
def code(x, y, z, t, a, b): return t / b
function code(x, y, z, t, a, b) return Float64(t / b) end
function tmp = code(x, y, z, t, a, b) tmp = t / b; end
code[x_, y_, z_, t_, a_, b_] := N[(t / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{t}{b}
\end{array}
Initial program 66.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower--.f6434.2
Applied rewrites34.2%
Taylor expanded in t around inf
lower-/.f6419.4
Applied rewrites19.4%
herbie shell --seed 2025156
(FPCore (x y z t a b)
:name "Development.Shake.Progress:decay from shake-0.15.5"
:precision binary64
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))