
(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}
Sampling outcomes in binary64 precision:
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 (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.2%
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.5e-39) (not (<= t 1.4e-93))) (fma y (/ z t) x) (/ (* (- z x) y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.5e-39) || !(t <= 1.4e-93)) {
tmp = fma(y, (z / t), x);
} else {
tmp = ((z - x) * y) / t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((t <= -6.5e-39) || !(t <= 1.4e-93)) tmp = fma(y, Float64(z / t), x); else tmp = Float64(Float64(Float64(z - x) * y) / t); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6.5e-39], N[Not[LessEqual[t, 1.4e-93]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{-39} \lor \neg \left(t \leq 1.4 \cdot 10^{-93}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\
\end{array}
\end{array}
if t < -6.50000000000000027e-39 or 1.39999999999999999e-93 < t Initial program 92.0%
Taylor expanded in x around 0
Applied rewrites81.5%
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.4
Applied rewrites84.4%
if -6.50000000000000027e-39 < t < 1.39999999999999999e-93Initial program 94.7%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6484.6
Applied rewrites84.6%
Final simplification84.5%
(FPCore (x y z t) :precision binary64 (if (or (<= x -2.2e+36) (not (<= x 48.0))) (* (- 1.0 (/ y t)) x) (fma y (/ z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -2.2e+36) || !(x <= 48.0)) {
tmp = (1.0 - (y / t)) * x;
} else {
tmp = fma(y, (z / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((x <= -2.2e+36) || !(x <= 48.0)) tmp = Float64(Float64(1.0 - Float64(y / t)) * x); else tmp = fma(y, Float64(z / t), x); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -2.2e+36], N[Not[LessEqual[x, 48.0]], $MachinePrecision]], N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+36} \lor \neg \left(x \leq 48\right):\\
\;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\end{array}
\end{array}
if x < -2.2e36 or 48 < x Initial program 93.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6485.1
Applied rewrites85.1%
if -2.2e36 < x < 48Initial program 93.0%
Taylor expanded in x around 0
Applied rewrites81.9%
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6483.8
Applied rewrites83.8%
Final simplification84.4%
(FPCore (x y z t) :precision binary64 (if (<= x -2.2e+36) (- x (* x (/ y t))) (if (<= x 48.0) (fma y (/ z t) x) (* (- 1.0 (/ y t)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.2e+36) {
tmp = x - (x * (y / t));
} else if (x <= 48.0) {
tmp = fma(y, (z / t), x);
} else {
tmp = (1.0 - (y / t)) * x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -2.2e+36) tmp = Float64(x - Float64(x * Float64(y / t))); elseif (x <= 48.0) tmp = fma(y, Float64(z / t), x); else tmp = Float64(Float64(1.0 - Float64(y / t)) * x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.2e+36], N[(x - N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 48.0], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+36}:\\
\;\;\;\;x - x \cdot \frac{y}{t}\\
\mathbf{elif}\;x \leq 48:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{y}{t}\right) \cdot x\\
\end{array}
\end{array}
if x < -2.2e36Initial program 92.0%
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
times-fracN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6488.7
Applied rewrites88.7%
if -2.2e36 < x < 48Initial program 93.0%
Taylor expanded in x around 0
Applied rewrites81.9%
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6483.8
Applied rewrites83.8%
if 48 < x Initial program 95.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6481.5
Applied rewrites81.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -9e+49) (not (<= z 4.4e+43))) (* (/ y t) z) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9e+49) || !(z <= 4.4e+43)) {
tmp = (y / t) * z;
} else {
tmp = x;
}
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 ((z <= (-9d+49)) .or. (.not. (z <= 4.4d+43))) then
tmp = (y / t) * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9e+49) || !(z <= 4.4e+43)) {
tmp = (y / t) * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -9e+49) or not (z <= 4.4e+43): tmp = (y / t) * z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -9e+49) || !(z <= 4.4e+43)) tmp = Float64(Float64(y / t) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -9e+49) || ~((z <= 4.4e+43))) tmp = (y / t) * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -9e+49], N[Not[LessEqual[z, 4.4e+43]], $MachinePrecision]], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+49} \lor \neg \left(z \leq 4.4 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.99999999999999965e49 or 4.40000000000000001e43 < z Initial program 92.3%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6473.9
Applied rewrites73.9%
associate-/l*N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
frac-timesN/A
*-commutativeN/A
frac-timesN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6478.5
Applied rewrites78.5%
Taylor expanded in x around 0
Applied rewrites71.4%
if -8.99999999999999965e49 < z < 4.40000000000000001e43Initial program 93.8%
Taylor expanded in y around 0
Applied rewrites48.4%
Final simplification57.4%
(FPCore (x y z t) :precision binary64 (if (<= z -9e+49) (* (/ y t) z) (if (<= z 4.4e+43) x (/ (* z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+49) {
tmp = (y / t) * z;
} else if (z <= 4.4e+43) {
tmp = 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 (z <= (-9d+49)) then
tmp = (y / t) * z
else if (z <= 4.4d+43) then
tmp = 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 (z <= -9e+49) {
tmp = (y / t) * z;
} else if (z <= 4.4e+43) {
tmp = x;
} else {
tmp = (z * y) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9e+49: tmp = (y / t) * z elif z <= 4.4e+43: tmp = x else: tmp = (z * y) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9e+49) tmp = Float64(Float64(y / t) * z); elseif (z <= 4.4e+43) tmp = x; else tmp = Float64(Float64(z * y) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9e+49) tmp = (y / t) * z; elseif (z <= 4.4e+43) tmp = x; else tmp = (z * y) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9e+49], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 4.4e+43], x, N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+49}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{+43}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot y}{t}\\
\end{array}
\end{array}
if z < -8.99999999999999965e49Initial program 90.1%
Taylor expanded in y around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6473.1
Applied rewrites73.1%
associate-/l*N/A
frac-2negN/A
mul-1-negN/A
*-commutativeN/A
mul-1-negN/A
frac-timesN/A
*-commutativeN/A
frac-timesN/A
*-commutativeN/A
mul-1-negN/A
mul-1-negN/A
frac-2negN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6480.7
Applied rewrites80.7%
Taylor expanded in x around 0
Applied rewrites72.9%
if -8.99999999999999965e49 < z < 4.40000000000000001e43Initial program 93.8%
Taylor expanded in y around 0
Applied rewrites48.4%
if 4.40000000000000001e43 < z Initial program 94.3%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6470.7
Applied rewrites70.7%
(FPCore (x y z t) :precision binary64 (if (<= y -2.4e+266) (* (/ (- y) t) x) (fma y (/ z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.4e+266) {
tmp = (-y / t) * x;
} else {
tmp = fma(y, (z / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.4e+266) tmp = Float64(Float64(Float64(-y) / t) * x); else tmp = fma(y, Float64(z / t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.4e+266], N[(N[((-y) / t), $MachinePrecision] * x), $MachinePrecision], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+266}:\\
\;\;\;\;\frac{-y}{t} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\end{array}
\end{array}
if y < -2.40000000000000002e266Initial program 89.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6478.6
Applied rewrites78.6%
Taylor expanded in y around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6478.6
Applied rewrites78.6%
if -2.40000000000000002e266 < y Initial program 93.3%
Taylor expanded in x around 0
Applied rewrites72.7%
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6472.2
Applied rewrites72.2%
(FPCore (x y z t) :precision binary64 (if (<= y -2.4e+266) (/ (* (- x) y) t) (fma y (/ z t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.4e+266) {
tmp = (-x * y) / t;
} else {
tmp = fma(y, (z / t), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -2.4e+266) tmp = Float64(Float64(Float64(-x) * y) / t); else tmp = fma(y, Float64(z / t), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.4e+266], N[(N[((-x) * y), $MachinePrecision] / t), $MachinePrecision], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+266}:\\
\;\;\;\;\frac{\left(-x\right) \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\end{array}
\end{array}
if y < -2.40000000000000002e266Initial program 89.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6478.6
Applied rewrites78.6%
Taylor expanded in y around inf
associate-*r/N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6478.4
Applied rewrites78.4%
if -2.40000000000000002e266 < y Initial program 93.3%
Taylor expanded in x around 0
Applied rewrites72.7%
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6472.2
Applied rewrites72.2%
(FPCore (x y z t) :precision binary64 (fma y (/ z t) x))
double code(double x, double y, double z, double t) {
return fma(y, (z / t), x);
}
function code(x, y, z, t) return fma(y, Float64(z / t), x) end
code[x_, y_, z_, t_] := N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \frac{z}{t}, x\right)
\end{array}
Initial program 93.2%
Taylor expanded in x around 0
Applied rewrites71.0%
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6470.1
Applied rewrites70.1%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.2%
Taylor expanded in y around 0
Applied rewrites37.8%
(FPCore (x y z t) :precision binary64 (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / 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 - ((x * (y / t)) + (-z * (y / t)))
end function
public static double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
def code(x, y, z, t): return x - ((x * (y / t)) + (-z * (y / t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t)))) end
function tmp = code(x, y, z, t) tmp = x - ((x * (y / t)) + (-z * (y / t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
\end{array}
herbie shell --seed 2025044
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:alt
(! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
(+ x (/ (* y (- z x)) t)))