
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / 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)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot \left(z - t\right)}{a}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / 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)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y \cdot \left(z - t\right)}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* y (- z t))) (t_2 (fma (/ (- t z) a) y x))) (if (<= t_1 (- INFINITY)) t_2 (if (<= t_1 5e+189) (- x (/ t_1 a)) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * (z - t);
double t_2 = fma(((t - z) / a), y, x);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= 5e+189) {
tmp = x - (t_1 / a);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(z - t)) t_2 = fma(Float64(Float64(t - z) / a), y, x) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= 5e+189) tmp = Float64(x - Float64(t_1 / a)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 5e+189], N[(x - N[(t$95$1 / a), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
t_2 := \mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+189}:\\
\;\;\;\;x - \frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -inf.0 or 5.0000000000000004e189 < (*.f64 y (-.f64 z t)) Initial program 78.8%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower--.f64N/A
negate-subN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-subN/A
negate-sub2N/A
+-commutativeN/A
negate-sub2N/A
div-subN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r/N/A
mul-1-negN/A
negate-sub2N/A
lower-/.f64N/A
lower--.f6499.2
Applied rewrites99.2%
if -inf.0 < (*.f64 y (-.f64 z t)) < 5.0000000000000004e189Initial program 99.3%
(FPCore (x y z t a) :precision binary64 (if (<= t -3.5e+181) (fma t (/ y a) x) (fma (/ (- t z) a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -3.5e+181) {
tmp = fma(t, (y / a), x);
} else {
tmp = fma(((t - z) / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -3.5e+181) tmp = fma(t, Float64(y / a), x); else tmp = fma(Float64(Float64(t - z) / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -3.5e+181], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.5 \cdot 10^{+181}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\end{array}
\end{array}
if t < -3.50000000000000008e181Initial program 89.8%
Taylor expanded in z around 0
negate-subN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
if -3.50000000000000008e181 < t Initial program 93.9%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower--.f64N/A
negate-subN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-subN/A
negate-sub2N/A
+-commutativeN/A
negate-sub2N/A
div-subN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r/N/A
mul-1-negN/A
negate-sub2N/A
lower-/.f64N/A
lower--.f6494.4
Applied rewrites94.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (/ (* (- t z) y) a))) (if (<= t_1 -5e+69) t_2 (if (<= t_1 2e+34) (- x (* y (/ z a))) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = ((t - z) * y) / a;
double tmp;
if (t_1 <= -5e+69) {
tmp = t_2;
} else if (t_1 <= 2e+34) {
tmp = x - (y * (z / a));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = ((t - z) * y) / a
if (t_1 <= (-5d+69)) then
tmp = t_2
else if (t_1 <= 2d+34) then
tmp = x - (y * (z / a))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = ((t - z) * y) / a;
double tmp;
if (t_1 <= -5e+69) {
tmp = t_2;
} else if (t_1 <= 2e+34) {
tmp = x - (y * (z / a));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = ((t - z) * y) / a tmp = 0 if t_1 <= -5e+69: tmp = t_2 elif t_1 <= 2e+34: tmp = x - (y * (z / a)) else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(Float64(t - z) * y) / a) tmp = 0.0 if (t_1 <= -5e+69) tmp = t_2; elseif (t_1 <= 2e+34) tmp = Float64(x - Float64(y * Float64(z / a))); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = ((t - z) * y) / a; tmp = 0.0; if (t_1 <= -5e+69) tmp = t_2; elseif (t_1 <= 2e+34) tmp = x - (y * (z / a)); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t - z), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+69], t$95$2, If[LessEqual[t$95$1, 2e+34], N[(x - N[(y * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{\left(t - z\right) \cdot y}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+69}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+34}:\\
\;\;\;\;x - y \cdot \frac{z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000036e69 or 1.99999999999999989e34 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.3%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
negate-sub2N/A
lower-*.f64N/A
lower--.f6479.2
Applied rewrites79.2%
if -5.00000000000000036e69 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e34Initial program 99.0%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (/ (* (- t z) y) a))) (if (<= t_1 -4e+53) t_2 (if (<= t_1 5e-35) (fma (/ t a) y x) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = ((t - z) * y) / a;
double tmp;
if (t_1 <= -4e+53) {
tmp = t_2;
} else if (t_1 <= 5e-35) {
tmp = fma((t / a), y, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(Float64(t - z) * y) / a) tmp = 0.0 if (t_1 <= -4e+53) tmp = t_2; elseif (t_1 <= 5e-35) tmp = fma(Float64(t / a), y, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t - z), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+53], t$95$2, If[LessEqual[t$95$1, 5e-35], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{\left(t - z\right) \cdot y}{a}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+53}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -4e53 or 4.99999999999999964e-35 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 90.1%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
negate-sub2N/A
lower-*.f64N/A
lower--.f6477.2
Applied rewrites77.2%
if -4e53 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.99999999999999964e-35Initial program 98.9%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lower--.f64N/A
negate-subN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
div-subN/A
negate-sub2N/A
+-commutativeN/A
negate-sub2N/A
div-subN/A
mul-1-negN/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r/N/A
mul-1-negN/A
negate-sub2N/A
lower-/.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in z around 0
Applied rewrites88.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.9e+228) (/ (* (- y) z) a) (if (<= z 6e+174) (fma t (/ y a) x) (* (- y) (/ z a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+228) {
tmp = (-y * z) / a;
} else if (z <= 6e+174) {
tmp = fma(t, (y / a), x);
} else {
tmp = -y * (z / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+228) tmp = Float64(Float64(Float64(-y) * z) / a); elseif (z <= 6e+174) tmp = fma(t, Float64(y / a), x); else tmp = Float64(Float64(-y) * Float64(z / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+228], N[(N[((-y) * z), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[z, 6e+174], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[((-y) * N[(z / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+228}:\\
\;\;\;\;\frac{\left(-y\right) \cdot z}{a}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+174}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) \cdot \frac{z}{a}\\
\end{array}
\end{array}
if z < -1.9000000000000001e228Initial program 88.8%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6486.2
Applied rewrites86.2%
Taylor expanded in z around inf
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f6467.5
Applied rewrites67.5%
if -1.9000000000000001e228 < z < 6e174Initial program 94.3%
Taylor expanded in z around 0
negate-subN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6478.1
Applied rewrites78.1%
if 6e174 < z Initial program 90.0%
Taylor expanded in z around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6462.0
Applied rewrites62.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a))) (if (<= t_1 -4e+53) (* (- y) (/ z a)) (if (<= t_1 2e+34) x (* (/ y a) t)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -4e+53) {
tmp = -y * (z / a);
} else if (t_1 <= 2e+34) {
tmp = x;
} else {
tmp = (y / a) * t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (y * (z - t)) / a
if (t_1 <= (-4d+53)) then
tmp = -y * (z / a)
else if (t_1 <= 2d+34) then
tmp = x
else
tmp = (y / a) * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -4e+53) {
tmp = -y * (z / a);
} else if (t_1 <= 2e+34) {
tmp = x;
} else {
tmp = (y / a) * t;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a tmp = 0 if t_1 <= -4e+53: tmp = -y * (z / a) elif t_1 <= 2e+34: tmp = x else: tmp = (y / a) * t return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -4e+53) tmp = Float64(Float64(-y) * Float64(z / a)); elseif (t_1 <= 2e+34) tmp = x; else tmp = Float64(Float64(y / a) * t); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; tmp = 0.0; if (t_1 <= -4e+53) tmp = -y * (z / a); elseif (t_1 <= 2e+34) tmp = x; else tmp = (y / a) * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+53], N[((-y) * N[(z / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+34], x, N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+53}:\\
\;\;\;\;\left(-y\right) \cdot \frac{z}{a}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot t\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -4e53Initial program 88.7%
Taylor expanded in z around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6445.1
Applied rewrites45.1%
if -4e53 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e34Initial program 99.0%
Taylor expanded in x around inf
Applied rewrites74.6%
if 1.99999999999999989e34 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 90.2%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6488.8
Applied rewrites88.8%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6445.8
Applied rewrites45.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6450.5
Applied rewrites50.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) t))) (if (<= t_1 -5e+69) t_2 (if (<= t_1 2e+34) x t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y / a) * t;
double tmp;
if (t_1 <= -5e+69) {
tmp = t_2;
} else if (t_1 <= 2e+34) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = (y / a) * t
if (t_1 <= (-5d+69)) then
tmp = t_2
else if (t_1 <= 2d+34) then
tmp = x
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y / a) * t;
double tmp;
if (t_1 <= -5e+69) {
tmp = t_2;
} else if (t_1 <= 2e+34) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = (y / a) * t tmp = 0 if t_1 <= -5e+69: tmp = t_2 elif t_1 <= 2e+34: tmp = x else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(y / a) * t) tmp = 0.0 if (t_1 <= -5e+69) tmp = t_2; elseif (t_1 <= 2e+34) tmp = x; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = (y / a) * t; tmp = 0.0; if (t_1 <= -5e+69) tmp = t_2; elseif (t_1 <= 2e+34) tmp = x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+69], t$95$2, If[LessEqual[t$95$1, 2e+34], x, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{y}{a} \cdot t\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+69}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000036e69 or 1.99999999999999989e34 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.3%
lift-*.f64N/A
lift--.f64N/A
negate-subN/A
mul-1-negN/A
distribute-rgt-inN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6487.9
Applied rewrites87.9%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6444.7
Applied rewrites44.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6449.7
Applied rewrites49.7%
if -5.00000000000000036e69 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e34Initial program 99.0%
Taylor expanded in x around inf
Applied rewrites74.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (/ (* t y) a))) (if (<= t_1 -5e+69) t_2 (if (<= t_1 2e+34) x t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (t * y) / a;
double tmp;
if (t_1 <= -5e+69) {
tmp = t_2;
} else if (t_1 <= 2e+34) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = (t * y) / a
if (t_1 <= (-5d+69)) then
tmp = t_2
else if (t_1 <= 2d+34) then
tmp = x
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (t * y) / a;
double tmp;
if (t_1 <= -5e+69) {
tmp = t_2;
} else if (t_1 <= 2e+34) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = (t * y) / a tmp = 0 if t_1 <= -5e+69: tmp = t_2 elif t_1 <= 2e+34: tmp = x else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(t * y) / a) tmp = 0.0 if (t_1 <= -5e+69) tmp = t_2; elseif (t_1 <= 2e+34) tmp = x; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = (t * y) / a; tmp = 0.0; if (t_1 <= -5e+69) tmp = t_2; elseif (t_1 <= 2e+34) tmp = x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+69], t$95$2, If[LessEqual[t$95$1, 2e+34], x, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{t \cdot y}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+69}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000036e69 or 1.99999999999999989e34 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.3%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6444.7
Applied rewrites44.7%
if -5.00000000000000036e69 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e34Initial program 99.0%
Taylor expanded in x around inf
Applied rewrites74.1%
(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 93.5%
Taylor expanded in x around inf
Applied rewrites39.5%
herbie shell --seed 2025110
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
:precision binary64
(- x (/ (* y (- z t)) a)))