
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (- (- t z) -1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) - -1.0) / a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) - (-1.0d0)) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) - -1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) - -1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) - -1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) - -1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] - -1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) - -1}{a}}
\end{array}
Initial program 97.8%
Final simplification97.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (- y z) (/ a (+ (- -1.0 t) z))))
(t_2 (- (- t z) -1.0))
(t_3 (/ (- y z) (/ t_2 a))))
(if (<= t_3 -2e+151)
t_1
(if (<= t_3 5e+70)
(- x (/ (* (- y z) a) t_2))
(if (<= t_3 2e+200) (fma (/ z (- (+ 1.0 t) z)) a x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y - z) * (a / ((-1.0 - t) + z));
double t_2 = (t - z) - -1.0;
double t_3 = (y - z) / (t_2 / a);
double tmp;
if (t_3 <= -2e+151) {
tmp = t_1;
} else if (t_3 <= 5e+70) {
tmp = x - (((y - z) * a) / t_2);
} else if (t_3 <= 2e+200) {
tmp = fma((z / ((1.0 + t) - z)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y - z) * Float64(a / Float64(Float64(-1.0 - t) + z))) t_2 = Float64(Float64(t - z) - -1.0) t_3 = Float64(Float64(y - z) / Float64(t_2 / a)) tmp = 0.0 if (t_3 <= -2e+151) tmp = t_1; elseif (t_3 <= 5e+70) tmp = Float64(x - Float64(Float64(Float64(y - z) * a) / t_2)); elseif (t_3 <= 2e+200) tmp = fma(Float64(z / Float64(Float64(1.0 + t) - z)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * N[(a / N[(N[(-1.0 - t), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t - z), $MachinePrecision] - -1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y - z), $MachinePrecision] / N[(t$95$2 / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -2e+151], t$95$1, If[LessEqual[t$95$3, 5e+70], N[(x - N[(N[(N[(y - z), $MachinePrecision] * a), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+200], N[(N[(z / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(y - z\right) \cdot \frac{a}{\left(-1 - t\right) + z}\\
t_2 := \left(t - z\right) - -1\\
t_3 := \frac{y - z}{\frac{t\_2}{a}}\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+151}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+70}:\\
\;\;\;\;x - \frac{\left(y - z\right) \cdot a}{t\_2}\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+200}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\left(1 + t\right) - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < -2.00000000000000003e151 or 1.9999999999999999e200 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) Initial program 99.8%
Taylor expanded in x around 0
Applied rewrites97.9%
if -2.00000000000000003e151 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < 5.0000000000000002e70Initial program 96.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6497.7
lift-+.f64N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f6497.7
Applied rewrites97.7%
if 5.0000000000000002e70 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < 1.9999999999999999e200Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites82.2%
Final simplification96.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ z (- (+ 1.0 t) z)) a x)))
(if (<= z -5.7e-11)
t_1
(if (<= z 600.0)
(- x (* (/ y (+ 1.0 t)) a))
(if (<= z 2.15e+42) (- x (* y (/ a (- 1.0 z)))) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / ((1.0 + t) - z)), a, x);
double tmp;
if (z <= -5.7e-11) {
tmp = t_1;
} else if (z <= 600.0) {
tmp = x - ((y / (1.0 + t)) * a);
} else if (z <= 2.15e+42) {
tmp = x - (y * (a / (1.0 - z)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(Float64(1.0 + t) - z)), a, x) tmp = 0.0 if (z <= -5.7e-11) tmp = t_1; elseif (z <= 600.0) tmp = Float64(x - Float64(Float64(y / Float64(1.0 + t)) * a)); elseif (z <= 2.15e+42) tmp = Float64(x - Float64(y * Float64(a / Float64(1.0 - z)))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -5.7e-11], t$95$1, If[LessEqual[z, 600.0], N[(x - N[(N[(y / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.15e+42], N[(x - N[(y * N[(a / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{\left(1 + t\right) - z}, a, x\right)\\
\mathbf{if}\;z \leq -5.7 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 600:\\
\;\;\;\;x - \frac{y}{1 + t} \cdot a\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{+42}:\\
\;\;\;\;x - y \cdot \frac{a}{1 - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.6999999999999997e-11 or 2.1499999999999999e42 < z Initial program 96.7%
Taylor expanded in y around 0
Applied rewrites84.9%
if -5.6999999999999997e-11 < z < 600Initial program 98.8%
Taylor expanded in z around 0
Applied rewrites94.8%
if 600 < z < 2.1499999999999999e42Initial program 100.0%
Taylor expanded in t around 0
Applied rewrites88.3%
Taylor expanded in y around inf
Applied rewrites100.0%
(FPCore (x y z t a)
:precision binary64
(if (<= z -260.0)
(- x a)
(if (<= z 600.0)
(- x (* (/ y (+ 1.0 t)) a))
(if (<= z 1.6e+140) (- x (* (/ y (- 1.0 z)) a)) (- x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -260.0) {
tmp = x - a;
} else if (z <= 600.0) {
tmp = x - ((y / (1.0 + t)) * a);
} else if (z <= 1.6e+140) {
tmp = x - ((y / (1.0 - z)) * a);
} else {
tmp = x - a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-260.0d0)) then
tmp = x - a
else if (z <= 600.0d0) then
tmp = x - ((y / (1.0d0 + t)) * a)
else if (z <= 1.6d+140) then
tmp = x - ((y / (1.0d0 - z)) * a)
else
tmp = x - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -260.0) {
tmp = x - a;
} else if (z <= 600.0) {
tmp = x - ((y / (1.0 + t)) * a);
} else if (z <= 1.6e+140) {
tmp = x - ((y / (1.0 - z)) * a);
} else {
tmp = x - a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -260.0: tmp = x - a elif z <= 600.0: tmp = x - ((y / (1.0 + t)) * a) elif z <= 1.6e+140: tmp = x - ((y / (1.0 - z)) * a) else: tmp = x - a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -260.0) tmp = Float64(x - a); elseif (z <= 600.0) tmp = Float64(x - Float64(Float64(y / Float64(1.0 + t)) * a)); elseif (z <= 1.6e+140) tmp = Float64(x - Float64(Float64(y / Float64(1.0 - z)) * a)); else tmp = Float64(x - a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -260.0) tmp = x - a; elseif (z <= 600.0) tmp = x - ((y / (1.0 + t)) * a); elseif (z <= 1.6e+140) tmp = x - ((y / (1.0 - z)) * a); else tmp = x - a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -260.0], N[(x - a), $MachinePrecision], If[LessEqual[z, 600.0], N[(x - N[(N[(y / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e+140], N[(x - N[(N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(x - a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -260:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 600:\\
\;\;\;\;x - \frac{y}{1 + t} \cdot a\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+140}:\\
\;\;\;\;x - \frac{y}{1 - z} \cdot a\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -260 or 1.60000000000000005e140 < z Initial program 97.1%
Taylor expanded in z around inf
Applied rewrites74.6%
if -260 < z < 600Initial program 98.8%
Taylor expanded in z around 0
Applied rewrites93.8%
if 600 < z < 1.60000000000000005e140Initial program 95.9%
Taylor expanded in y around inf
Applied rewrites83.2%
Taylor expanded in t around 0
Applied rewrites79.9%
(FPCore (x y z t a)
:precision binary64
(if (<= z -0.64)
(- x a)
(if (<= z 3.6e-260)
(- x (* (- y z) (fma a z a)))
(if (<= z 1.16e+56) (fma (/ (- y z) t) (- a) x) (- x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -0.64) {
tmp = x - a;
} else if (z <= 3.6e-260) {
tmp = x - ((y - z) * fma(a, z, a));
} else if (z <= 1.16e+56) {
tmp = fma(((y - z) / t), -a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -0.64) tmp = Float64(x - a); elseif (z <= 3.6e-260) tmp = Float64(x - Float64(Float64(y - z) * fma(a, z, a))); elseif (z <= 1.16e+56) tmp = fma(Float64(Float64(y - z) / t), Float64(-a), x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -0.64], N[(x - a), $MachinePrecision], If[LessEqual[z, 3.6e-260], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a * z + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.16e+56], N[(N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision] * (-a) + x), $MachinePrecision], N[(x - a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.64:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-260}:\\
\;\;\;\;x - \left(y - z\right) \cdot \mathsf{fma}\left(a, z, a\right)\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{t}, -a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -0.640000000000000013 or 1.1599999999999999e56 < z Initial program 96.7%
Taylor expanded in z around inf
Applied rewrites73.7%
if -0.640000000000000013 < z < 3.6000000000000001e-260Initial program 99.4%
Taylor expanded in t around 0
Applied rewrites82.8%
Taylor expanded in z around 0
Applied rewrites82.8%
if 3.6000000000000001e-260 < z < 1.1599999999999999e56Initial program 97.8%
Taylor expanded in t around inf
Applied rewrites80.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (+ 1.0 t) z)))
(if (or (<= y -2400000.0) (not (<= y 4.5e-31)))
(- x (* (/ y t_1) a))
(fma (/ z t_1) a x))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (1.0 + t) - z;
double tmp;
if ((y <= -2400000.0) || !(y <= 4.5e-31)) {
tmp = x - ((y / t_1) * a);
} else {
tmp = fma((z / t_1), a, x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(1.0 + t) - z) tmp = 0.0 if ((y <= -2400000.0) || !(y <= 4.5e-31)) tmp = Float64(x - Float64(Float64(y / t_1) * a)); else tmp = fma(Float64(z / t_1), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[y, -2400000.0], N[Not[LessEqual[y, 4.5e-31]], $MachinePrecision]], N[(x - N[(N[(y / t$95$1), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[(z / t$95$1), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 + t\right) - z\\
\mathbf{if}\;y \leq -2400000 \lor \neg \left(y \leq 4.5 \cdot 10^{-31}\right):\\
\;\;\;\;x - \frac{y}{t\_1} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t\_1}, a, x\right)\\
\end{array}
\end{array}
if y < -2.4e6 or 4.5000000000000004e-31 < y Initial program 97.5%
Taylor expanded in y around inf
Applied rewrites91.6%
if -2.4e6 < y < 4.5000000000000004e-31Initial program 98.3%
Taylor expanded in y around 0
Applied rewrites93.5%
Final simplification92.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -0.64)
(- x a)
(if (<= z 3.6e-260)
(- x (* (- y z) (fma a z a)))
(if (<= z 1.65e+56) (fma (/ y t) (- a) x) (- x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -0.64) {
tmp = x - a;
} else if (z <= 3.6e-260) {
tmp = x - ((y - z) * fma(a, z, a));
} else if (z <= 1.65e+56) {
tmp = fma((y / t), -a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -0.64) tmp = Float64(x - a); elseif (z <= 3.6e-260) tmp = Float64(x - Float64(Float64(y - z) * fma(a, z, a))); elseif (z <= 1.65e+56) tmp = fma(Float64(y / t), Float64(-a), x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -0.64], N[(x - a), $MachinePrecision], If[LessEqual[z, 3.6e-260], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a * z + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.65e+56], N[(N[(y / t), $MachinePrecision] * (-a) + x), $MachinePrecision], N[(x - a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.64:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-260}:\\
\;\;\;\;x - \left(y - z\right) \cdot \mathsf{fma}\left(a, z, a\right)\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+56}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, -a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -0.640000000000000013 or 1.65000000000000001e56 < z Initial program 96.7%
Taylor expanded in z around inf
Applied rewrites73.7%
if -0.640000000000000013 < z < 3.6000000000000001e-260Initial program 99.4%
Taylor expanded in t around 0
Applied rewrites82.8%
Taylor expanded in z around 0
Applied rewrites82.8%
if 3.6000000000000001e-260 < z < 1.65000000000000001e56Initial program 97.8%
Taylor expanded in t around inf
Applied rewrites80.7%
Taylor expanded in y around inf
Applied rewrites79.3%
(FPCore (x y z t a)
:precision binary64
(if (<= t -1200000000.0)
(- x (* (- y z) (/ a t)))
(if (<= t 3.8e+21)
(- x (* (- y z) (/ a (- 1.0 z))))
(fma (/ z (- (+ 1.0 t) z)) a x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1200000000.0) {
tmp = x - ((y - z) * (a / t));
} else if (t <= 3.8e+21) {
tmp = x - ((y - z) * (a / (1.0 - z)));
} else {
tmp = fma((z / ((1.0 + t) - z)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1200000000.0) tmp = Float64(x - Float64(Float64(y - z) * Float64(a / t))); elseif (t <= 3.8e+21) tmp = Float64(x - Float64(Float64(y - z) * Float64(a / Float64(1.0 - z)))); else tmp = fma(Float64(z / Float64(Float64(1.0 + t) - z)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1200000000.0], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.8e+21], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1200000000:\\
\;\;\;\;x - \left(y - z\right) \cdot \frac{a}{t}\\
\mathbf{elif}\;t \leq 3.8 \cdot 10^{+21}:\\
\;\;\;\;x - \left(y - z\right) \cdot \frac{a}{1 - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\left(1 + t\right) - z}, a, x\right)\\
\end{array}
\end{array}
if t < -1.2e9Initial program 97.8%
Taylor expanded in t around inf
Applied rewrites75.2%
Applied rewrites86.1%
if -1.2e9 < t < 3.8e21Initial program 97.9%
Taylor expanded in t around 0
Applied rewrites96.8%
if 3.8e21 < t Initial program 97.7%
Taylor expanded in y around 0
Applied rewrites86.3%
(FPCore (x y z t a)
:precision binary64
(if (<= z -5.7e-11)
(fma (/ z (- (+ 1.0 t) z)) a x)
(if (<= z 640.0)
(- x (* (/ y (+ 1.0 t)) a))
(- x (* (- y z) (/ (- a) z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -5.7e-11) {
tmp = fma((z / ((1.0 + t) - z)), a, x);
} else if (z <= 640.0) {
tmp = x - ((y / (1.0 + t)) * a);
} else {
tmp = x - ((y - z) * (-a / z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -5.7e-11) tmp = fma(Float64(z / Float64(Float64(1.0 + t) - z)), a, x); elseif (z <= 640.0) tmp = Float64(x - Float64(Float64(y / Float64(1.0 + t)) * a)); else tmp = Float64(x - Float64(Float64(y - z) * Float64(Float64(-a) / z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -5.7e-11], N[(N[(z / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[z, 640.0], N[(x - N[(N[(y / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y - z), $MachinePrecision] * N[((-a) / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.7 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\left(1 + t\right) - z}, a, x\right)\\
\mathbf{elif}\;z \leq 640:\\
\;\;\;\;x - \frac{y}{1 + t} \cdot a\\
\mathbf{else}:\\
\;\;\;\;x - \left(y - z\right) \cdot \frac{-a}{z}\\
\end{array}
\end{array}
if z < -5.6999999999999997e-11Initial program 97.1%
Taylor expanded in y around 0
Applied rewrites84.6%
if -5.6999999999999997e-11 < z < 640Initial program 98.8%
Taylor expanded in z around 0
Applied rewrites94.8%
if 640 < z Initial program 96.6%
Taylor expanded in t around 0
Applied rewrites86.4%
Taylor expanded in z around inf
Applied rewrites86.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -0.000145) (not (<= t 5.3e+66))) (fma (/ (- y z) t) (- a) x) (- x (* (/ y (- 1.0 z)) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -0.000145) || !(t <= 5.3e+66)) {
tmp = fma(((y - z) / t), -a, x);
} else {
tmp = x - ((y / (1.0 - z)) * a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -0.000145) || !(t <= 5.3e+66)) tmp = fma(Float64(Float64(y - z) / t), Float64(-a), x); else tmp = Float64(x - Float64(Float64(y / Float64(1.0 - z)) * a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -0.000145], N[Not[LessEqual[t, 5.3e+66]], $MachinePrecision]], N[(N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision] * (-a) + x), $MachinePrecision], N[(x - N[(N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.000145 \lor \neg \left(t \leq 5.3 \cdot 10^{+66}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{t}, -a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{1 - z} \cdot a\\
\end{array}
\end{array}
if t < -1.45e-4 or 5.2999999999999997e66 < t Initial program 97.6%
Taylor expanded in t around inf
Applied rewrites82.3%
if -1.45e-4 < t < 5.2999999999999997e66Initial program 98.0%
Taylor expanded in y around inf
Applied rewrites83.1%
Taylor expanded in t around 0
Applied rewrites82.5%
Final simplification82.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -0.000145) (not (<= t 5.3e+66))) (fma (/ (- y z) t) (- a) x) (- x (* y (/ a (- 1.0 z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -0.000145) || !(t <= 5.3e+66)) {
tmp = fma(((y - z) / t), -a, x);
} else {
tmp = x - (y * (a / (1.0 - z)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -0.000145) || !(t <= 5.3e+66)) tmp = fma(Float64(Float64(y - z) / t), Float64(-a), x); else tmp = Float64(x - Float64(y * Float64(a / Float64(1.0 - z)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -0.000145], N[Not[LessEqual[t, 5.3e+66]], $MachinePrecision]], N[(N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision] * (-a) + x), $MachinePrecision], N[(x - N[(y * N[(a / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.000145 \lor \neg \left(t \leq 5.3 \cdot 10^{+66}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{t}, -a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{a}{1 - z}\\
\end{array}
\end{array}
if t < -1.45e-4 or 5.2999999999999997e66 < t Initial program 97.6%
Taylor expanded in t around inf
Applied rewrites82.3%
if -1.45e-4 < t < 5.2999999999999997e66Initial program 98.0%
Taylor expanded in t around 0
Applied rewrites96.2%
Taylor expanded in y around inf
Applied rewrites81.3%
Final simplification81.8%
(FPCore (x y z t a)
:precision binary64
(if (<= t -0.000145)
(- x (* (- y z) (/ a t)))
(if (<= t 5.3e+66)
(- x (* (/ y (- 1.0 z)) a))
(fma (/ (- y z) t) (- a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -0.000145) {
tmp = x - ((y - z) * (a / t));
} else if (t <= 5.3e+66) {
tmp = x - ((y / (1.0 - z)) * a);
} else {
tmp = fma(((y - z) / t), -a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -0.000145) tmp = Float64(x - Float64(Float64(y - z) * Float64(a / t))); elseif (t <= 5.3e+66) tmp = Float64(x - Float64(Float64(y / Float64(1.0 - z)) * a)); else tmp = fma(Float64(Float64(y - z) / t), Float64(-a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -0.000145], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 5.3e+66], N[(x - N[(N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision] * (-a) + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.000145:\\
\;\;\;\;x - \left(y - z\right) \cdot \frac{a}{t}\\
\mathbf{elif}\;t \leq 5.3 \cdot 10^{+66}:\\
\;\;\;\;x - \frac{y}{1 - z} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{t}, -a, x\right)\\
\end{array}
\end{array}
if t < -1.45e-4Initial program 97.9%
Taylor expanded in t around inf
Applied rewrites71.5%
Applied rewrites81.9%
if -1.45e-4 < t < 5.2999999999999997e66Initial program 98.0%
Taylor expanded in y around inf
Applied rewrites83.1%
Taylor expanded in t around 0
Applied rewrites82.5%
if 5.2999999999999997e66 < t Initial program 97.2%
Taylor expanded in t around inf
Applied rewrites84.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -0.64) (not (<= z 1.0))) (- x a) (- x (* (- y z) (fma a z a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -0.64) || !(z <= 1.0)) {
tmp = x - a;
} else {
tmp = x - ((y - z) * fma(a, z, a));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -0.64) || !(z <= 1.0)) tmp = Float64(x - a); else tmp = Float64(x - Float64(Float64(y - z) * fma(a, z, a))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -0.64], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a * z + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.64 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - \left(y - z\right) \cdot \mathsf{fma}\left(a, z, a\right)\\
\end{array}
\end{array}
if z < -0.640000000000000013 or 1 < z Initial program 96.8%
Taylor expanded in z around inf
Applied rewrites70.8%
if -0.640000000000000013 < z < 1Initial program 98.8%
Taylor expanded in t around 0
Applied rewrites75.9%
Taylor expanded in z around 0
Applied rewrites75.4%
Final simplification73.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.8e+27) (not (<= z 1.0))) (- x a) (- x (* (- y z) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.8e+27) || !(z <= 1.0)) {
tmp = x - a;
} else {
tmp = x - ((y - z) * a);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((z <= (-4.8d+27)) .or. (.not. (z <= 1.0d0))) then
tmp = x - a
else
tmp = x - ((y - z) * a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.8e+27) || !(z <= 1.0)) {
tmp = x - a;
} else {
tmp = x - ((y - z) * a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -4.8e+27) or not (z <= 1.0): tmp = x - a else: tmp = x - ((y - z) * a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.8e+27) || !(z <= 1.0)) tmp = Float64(x - a); else tmp = Float64(x - Float64(Float64(y - z) * a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -4.8e+27) || ~((z <= 1.0))) tmp = x - a; else tmp = x - ((y - z) * a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.8e+27], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(N[(y - z), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+27} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - \left(y - z\right) \cdot a\\
\end{array}
\end{array}
if z < -4.79999999999999995e27 or 1 < z Initial program 96.7%
Taylor expanded in z around inf
Applied rewrites70.9%
if -4.79999999999999995e27 < z < 1Initial program 98.9%
Taylor expanded in t around 0
Applied rewrites76.3%
Taylor expanded in z around 0
Applied rewrites74.6%
Final simplification72.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -0.64) (not (<= z 9e+25))) (- x a) (- x (* y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -0.64) || !(z <= 9e+25)) {
tmp = x - a;
} else {
tmp = x - (y * a);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((z <= (-0.64d0)) .or. (.not. (z <= 9d+25))) then
tmp = x - a
else
tmp = x - (y * a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -0.64) || !(z <= 9e+25)) {
tmp = x - a;
} else {
tmp = x - (y * a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -0.64) or not (z <= 9e+25): tmp = x - a else: tmp = x - (y * a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -0.64) || !(z <= 9e+25)) tmp = Float64(x - a); else tmp = Float64(x - Float64(y * a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -0.64) || ~((z <= 9e+25))) tmp = x - a; else tmp = x - (y * a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -0.64], N[Not[LessEqual[z, 9e+25]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(y * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.64 \lor \neg \left(z \leq 9 \cdot 10^{+25}\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot a\\
\end{array}
\end{array}
if z < -0.640000000000000013 or 9.0000000000000006e25 < z Initial program 96.7%
Taylor expanded in z around inf
Applied rewrites73.2%
if -0.640000000000000013 < z < 9.0000000000000006e25Initial program 98.9%
Taylor expanded in t around 0
Applied rewrites75.6%
Taylor expanded in z around 0
Applied rewrites71.6%
Final simplification72.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.8e-26) (not (<= z 2.15e+42))) (- x a) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.8e-26) || !(z <= 2.15e+42)) {
tmp = x - a;
} else {
tmp = x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((z <= (-2.8d-26)) .or. (.not. (z <= 2.15d+42))) then
tmp = x - a
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.8e-26) || !(z <= 2.15e+42)) {
tmp = x - a;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -2.8e-26) or not (z <= 2.15e+42): tmp = x - a else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.8e-26) || !(z <= 2.15e+42)) tmp = Float64(x - a); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -2.8e-26) || ~((z <= 2.15e+42))) tmp = x - a; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.8e-26], N[Not[LessEqual[z, 2.15e+42]], $MachinePrecision]], N[(x - a), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-26} \lor \neg \left(z \leq 2.15 \cdot 10^{+42}\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.8000000000000001e-26 or 2.1499999999999999e42 < z Initial program 96.7%
Taylor expanded in z around inf
Applied rewrites72.2%
if -2.8000000000000001e-26 < z < 2.1499999999999999e42Initial program 98.9%
Taylor expanded in x around inf
Applied rewrites60.0%
Final simplification65.9%
(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 97.8%
Taylor expanded in x around inf
Applied rewrites54.8%
(FPCore (x y z t a) :precision binary64 (- x (* (/ (- y z) (+ (- t z) 1.0)) a)))
double code(double x, double y, double z, double t, double a) {
return x - (((y - z) / ((t - z) + 1.0)) * a);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - (((y - z) / ((t - z) + 1.0d0)) * a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - (((y - z) / ((t - z) + 1.0)) * a);
}
def code(x, y, z, t, a): return x - (((y - z) / ((t - z) + 1.0)) * a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(Float64(y - z) / Float64(Float64(t - z) + 1.0)) * a)) end
function tmp = code(x, y, z, t, a) tmp = x - (((y - z) / ((t - z) + 1.0)) * a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(N[(y - z), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\left(t - z\right) + 1} \cdot a
\end{array}
herbie shell --seed 2025021
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (- x (* (/ (- y z) (+ (- t z) 1)) a)))
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))