
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= x 3e-131) (fma (/ (- z x) t) y x) (fma (- z x) (/ y t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 3e-131) {
tmp = fma(((z - x) / t), y, x);
} else {
tmp = fma((z - x), (y / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= 3e-131) tmp = fma(Float64(Float64(z - x) / t), y, x); else tmp = fma(Float64(z - x), Float64(y / t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, 3e-131], N[(N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)\\
\end{array}
\end{array}
if x < 2.99999999999999996e-131Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.5
Applied rewrites92.5%
if 2.99999999999999996e-131 < x Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
(FPCore (x y z t) :precision binary64 (fma (- z x) (/ y t) x))
double code(double x, double y, double z, double t) {
return fma((z - x), (y / t), x);
}
function code(x, y, z, t) return fma(Float64(z - x), Float64(y / t), x) end
code[x_, y_, z_, t_] := N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)
\end{array}
Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (/ (- z x) t) y))) (if (<= y -2.9e+64) t_1 (if (<= y 1.5e-56) (+ x (/ (* y z) t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = ((z - x) / t) * y;
double tmp;
if (y <= -2.9e+64) {
tmp = t_1;
} else if (y <= 1.5e-56) {
tmp = x + ((y * z) / t);
} else {
tmp = t_1;
}
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)
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) :: t_1
real(8) :: tmp
t_1 = ((z - x) / t) * y
if (y <= (-2.9d+64)) then
tmp = t_1
else if (y <= 1.5d-56) then
tmp = x + ((y * z) / t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = ((z - x) / t) * y;
double tmp;
if (y <= -2.9e+64) {
tmp = t_1;
} else if (y <= 1.5e-56) {
tmp = x + ((y * z) / t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = ((z - x) / t) * y tmp = 0 if y <= -2.9e+64: tmp = t_1 elif y <= 1.5e-56: tmp = x + ((y * z) / t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(Float64(z - x) / t) * y) tmp = 0.0 if (y <= -2.9e+64) tmp = t_1; elseif (y <= 1.5e-56) tmp = Float64(x + Float64(Float64(y * z) / t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = ((z - x) / t) * y; tmp = 0.0; if (y <= -2.9e+64) tmp = t_1; elseif (y <= 1.5e-56) tmp = x + ((y * z) / t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -2.9e+64], t$95$1, If[LessEqual[y, 1.5e-56], N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - x}{t} \cdot y\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{+64}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-56}:\\
\;\;\;\;x + \frac{y \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -2.89999999999999993e64 or 1.49999999999999995e-56 < y Initial program 93.1%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f64N/A
lift--.f6458.3
Applied rewrites58.3%
if -2.89999999999999993e64 < y < 1.49999999999999995e-56Initial program 93.1%
Taylor expanded in x around 0
Applied rewrites74.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- 1.0 (/ y t)) x))) (if (<= x -2700000.0) t_1 (if (<= x 1.15e-23) (fma (/ z t) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (y / t)) * x;
double tmp;
if (x <= -2700000.0) {
tmp = t_1;
} else if (x <= 1.15e-23) {
tmp = fma((z / t), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - Float64(y / t)) * x) tmp = 0.0 if (x <= -2700000.0) tmp = t_1; elseif (x <= 1.15e-23) tmp = fma(Float64(z / t), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -2700000.0], t$95$1, If[LessEqual[x, 1.15e-23], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \frac{y}{t}\right) \cdot x\\
\mathbf{if}\;x \leq -2700000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.7e6 or 1.15000000000000005e-23 < x Initial program 93.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6464.6
Applied rewrites64.6%
if -2.7e6 < x < 1.15000000000000005e-23Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f6492.5
Applied rewrites92.5%
Taylor expanded in x around 0
Applied rewrites74.4%
(FPCore (x y z t) :precision binary64 (if (<= y -8.2e+201) (- (* y (/ x t))) (fma z (/ y t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -8.2e+201) {
tmp = -(y * (x / t));
} else {
tmp = fma(z, (y / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -8.2e+201) tmp = Float64(-Float64(y * Float64(x / t))); else tmp = fma(z, Float64(y / t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -8.2e+201], (-N[(y * N[(x / t), $MachinePrecision]), $MachinePrecision]), N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+201}:\\
\;\;\;\;-y \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\end{array}
\end{array}
if y < -8.2000000000000005e201Initial program 93.1%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6428.5
Applied rewrites28.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6426.6
Applied rewrites26.6%
if -8.2000000000000005e201 < y Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites78.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (/ y t))))
(if (<= y -8.8e+153)
(- (* y (/ x t)))
(if (<= y -6.8e+38) t_1 (if (<= y 2.9e-75) (* 1.0 x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = z * (y / t);
double tmp;
if (y <= -8.8e+153) {
tmp = -(y * (x / t));
} else if (y <= -6.8e+38) {
tmp = t_1;
} else if (y <= 2.9e-75) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
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)
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) :: t_1
real(8) :: tmp
t_1 = z * (y / t)
if (y <= (-8.8d+153)) then
tmp = -(y * (x / t))
else if (y <= (-6.8d+38)) then
tmp = t_1
else if (y <= 2.9d-75) then
tmp = 1.0d0 * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (y / t);
double tmp;
if (y <= -8.8e+153) {
tmp = -(y * (x / t));
} else if (y <= -6.8e+38) {
tmp = t_1;
} else if (y <= 2.9e-75) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (y / t) tmp = 0 if y <= -8.8e+153: tmp = -(y * (x / t)) elif y <= -6.8e+38: tmp = t_1 elif y <= 2.9e-75: tmp = 1.0 * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(y / t)) tmp = 0.0 if (y <= -8.8e+153) tmp = Float64(-Float64(y * Float64(x / t))); elseif (y <= -6.8e+38) tmp = t_1; elseif (y <= 2.9e-75) tmp = Float64(1.0 * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (y / t); tmp = 0.0; if (y <= -8.8e+153) tmp = -(y * (x / t)); elseif (y <= -6.8e+38) tmp = t_1; elseif (y <= 2.9e-75) tmp = 1.0 * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.8e+153], (-N[(y * N[(x / t), $MachinePrecision]), $MachinePrecision]), If[LessEqual[y, -6.8e+38], t$95$1, If[LessEqual[y, 2.9e-75], N[(1.0 * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \frac{y}{t}\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{+153}:\\
\;\;\;\;-y \cdot \frac{x}{t}\\
\mathbf{elif}\;y \leq -6.8 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-75}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -8.7999999999999998e153Initial program 93.1%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6428.5
Applied rewrites28.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6426.6
Applied rewrites26.6%
if -8.7999999999999998e153 < y < -6.79999999999999992e38 or 2.9000000000000002e-75 < y Initial program 93.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.0
Applied rewrites39.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6442.0
Applied rewrites42.0%
if -6.79999999999999992e38 < y < 2.9000000000000002e-75Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites78.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift-/.f6464.6
Applied rewrites64.6%
Taylor expanded in y around 0
Applied rewrites38.5%
(FPCore (x y z t) :precision binary64 (if (<= y -1.2e+46) (- (* x (/ y t))) (if (<= y 2.9e-75) (* 1.0 x) (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.2e+46) {
tmp = -(x * (y / t));
} else if (y <= 2.9e-75) {
tmp = 1.0 * x;
} else {
tmp = z * (y / 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)
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) :: tmp
if (y <= (-1.2d+46)) then
tmp = -(x * (y / t))
else if (y <= 2.9d-75) then
tmp = 1.0d0 * x
else
tmp = z * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.2e+46) {
tmp = -(x * (y / t));
} else if (y <= 2.9e-75) {
tmp = 1.0 * x;
} else {
tmp = z * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.2e+46: tmp = -(x * (y / t)) elif y <= 2.9e-75: tmp = 1.0 * x else: tmp = z * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.2e+46) tmp = Float64(-Float64(x * Float64(y / t))); elseif (y <= 2.9e-75) tmp = Float64(1.0 * x); else tmp = Float64(z * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.2e+46) tmp = -(x * (y / t)); elseif (y <= 2.9e-75) tmp = 1.0 * x; else tmp = z * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.2e+46], (-N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]), If[LessEqual[y, 2.9e-75], N[(1.0 * x), $MachinePrecision], N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+46}:\\
\;\;\;\;-x \cdot \frac{y}{t}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-75}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -1.20000000000000004e46Initial program 93.1%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6458.6
Applied rewrites58.6%
Taylor expanded in x around inf
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6428.5
Applied rewrites28.5%
if -1.20000000000000004e46 < y < 2.9000000000000002e-75Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites78.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift-/.f6464.6
Applied rewrites64.6%
Taylor expanded in y around 0
Applied rewrites38.5%
if 2.9000000000000002e-75 < y Initial program 93.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.0
Applied rewrites39.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6442.0
Applied rewrites42.0%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (/ y t)))) (if (<= y -6.8e+38) t_1 (if (<= y 2.9e-75) (* 1.0 x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (y / t);
double tmp;
if (y <= -6.8e+38) {
tmp = t_1;
} else if (y <= 2.9e-75) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
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)
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) :: t_1
real(8) :: tmp
t_1 = z * (y / t)
if (y <= (-6.8d+38)) then
tmp = t_1
else if (y <= 2.9d-75) then
tmp = 1.0d0 * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (y / t);
double tmp;
if (y <= -6.8e+38) {
tmp = t_1;
} else if (y <= 2.9e-75) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (y / t) tmp = 0 if y <= -6.8e+38: tmp = t_1 elif y <= 2.9e-75: tmp = 1.0 * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(y / t)) tmp = 0.0 if (y <= -6.8e+38) tmp = t_1; elseif (y <= 2.9e-75) tmp = Float64(1.0 * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (y / t); tmp = 0.0; if (y <= -6.8e+38) tmp = t_1; elseif (y <= 2.9e-75) tmp = 1.0 * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.8e+38], t$95$1, If[LessEqual[y, 2.9e-75], N[(1.0 * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \frac{y}{t}\\
\mathbf{if}\;y \leq -6.8 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-75}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.79999999999999992e38 or 2.9000000000000002e-75 < y Initial program 93.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.0
Applied rewrites39.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6442.0
Applied rewrites42.0%
if -6.79999999999999992e38 < y < 2.9000000000000002e-75Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites78.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift-/.f6464.6
Applied rewrites64.6%
Taylor expanded in y around 0
Applied rewrites38.5%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* y (/ z t)))) (if (<= y -6.8e+38) t_1 (if (<= y 1.5e-56) (* 1.0 x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if (y <= -6.8e+38) {
tmp = t_1;
} else if (y <= 1.5e-56) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
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)
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) :: t_1
real(8) :: tmp
t_1 = y * (z / t)
if (y <= (-6.8d+38)) then
tmp = t_1
else if (y <= 1.5d-56) then
tmp = 1.0d0 * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = y * (z / t);
double tmp;
if (y <= -6.8e+38) {
tmp = t_1;
} else if (y <= 1.5e-56) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = y * (z / t) tmp = 0 if y <= -6.8e+38: tmp = t_1 elif y <= 1.5e-56: tmp = 1.0 * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(y * Float64(z / t)) tmp = 0.0 if (y <= -6.8e+38) tmp = t_1; elseif (y <= 1.5e-56) tmp = Float64(1.0 * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = y * (z / t); tmp = 0.0; if (y <= -6.8e+38) tmp = t_1; elseif (y <= 1.5e-56) tmp = 1.0 * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.8e+38], t$95$1, If[LessEqual[y, 1.5e-56], N[(1.0 * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \frac{z}{t}\\
\mathbf{if}\;y \leq -6.8 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-56}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -6.79999999999999992e38 or 1.49999999999999995e-56 < y Initial program 93.1%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.0
Applied rewrites39.0%
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6438.9
Applied rewrites38.9%
if -6.79999999999999992e38 < y < 1.49999999999999995e-56Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites78.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift-/.f6464.6
Applied rewrites64.6%
Taylor expanded in y around 0
Applied rewrites38.5%
(FPCore (x y z t) :precision binary64 (* 1.0 x))
double code(double x, double y, double z, double t) {
return 1.0 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 * x
end function
public static double code(double x, double y, double z, double t) {
return 1.0 * x;
}
def code(x, y, z, t): return 1.0 * x
function code(x, y, z, t) return Float64(1.0 * x) end
function tmp = code(x, y, z, t) tmp = 1.0 * x; end
code[x_, y_, z_, t_] := N[(1.0 * x), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot x
\end{array}
Initial program 93.1%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
Taylor expanded in x around 0
Applied rewrites78.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lift-/.f6464.6
Applied rewrites64.6%
Taylor expanded in y around 0
Applied rewrites38.5%
herbie shell --seed 2025139
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
(+ x (/ (* y (- z x)) t)))