
(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 10 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) (/ y a) x))) (if (<= t_1 -1e+239) t_2 (if (<= t_1 5e+121) (- 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), (y / a), x);
double tmp;
if (t_1 <= -1e+239) {
tmp = t_2;
} else if (t_1 <= 5e+121) {
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(t - z), Float64(y / a), x) tmp = 0.0 if (t_1 <= -1e+239) tmp = t_2; elseif (t_1 <= 5e+121) 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[(t - z), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+239], t$95$2, If[LessEqual[t$95$1, 5e+121], 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(t - z, \frac{y}{a}, x\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+239}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+121}:\\
\;\;\;\;x - \frac{t\_1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 y (-.f64 z t)) < -9.99999999999999991e238 or 5.00000000000000007e121 < (*.f64 y (-.f64 z t)) Initial program 93.4%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
div-subN/A
sub-negate-revN/A
+-commutativeN/A
sub-negate-revN/A
div-subN/A
distribute-rgt-neg-outN/A
associate-/l*N/A
mult-flipN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites93.3%
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-*l*N/A
mult-flipN/A
lower-fma.f64N/A
lift--.f64N/A
lift-/.f6496.9
Applied rewrites96.9%
if -9.99999999999999991e238 < (*.f64 y (-.f64 z t)) < 5.00000000000000007e121Initial program 93.4%
(FPCore (x y z t a) :precision binary64 (fma (- t z) (/ y a) x))
double code(double x, double y, double z, double t, double a) {
return fma((t - z), (y / a), x);
}
function code(x, y, z, t, a) return fma(Float64(t - z), Float64(y / a), x) end
code[x_, y_, z_, t_, a_] := N[(N[(t - z), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(t - z, \frac{y}{a}, x\right)
\end{array}
Initial program 93.4%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
div-subN/A
sub-negate-revN/A
+-commutativeN/A
sub-negate-revN/A
div-subN/A
distribute-rgt-neg-outN/A
associate-/l*N/A
mult-flipN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites93.3%
lift-/.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-*l*N/A
mult-flipN/A
lower-fma.f64N/A
lift--.f64N/A
lift-/.f6496.9
Applied rewrites96.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ (- t z) a) y)))
(if (<= t_1 -1e+193)
t_2
(if (<= t_1 5e+196)
(- x (/ (* z y) a))
(if (<= t_1 4e+306) (/ (* (- t z) y) 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) / a) * y;
double tmp;
if (t_1 <= -1e+193) {
tmp = t_2;
} else if (t_1 <= 5e+196) {
tmp = x - ((z * y) / a);
} else if (t_1 <= 4e+306) {
tmp = ((t - z) * y) / 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) / a) * y
if (t_1 <= (-1d+193)) then
tmp = t_2
else if (t_1 <= 5d+196) then
tmp = x - ((z * y) / a)
else if (t_1 <= 4d+306) then
tmp = ((t - z) * y) / 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) / a) * y;
double tmp;
if (t_1 <= -1e+193) {
tmp = t_2;
} else if (t_1 <= 5e+196) {
tmp = x - ((z * y) / a);
} else if (t_1 <= 4e+306) {
tmp = ((t - z) * y) / a;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = ((t - z) / a) * y tmp = 0 if t_1 <= -1e+193: tmp = t_2 elif t_1 <= 5e+196: tmp = x - ((z * y) / a) elif t_1 <= 4e+306: tmp = ((t - z) * y) / 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) / a) * y) tmp = 0.0 if (t_1 <= -1e+193) tmp = t_2; elseif (t_1 <= 5e+196) tmp = Float64(x - Float64(Float64(z * y) / a)); elseif (t_1 <= 4e+306) tmp = Float64(Float64(Float64(t - z) * y) / 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) / a) * y; tmp = 0.0; if (t_1 <= -1e+193) tmp = t_2; elseif (t_1 <= 5e+196) tmp = x - ((z * y) / a); elseif (t_1 <= 4e+306) tmp = ((t - z) * y) / 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] / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+193], t$95$2, If[LessEqual[t$95$1, 5e+196], N[(x - N[(N[(z * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+306], N[(N[(N[(t - z), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{t - z}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+193}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+196}:\\
\;\;\;\;x - \frac{z \cdot y}{a}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+306}:\\
\;\;\;\;\frac{\left(t - z\right) \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000007e193 or 4.00000000000000007e306 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.4%
Taylor expanded in x around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
div-subN/A
sub-negate-revN/A
sub-negate-revN/A
div-subN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-fracN/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f6456.7
Applied rewrites56.7%
if -1.00000000000000007e193 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.9999999999999998e196Initial program 93.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6468.6
Applied rewrites68.6%
if 4.9999999999999998e196 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.00000000000000007e306Initial program 93.4%
Taylor expanded in a around 0
lower-/.f64N/A
sub-flipN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in x around 0
*-commutativeN/A
lift--.f64N/A
lift-*.f6456.7
Applied rewrites56.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ (- t z) a) y)))
(if (<= t_1 -4e+117)
t_2
(if (<= t_1 1e+98)
(fma (/ t a) y x)
(if (<= t_1 4e+306) (/ (* (- t z) y) 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) / a) * y;
double tmp;
if (t_1 <= -4e+117) {
tmp = t_2;
} else if (t_1 <= 1e+98) {
tmp = fma((t / a), y, x);
} else if (t_1 <= 4e+306) {
tmp = ((t - z) * y) / 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) / a) * y) tmp = 0.0 if (t_1 <= -4e+117) tmp = t_2; elseif (t_1 <= 1e+98) tmp = fma(Float64(t / a), y, x); elseif (t_1 <= 4e+306) tmp = Float64(Float64(Float64(t - z) * y) / a); 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] / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+117], t$95$2, If[LessEqual[t$95$1, 1e+98], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 4e+306], N[(N[(N[(t - z), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{t - z}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+306}:\\
\;\;\;\;\frac{\left(t - z\right) \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -4.0000000000000002e117 or 4.00000000000000007e306 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.4%
Taylor expanded in x around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
div-subN/A
sub-negate-revN/A
sub-negate-revN/A
div-subN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-fracN/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f6456.7
Applied rewrites56.7%
if -4.0000000000000002e117 < (/.f64 (*.f64 y (-.f64 z t)) a) < 9.99999999999999998e97Initial program 93.4%
Taylor expanded in z around 0
mul-1-negN/A
add-flipN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6471.0
Applied rewrites71.0%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6468.0
Applied rewrites68.0%
if 9.99999999999999998e97 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.00000000000000007e306Initial program 93.4%
Taylor expanded in a around 0
lower-/.f64N/A
sub-flipN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in x around 0
*-commutativeN/A
lift--.f64N/A
lift-*.f6456.7
Applied rewrites56.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ (- t z) a) y))) (if (<= t_1 -4e+117) t_2 (if (<= t_1 1e+98) (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) / a) * y;
double tmp;
if (t_1 <= -4e+117) {
tmp = t_2;
} else if (t_1 <= 1e+98) {
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) / a) * y) tmp = 0.0 if (t_1 <= -4e+117) tmp = t_2; elseif (t_1 <= 1e+98) 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] / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+117], t$95$2, If[LessEqual[t$95$1, 1e+98], 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{t - z}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+117}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+98}:\\
\;\;\;\;\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) < -4.0000000000000002e117 or 9.99999999999999998e97 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.4%
Taylor expanded in x around 0
mul-1-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
div-subN/A
sub-negate-revN/A
sub-negate-revN/A
div-subN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
distribute-neg-fracN/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f6456.7
Applied rewrites56.7%
if -4.0000000000000002e117 < (/.f64 (*.f64 y (-.f64 z t)) a) < 9.99999999999999998e97Initial program 93.4%
Taylor expanded in z around 0
mul-1-negN/A
add-flipN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6471.0
Applied rewrites71.0%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6468.0
Applied rewrites68.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.9e+194) (* (- z) (/ y a)) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e+194) {
tmp = -z * (y / a);
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e+194) tmp = Float64(Float64(-z) * Float64(y / a)); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e+194], N[((-z) * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+194}:\\
\;\;\;\;\left(-z\right) \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
\end{array}
if z < -1.8999999999999999e194Initial program 93.4%
Taylor expanded in z around inf
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6434.2
Applied rewrites34.2%
if -1.8999999999999999e194 < z Initial program 93.4%
Taylor expanded in z around 0
mul-1-negN/A
add-flipN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6471.0
Applied rewrites71.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -7.2e+193) (* (- z) (/ y a)) (fma (/ t a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -7.2e+193) {
tmp = -z * (y / a);
} else {
tmp = fma((t / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -7.2e+193) tmp = Float64(Float64(-z) * Float64(y / a)); else tmp = fma(Float64(t / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -7.2e+193], N[((-z) * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.2 \cdot 10^{+193}:\\
\;\;\;\;\left(-z\right) \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\end{array}
\end{array}
if z < -7.2e193Initial program 93.4%
Taylor expanded in z around inf
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f6434.2
Applied rewrites34.2%
if -7.2e193 < z Initial program 93.4%
Taylor expanded in z around 0
mul-1-negN/A
add-flipN/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f6471.0
Applied rewrites71.0%
lift-/.f64N/A
lift-fma.f64N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6468.0
Applied rewrites68.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) t))) (if (<= t_1 -1e+193) t_2 (if (<= t_1 5e+196) (/ (* x a) 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 = (y / a) * t;
double tmp;
if (t_1 <= -1e+193) {
tmp = t_2;
} else if (t_1 <= 5e+196) {
tmp = (x * a) / 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 = (y / a) * t
if (t_1 <= (-1d+193)) then
tmp = t_2
else if (t_1 <= 5d+196) then
tmp = (x * a) / 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 = (y / a) * t;
double tmp;
if (t_1 <= -1e+193) {
tmp = t_2;
} else if (t_1 <= 5e+196) {
tmp = (x * a) / a;
} 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+193: tmp = t_2 elif t_1 <= 5e+196: tmp = (x * a) / 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(y / a) * t) tmp = 0.0 if (t_1 <= -1e+193) tmp = t_2; elseif (t_1 <= 5e+196) tmp = Float64(Float64(x * a) / 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 = (y / a) * t; tmp = 0.0; if (t_1 <= -1e+193) tmp = t_2; elseif (t_1 <= 5e+196) tmp = (x * a) / 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[(y / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+193], t$95$2, If[LessEqual[t$95$1, 5e+196], N[(N[(x * a), $MachinePrecision] / a), $MachinePrecision], 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^{+193}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+196}:\\
\;\;\;\;\frac{x \cdot a}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.00000000000000007e193 or 4.9999999999999998e196 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.4%
Taylor expanded in t around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6431.3
Applied rewrites31.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6433.6
Applied rewrites33.6%
if -1.00000000000000007e193 < (/.f64 (*.f64 y (-.f64 z t)) a) < 4.9999999999999998e196Initial program 93.4%
Taylor expanded in a around 0
lower-/.f64N/A
sub-flipN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
sub-negate-revN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in x around 0
*-commutativeN/A
lift--.f64N/A
lift-*.f6456.7
Applied rewrites56.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6429.3
Applied rewrites29.3%
(FPCore (x y z t a) :precision binary64 (* (/ y a) t))
double code(double x, double y, double z, double t, double a) {
return (y / a) * t;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (y / a) * t
end function
public static double code(double x, double y, double z, double t, double a) {
return (y / a) * t;
}
def code(x, y, z, t, a): return (y / a) * t
function code(x, y, z, t, a) return Float64(Float64(y / a) * t) end
function tmp = code(x, y, z, t, a) tmp = (y / a) * t; end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{a} \cdot t
\end{array}
Initial program 93.4%
Taylor expanded in t around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6431.3
Applied rewrites31.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6433.6
Applied rewrites33.6%
(FPCore (x y z t a) :precision binary64 (* y (/ t a)))
double code(double x, double y, double z, double t, double a) {
return y * (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 = y * (t / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return y * (t / a);
}
def code(x, y, z, t, a): return y * (t / a)
function code(x, y, z, t, a) return Float64(y * Float64(t / a)) end
function tmp = code(x, y, z, t, a) tmp = y * (t / a); end
code[x_, y_, z_, t_, a_] := N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{t}{a}
\end{array}
Initial program 93.4%
Taylor expanded in t around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6431.3
Applied rewrites31.3%
herbie shell --seed 2025132
(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)))