
(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]
x - \frac{y \cdot \left(z - t\right)}{a}
Herbie found 11 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]
x - \frac{y \cdot \left(z - t\right)}{a}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- x (/ (* y (- z t)) a))))
(if (<= t_1 (- INFINITY))
(fma (/ 1.0 (/ a y)) (- t z) x)
(if (<= t_1 2e+62)
(- x (/ 1.0 (/ a (* (- z t) y))))
(fma (/ y a) (- t z) x)))))double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((y * (z - t)) / a);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((1.0 / (a / y)), (t - z), x);
} else if (t_1 <= 2e+62) {
tmp = x - (1.0 / (a / ((z - t) * y)));
} else {
tmp = fma((y / a), (t - z), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(y * Float64(z - t)) / a)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(1.0 / Float64(a / y)), Float64(t - z), x); elseif (t_1 <= 2e+62) tmp = Float64(x - Float64(1.0 / Float64(a / Float64(Float64(z - t) * y)))); 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[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(1.0 / N[(a / y), $MachinePrecision]), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 2e+62], N[(x - N[(1.0 / N[(a / N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
t_1 := x - \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a}{y}}, t - z, x\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+62}:\\
\;\;\;\;x - \frac{1}{\frac{a}{\left(z - t\right) \cdot y}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\
\end{array}
if (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < -inf.0Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6497.3%
Applied rewrites97.3%
if -inf.0 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < 2.0000000000000001e62Initial program 93.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6493.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6493.1%
Applied rewrites93.1%
if 2.0000000000000001e62 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- x (/ (* y (- z t)) a))))
(if (<= t_1 (- INFINITY))
(fma (/ 1.0 (/ a y)) (- t z) x)
(if (<= t_1 5e-153) t_1 (fma (/ y a) (- t z) x)))))double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((y * (z - t)) / a);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((1.0 / (a / y)), (t - z), x);
} else if (t_1 <= 5e-153) {
tmp = t_1;
} else {
tmp = fma((y / a), (t - z), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(y * Float64(z - t)) / a)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = fma(Float64(1.0 / Float64(a / y)), Float64(t - z), x); elseif (t_1 <= 5e-153) tmp = t_1; 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[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(1.0 / N[(a / y), $MachinePrecision]), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 5e-153], t$95$1, N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
t_1 := x - \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a}{y}}, t - z, x\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-153}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\
\end{array}
if (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < -inf.0Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6497.3%
Applied rewrites97.3%
if -inf.0 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < 5.0000000000000003e-153Initial program 93.2%
if 5.0000000000000003e-153 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- x (/ (* y (- z t)) a))))
(if (<= t_1 -5e+303)
(fma (/ (- t z) a) y x)
(if (<= t_1 5e-153) t_1 (fma (/ y a) (- t z) x)))))double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((y * (z - t)) / a);
double tmp;
if (t_1 <= -5e+303) {
tmp = fma(((t - z) / a), y, x);
} else if (t_1 <= 5e-153) {
tmp = t_1;
} else {
tmp = fma((y / a), (t - z), x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(y * Float64(z - t)) / a)) tmp = 0.0 if (t_1 <= -5e+303) tmp = fma(Float64(Float64(t - z) / a), y, x); elseif (t_1 <= 5e-153) tmp = t_1; 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[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+303], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 5e-153], t$95$1, N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
t_1 := x - \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+303}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-153}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)\\
\end{array}
if (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < -4.9999999999999997e303Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f6493.1%
Applied rewrites93.1%
if -4.9999999999999997e303 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) < 5.0000000000000003e-153Initial program 93.2%
if 5.0000000000000003e-153 < (-.f64 x (/.f64 (*.f64 y (-.f64 z t)) a)) Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.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]
\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)
Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
(FPCore (x y z t a) :precision binary64 (if (<= t 1.56e+139) (fma (/ (- t z) a) y x) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 1.56e+139) {
tmp = fma(((t - z) / a), y, x);
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= 1.56e+139) tmp = fma(Float64(Float64(t - z) / a), y, x); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 1.56e+139], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;t \leq 1.56 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
if t < 1.5599999999999999e139Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f6493.1%
Applied rewrites93.1%
if 1.5599999999999999e139 < t Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in z around 0
Applied rewrites71.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) (- t z)))) (if (<= t_1 -5e+84) t_2 (if (<= t_1 2e+126) (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 = (y / a) * (t - z);
double tmp;
if (t_1 <= -5e+84) {
tmp = t_2;
} else if (t_1 <= 2e+126) {
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(y / a) * Float64(t - z)) tmp = 0.0 if (t_1 <= -5e+84) tmp = t_2; elseif (t_1 <= 2e+126) 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[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+84], t$95$2, If[LessEqual[t$95$1, 2e+126], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{y}{a} \cdot \left(t - z\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+84}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+126}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.0000000000000001e84 or 1.9999999999999998e126 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f6457.5%
Applied rewrites57.5%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6461.0%
Applied rewrites61.0%
if -5.0000000000000001e84 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.9999999999999998e126Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in z around 0
Applied rewrites71.2%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6468.0%
Applied rewrites68.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- t z)) a)) (t_2 (/ (* y (- z t)) a)))
(if (<= t_2 (- INFINITY))
(* (/ (- t z) a) y)
(if (<= t_2 -5e+84) t_1 (if (<= t_2 2e+126) (fma (/ t a) y x) t_1)))))double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (t - z)) / a;
double t_2 = (y * (z - t)) / a;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = ((t - z) / a) * y;
} else if (t_2 <= -5e+84) {
tmp = t_1;
} else if (t_2 <= 2e+126) {
tmp = fma((t / a), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(t - z)) / a) t_2 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(t - z) / a) * y); elseif (t_2 <= -5e+84) tmp = t_1; elseif (t_2 <= 2e+126) tmp = fma(Float64(t / a), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$2, -5e+84], t$95$1, If[LessEqual[t$95$2, 2e+126], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_1 := \frac{y \cdot \left(t - z\right)}{a}\\
t_2 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\frac{t - z}{a} \cdot y\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+84}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+126}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -inf.0Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f6457.5%
Applied rewrites57.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6457.6%
Applied rewrites57.6%
if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) a) < -5.0000000000000001e84 or 1.9999999999999998e126 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f6457.5%
Applied rewrites57.5%
if -5.0000000000000001e84 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1.9999999999999998e126Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in z around 0
Applied rewrites71.2%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6468.0%
Applied rewrites68.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ (- t z) a) y))) (if (<= t_1 -5e+275) t_2 (if (<= t_1 2e+236) (fma (/ y a) t 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 <= -5e+275) {
tmp = t_2;
} else if (t_1 <= 2e+236) {
tmp = fma((y / a), t, 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 <= -5e+275) tmp = t_2; elseif (t_1 <= 2e+236) tmp = fma(Float64(y / a), t, 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, -5e+275], t$95$2, If[LessEqual[t$95$1, 2e+236], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$2]]]]
\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 -5 \cdot 10^{+275}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+236}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.0000000000000003e275 or 2.0000000000000001e236 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f6457.5%
Applied rewrites57.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6457.6%
Applied rewrites57.6%
if -5.0000000000000003e275 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2.0000000000000001e236Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in z around 0
Applied rewrites71.2%
(FPCore (x y z t a) :precision binary64 (fma (/ y a) t x))
double code(double x, double y, double z, double t, double a) {
return fma((y / a), t, x);
}
function code(x, y, z, t, a) return fma(Float64(y / a), t, x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]
\mathsf{fma}\left(\frac{y}{a}, t, x\right)
Initial program 93.2%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.5%
Applied rewrites97.5%
Taylor expanded in z around 0
Applied rewrites71.2%
(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]
\frac{y}{a} \cdot t
Initial program 93.2%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6432.4%
Applied rewrites32.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6435.2%
Applied rewrites35.2%
(FPCore (x y z t a) :precision binary64 (* (/ t a) y))
double code(double x, double y, double z, double t, double a) {
return (t / a) * y;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
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 = (t / a) * y
end function
public static double code(double x, double y, double z, double t, double a) {
return (t / a) * y;
}
def code(x, y, z, t, a): return (t / a) * y
function code(x, y, z, t, a) return Float64(Float64(t / a) * y) end
function tmp = code(x, y, z, t, a) tmp = (t / a) * y; end
code[x_, y_, z_, t_, a_] := N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision]
\frac{t}{a} \cdot y
Initial program 93.2%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6432.4%
Applied rewrites32.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6432.5%
Applied rewrites32.5%
herbie shell --seed 2025204
(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)))