
(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 12 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))))
(if (<= t_1 -1e+203)
(fma (/ (- t z) a) y x)
(if (<= t_1 1e+120) (- x (/ t_1 a)) (fma (/ y a) (- t z) x)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y * (z - t);
double tmp;
if (t_1 <= -1e+203) {
tmp = fma(((t - z) / a), y, x);
} else if (t_1 <= 1e+120) {
tmp = x - (t_1 / a);
} else {
tmp = fma((y / a), (t - z), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(y * Float64(z - t)) tmp = 0.0 if (t_1 <= -1e+203) tmp = fma(Float64(Float64(t - z) / a), y, x); elseif (t_1 <= 1e+120) tmp = Float64(x - Float64(t_1 / a)); else tmp = fma(Float64(y / a), Float64(t - z), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+203], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 1e+120], N[(x - N[(t$95$1 / a), $MachinePrecision]), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+203}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+120}:\\
\;\;\;\;x - \frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -9.9999999999999999e202Initial program 81.0%
Applied rewrites99.1%
if -9.9999999999999999e202 < (*.f64 y (-.f64 z t)) < 9.9999999999999998e119Initial program 99.4%
if 9.9999999999999998e119 < (*.f64 y (-.f64 z t)) Initial program 88.2%
Applied rewrites98.8%
(FPCore (x y z t a) :precision binary64 (if (<= (- x (/ (* y (- z t)) a)) 1e-19) (fma (/ (- t z) a) y x) (fma (/ y a) (- t z) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x - ((y * (z - t)) / a)) <= 1e-19) {
tmp = fma(((t - z) / a), y, x);
} else {
tmp = fma((y / a), (t - z), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(x - Float64(Float64(y * Float64(z - t)) / a)) <= 1e-19) tmp = fma(Float64(Float64(t - z) / a), y, x); else tmp = fma(Float64(y / a), Float64(t - z), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], 1e-19], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x - \frac{y \cdot \left(z - t\right)}{a} \leq 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\
\end{array}
\end{array}
if (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < 9.9999999999999998e-20Initial program 94.0%
Applied rewrites94.3%
if 9.9999999999999998e-20 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) Initial program 92.9%
Applied rewrites98.5%
(FPCore (x y z t a) :precision binary64 (fma (/ y a) (- t z) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / a), (t - z), x);
}
function code(x, y, z, t, a) return fma(Float64(y / a), Float64(t - z), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)
\end{array}
Initial program 93.5%
Applied rewrites97.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)))
(if (<= t_1 -5e+114)
(* (- t z) (/ y a))
(if (<= t_1 10000.0)
(- x (/ (* y z) a))
(if (<= t_1 2e+183) (fma (/ y a) t x) (* (/ (- t z) a) y))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -5e+114) {
tmp = (t - z) * (y / a);
} else if (t_1 <= 10000.0) {
tmp = x - ((y * z) / a);
} else if (t_1 <= 2e+183) {
tmp = fma((y / a), t, x);
} else {
tmp = ((t - z) / a) * y;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -5e+114) tmp = Float64(Float64(t - z) * Float64(y / a)); elseif (t_1 <= 10000.0) tmp = Float64(x - Float64(Float64(y * z) / a)); elseif (t_1 <= 2e+183) tmp = fma(Float64(y / a), t, x); else tmp = Float64(Float64(Float64(t - z) / a) * y); end return 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, -5e+114], N[(N[(t - z), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 10000.0], N[(x - N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+183], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+114}:\\
\;\;\;\;\left(t - z\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;t\_1 \leq 10000:\\
\;\;\;\;x - \frac{y \cdot z}{a}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+183}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t - z}{a} \cdot y\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.0000000000000001e114Initial program 87.9%
Taylor expanded in x around 0
Applied rewrites89.7%
if -5.0000000000000001e114 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1e4Initial program 99.2%
Taylor expanded in z around inf
Applied rewrites85.5%
if 1e4 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e183Initial program 99.7%
Applied rewrites97.8%
Taylor expanded in z around 0
Applied rewrites63.7%
if 1.99999999999999989e183 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 85.1%
Applied rewrites97.2%
Taylor expanded in x around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6488.4
Applied rewrites88.4%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)))
(if (<= t_1 -1e+98)
(* (- t z) (/ y a))
(if (<= t_1 2e+183) (fma y (/ t a) x) (* (/ (- t z) a) y)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -1e+98) {
tmp = (t - z) * (y / a);
} else if (t_1 <= 2e+183) {
tmp = fma(y, (t / a), x);
} else {
tmp = ((t - z) / a) * y;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -1e+98) tmp = Float64(Float64(t - z) * Float64(y / a)); elseif (t_1 <= 2e+183) tmp = fma(y, Float64(t / a), x); else tmp = Float64(Float64(Float64(t - z) / a) * y); end return 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, -1e+98], N[(N[(t - z), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+183], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+98}:\\
\;\;\;\;\left(t - z\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+183}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t - z}{a} \cdot y\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -9.99999999999999998e97Initial program 88.3%
Taylor expanded in x around 0
Applied rewrites88.9%
if -9.99999999999999998e97 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e183Initial program 99.3%
Taylor expanded in z around 0
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
fp-cancel-sign-sub-invN/A
associate-/l*N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.5
Applied rewrites80.5%
if 1.99999999999999989e183 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 85.1%
Applied rewrites97.2%
Taylor expanded in x around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6488.4
Applied rewrites88.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ (- t z) a) y)) (t_2 (/ (* y (- z t)) a))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+183) (fma (/ y a) t x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((t - z) / a) * y;
double t_2 = (y * (z - t)) / a;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+183) {
tmp = fma((y / a), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(t - z) / a) * y) t_2 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+183) tmp = fma(Float64(y / a), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+183], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - z}{a} \cdot y\\
t_2 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+183}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0 or 1.99999999999999989e183 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 83.6%
Applied rewrites98.4%
Taylor expanded in x around 0
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6491.6
Applied rewrites91.6%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.99999999999999989e183Initial program 99.4%
Applied rewrites96.9%
Taylor expanded in z around 0
Applied rewrites77.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.2e+231) (* (/ (- z) a) y) (if (<= z 2.55e+98) (fma (/ y a) t x) (* (- z) (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.2e+231) {
tmp = (-z / a) * y;
} else if (z <= 2.55e+98) {
tmp = fma((y / a), t, x);
} else {
tmp = -z * (y / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.2e+231) tmp = Float64(Float64(Float64(-z) / a) * y); elseif (z <= 2.55e+98) tmp = fma(Float64(y / a), t, x); else tmp = Float64(Float64(-z) * Float64(y / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.2e+231], N[(N[((-z) / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 2.55e+98], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[((-z) * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+231}:\\
\;\;\;\;\frac{-z}{a} \cdot y\\
\mathbf{elif}\;z \leq 2.55 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -2.19999999999999992e231Initial program 90.3%
Taylor expanded in z around inf
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
distribute-neg-frac2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6468.1
Applied rewrites68.1%
if -2.19999999999999992e231 < z < 2.54999999999999994e98Initial program 94.6%
Applied rewrites97.3%
Taylor expanded in z around 0
Applied rewrites79.9%
if 2.54999999999999994e98 < z Initial program 89.4%
Taylor expanded in x around 0
Applied rewrites75.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6464.9
Applied rewrites64.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.9e+223) (* (/ (- z) a) y) (if (<= z 2.55e+98) (fma y (/ t a) x) (* (- z) (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+223) {
tmp = (-z / a) * y;
} else if (z <= 2.55e+98) {
tmp = fma(y, (t / a), x);
} else {
tmp = -z * (y / a);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+223) tmp = Float64(Float64(Float64(-z) / a) * y); elseif (z <= 2.55e+98) tmp = fma(y, Float64(t / a), x); else tmp = Float64(Float64(-z) * Float64(y / a)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+223], N[(N[((-z) / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 2.55e+98], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[((-z) * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+223}:\\
\;\;\;\;\frac{-z}{a} \cdot y\\
\mathbf{elif}\;z \leq 2.55 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-z\right) \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -1.9e223Initial program 90.5%
Taylor expanded in z around inf
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
distribute-neg-frac2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6466.9
Applied rewrites66.9%
if -1.9e223 < z < 2.54999999999999994e98Initial program 94.7%
Taylor expanded in z around 0
mul-1-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
fp-cancel-sign-sub-invN/A
associate-/l*N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6477.0
Applied rewrites77.0%
if 2.54999999999999994e98 < z Initial program 89.4%
Taylor expanded in x around 0
Applied rewrites75.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6464.9
Applied rewrites64.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)))
(if (<= t_1 -1e+98)
(* (- z) (/ y a))
(if (<= t_1 500000.0) 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 <= -1e+98) {
tmp = -z * (y / a);
} else if (t_1 <= 500000.0) {
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 <= (-1d+98)) then
tmp = -z * (y / a)
else if (t_1 <= 500000.0d0) 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 <= -1e+98) {
tmp = -z * (y / a);
} else if (t_1 <= 500000.0) {
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 <= -1e+98: tmp = -z * (y / a) elif t_1 <= 500000.0: 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 <= -1e+98) tmp = Float64(Float64(-z) * Float64(y / a)); elseif (t_1 <= 500000.0) 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 <= -1e+98) tmp = -z * (y / a); elseif (t_1 <= 500000.0) 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, -1e+98], N[((-z) * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 500000.0], 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 -1 \cdot 10^{+98}:\\
\;\;\;\;\left(-z\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;t\_1 \leq 500000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot t\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -9.99999999999999998e97Initial program 88.3%
Taylor expanded in x around 0
Applied rewrites88.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6450.8
Applied rewrites50.8%
if -9.99999999999999998e97 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5e5Initial program 99.2%
Taylor expanded in x around inf
Applied rewrites73.6%
if 5e5 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.9%
Taylor expanded in t around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6442.2
Applied rewrites42.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6446.6
Applied rewrites46.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) t))) (if (<= t_1 -1e+98) t_2 (if (<= t_1 500000.0) 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 <= -1e+98) {
tmp = t_2;
} else if (t_1 <= 500000.0) {
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 <= (-1d+98)) then
tmp = t_2
else if (t_1 <= 500000.0d0) 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 <= -1e+98) {
tmp = t_2;
} else if (t_1 <= 500000.0) {
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 <= -1e+98: tmp = t_2 elif t_1 <= 500000.0: 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 <= -1e+98) tmp = t_2; elseif (t_1 <= 500000.0) 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 <= -1e+98) tmp = t_2; elseif (t_1 <= 500000.0) 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, -1e+98], t$95$2, If[LessEqual[t$95$1, 500000.0], 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 -1 \cdot 10^{+98}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 500000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -9.99999999999999998e97 or 5e5 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.2%
Taylor expanded in t around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6444.7
Applied rewrites44.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6449.8
Applied rewrites49.8%
if -9.99999999999999998e97 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5e5Initial program 99.2%
Taylor expanded in x around inf
Applied rewrites73.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* y (/ t a)))) (if (<= t_1 -1e+98) t_2 (if (<= t_1 500000.0) 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 * (t / a);
double tmp;
if (t_1 <= -1e+98) {
tmp = t_2;
} else if (t_1 <= 500000.0) {
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 * (t / a)
if (t_1 <= (-1d+98)) then
tmp = t_2
else if (t_1 <= 500000.0d0) 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 * (t / a);
double tmp;
if (t_1 <= -1e+98) {
tmp = t_2;
} else if (t_1 <= 500000.0) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = y * (t / a) tmp = 0 if t_1 <= -1e+98: tmp = t_2 elif t_1 <= 500000.0: 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(y * Float64(t / a)) tmp = 0.0 if (t_1 <= -1e+98) tmp = t_2; elseif (t_1 <= 500000.0) 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 * (t / a); tmp = 0.0; if (t_1 <= -1e+98) tmp = t_2; elseif (t_1 <= 500000.0) 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[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+98], t$95$2, If[LessEqual[t$95$1, 500000.0], x, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := y \cdot \frac{t}{a}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+98}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 500000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -9.99999999999999998e97 or 5e5 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 89.2%
Taylor expanded in t around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6444.7
Applied rewrites44.7%
if -9.99999999999999998e97 < (/.f64 (*.f64 y (-.f64 z t)) a) < 5e5Initial program 99.2%
Taylor expanded in x around inf
Applied rewrites73.6%
(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.2%
herbie shell --seed 2025130
(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)))