
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
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 - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot t}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
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 - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot t}{a - z}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y z) t) (- a z)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+300)))
(* (/ t (- a z)) (- y z))
t_1)))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) * t) / (a - z));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+300)) {
tmp = (t / (a - z)) * (y - z);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) * t) / (a - z));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+300)) {
tmp = (t / (a - z)) * (y - z);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x + (((y - z) * t) / (a - z)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 5e+300): tmp = (t / (a - z)) * (y - z) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+300)) tmp = Float64(Float64(t / Float64(a - z)) * Float64(y - z)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - z) * t) / (a - z)); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 5e+300))) tmp = (t / (a - z)) * (y - z); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+300]], $MachinePrecision]], N[(N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+300}\right):\\
\;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z))) < -inf.0 or 5.00000000000000026e300 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z))) Initial program 39.5%
Taylor expanded in x around 0
associate-/l*N/A
div-subN/A
div-subN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6489.4
Applied rewrites89.4%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z))) < 5.00000000000000026e300Initial program 99.8%
Final simplification97.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* (- y z) t) (- a z))))
(if (or (<= t_1 -4e+209) (not (<= t_1 2e+46)))
(* (/ t (- a z)) (- y z))
(fma (/ z (- a z)) (- t) x))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y - z) * t) / (a - z);
double tmp;
if ((t_1 <= -4e+209) || !(t_1 <= 2e+46)) {
tmp = (t / (a - z)) * (y - z);
} else {
tmp = fma((z / (a - z)), -t, x);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y - z) * t) / Float64(a - z)) tmp = 0.0 if ((t_1 <= -4e+209) || !(t_1 <= 2e+46)) tmp = Float64(Float64(t / Float64(a - z)) * Float64(y - z)); else tmp = fma(Float64(z / Float64(a - z)), Float64(-t), x); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -4e+209], N[Not[LessEqual[t$95$1, 2e+46]], $MachinePrecision]], N[(N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision] * (-t) + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+209} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+46}\right):\\
\;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - z}, -t, x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -4.0000000000000003e209 or 2e46 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) Initial program 64.9%
Taylor expanded in x around 0
associate-/l*N/A
div-subN/A
div-subN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6480.1
Applied rewrites80.1%
if -4.0000000000000003e209 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 2e46Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6493.5
Applied rewrites93.5%
Final simplification88.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* (- y z) t) (- a z)))) (if (<= t_1 -2e+75) t (if (<= t_1 4e+234) x t))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((y - z) * t) / (a - z);
double tmp;
if (t_1 <= -2e+75) {
tmp = t;
} else if (t_1 <= 4e+234) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = ((y - z) * t) / (a - z)
if (t_1 <= (-2d+75)) then
tmp = t
else if (t_1 <= 4d+234) then
tmp = x
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((y - z) * t) / (a - z);
double tmp;
if (t_1 <= -2e+75) {
tmp = t;
} else if (t_1 <= 4e+234) {
tmp = x;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((y - z) * t) / (a - z) tmp = 0 if t_1 <= -2e+75: tmp = t elif t_1 <= 4e+234: tmp = x else: tmp = t return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y - z) * t) / Float64(a - z)) tmp = 0.0 if (t_1 <= -2e+75) tmp = t; elseif (t_1 <= 4e+234) tmp = x; else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((y - z) * t) / (a - z); tmp = 0.0; if (t_1 <= -2e+75) tmp = t; elseif (t_1 <= 4e+234) tmp = x; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+75], t, If[LessEqual[t$95$1, 4e+234], x, t]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+75}:\\
\;\;\;\;t\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+234}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -1.99999999999999985e75 or 4.00000000000000007e234 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) Initial program 60.7%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
mul-1-negN/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6468.6
Applied rewrites68.6%
Taylor expanded in x around 0
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6460.7
Applied rewrites60.7%
Taylor expanded in y around 0
Applied rewrites34.6%
if -1.99999999999999985e75 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 4.00000000000000007e234Initial program 99.9%
Taylor expanded in x around inf
Applied rewrites72.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -9e+117) (not (<= z 2e-33))) (fma (/ z (- a z)) (- t) x) (+ x (/ (* y t) (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -9e+117) || !(z <= 2e-33)) {
tmp = fma((z / (a - z)), -t, x);
} else {
tmp = x + ((y * t) / (a - z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -9e+117) || !(z <= 2e-33)) tmp = fma(Float64(z / Float64(a - z)), Float64(-t), x); else tmp = Float64(x + Float64(Float64(y * t) / Float64(a - z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -9e+117], N[Not[LessEqual[z, 2e-33]], $MachinePrecision]], N[(N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision] * (-t) + x), $MachinePrecision], N[(x + N[(N[(y * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+117} \lor \neg \left(z \leq 2 \cdot 10^{-33}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - z}, -t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot t}{a - z}\\
\end{array}
\end{array}
if z < -9e117 or 2.0000000000000001e-33 < z Initial program 80.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6491.8
Applied rewrites91.8%
if -9e117 < z < 2.0000000000000001e-33Initial program 95.2%
Taylor expanded in y around inf
Applied rewrites89.7%
Final simplification90.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -9.5e-116) (not (<= z 1.1e+60))) (fma (/ (- z y) z) t x) (fma (- y z) (/ t a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -9.5e-116) || !(z <= 1.1e+60)) {
tmp = fma(((z - y) / z), t, x);
} else {
tmp = fma((y - z), (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -9.5e-116) || !(z <= 1.1e+60)) tmp = fma(Float64(Float64(z - y) / z), t, x); else tmp = fma(Float64(y - z), Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -9.5e-116], N[Not[LessEqual[z, 1.1e+60]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{-116} \lor \neg \left(z \leq 1.1 \cdot 10^{+60}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{z}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if z < -9.4999999999999998e-116 or 1.09999999999999998e60 < z Initial program 83.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identityN/A
mul-1-negN/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6487.7
Applied rewrites87.7%
if -9.4999999999999998e-116 < z < 1.09999999999999998e60Initial program 93.5%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6481.8
Applied rewrites81.8%
Final simplification85.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.6e-51) (not (<= z 4e+60))) (+ x t) (fma (- y z) (/ t a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.6e-51) || !(z <= 4e+60)) {
tmp = x + t;
} else {
tmp = fma((y - z), (t / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.6e-51) || !(z <= 4e+60)) tmp = Float64(x + t); else tmp = fma(Float64(y - z), Float64(t / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.6e-51], N[Not[LessEqual[z, 4e+60]], $MachinePrecision]], N[(x + t), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(t / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-51} \lor \neg \left(z \leq 4 \cdot 10^{+60}\right):\\
\;\;\;\;x + t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.6e-51 or 3.9999999999999998e60 < z Initial program 81.7%
Taylor expanded in z around inf
Applied rewrites81.0%
if -3.6e-51 < z < 3.9999999999999998e60Initial program 94.2%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6479.8
Applied rewrites79.8%
Final simplification80.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.6e-51) (not (<= z 4e+60))) (+ x t) (fma t (/ (- y z) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.6e-51) || !(z <= 4e+60)) {
tmp = x + t;
} else {
tmp = fma(t, ((y - z) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.6e-51) || !(z <= 4e+60)) tmp = Float64(x + t); else tmp = fma(t, Float64(Float64(y - z) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.6e-51], N[Not[LessEqual[z, 4e+60]], $MachinePrecision]], N[(x + t), $MachinePrecision], N[(t * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-51} \lor \neg \left(z \leq 4 \cdot 10^{+60}\right):\\
\;\;\;\;x + t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y - z}{a}, x\right)\\
\end{array}
\end{array}
if z < -3.6e-51 or 3.9999999999999998e60 < z Initial program 81.7%
Taylor expanded in z around inf
Applied rewrites81.0%
if -3.6e-51 < z < 3.9999999999999998e60Initial program 94.2%
Taylor expanded in x around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
metadata-evalN/A
metadata-evalN/A
fp-cancel-sign-subN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites88.4%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6479.2
Applied rewrites79.2%
Final simplification80.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -0.19) (not (<= z 0.00355))) (+ x t) (fma (/ y a) t x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -0.19) || !(z <= 0.00355)) {
tmp = x + t;
} else {
tmp = fma((y / a), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -0.19) || !(z <= 0.00355)) tmp = Float64(x + t); else tmp = fma(Float64(y / a), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -0.19], N[Not[LessEqual[z, 0.00355]], $MachinePrecision]], N[(x + t), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.19 \lor \neg \left(z \leq 0.00355\right):\\
\;\;\;\;x + t\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\end{array}
\end{array}
if z < -0.19 or 0.0035500000000000002 < z Initial program 80.9%
Taylor expanded in z around inf
Applied rewrites80.6%
if -0.19 < z < 0.0035500000000000002Initial program 95.0%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6477.2
Applied rewrites77.2%
Final simplification79.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.7e+53) (fma (/ t z) a (+ t x)) (if (<= z 0.00355) (fma (/ y a) t x) (+ x t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.7e+53) {
tmp = fma((t / z), a, (t + x));
} else if (z <= 0.00355) {
tmp = fma((y / a), t, x);
} else {
tmp = x + t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.7e+53) tmp = fma(Float64(t / z), a, Float64(t + x)); elseif (z <= 0.00355) tmp = fma(Float64(y / a), t, x); else tmp = Float64(x + t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.7e+53], N[(N[(t / z), $MachinePrecision] * a + N[(t + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.00355], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(x + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{z}, a, t + x\right)\\
\mathbf{elif}\;z \leq 0.00355:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\\
\end{array}
\end{array}
if z < -2.70000000000000019e53Initial program 76.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f6495.9
Applied rewrites95.9%
Taylor expanded in z around inf
associate-+r+N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6492.9
Applied rewrites92.9%
if -2.70000000000000019e53 < z < 0.0035500000000000002Initial program 95.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6475.7
Applied rewrites75.7%
if 0.0035500000000000002 < z Initial program 82.6%
Taylor expanded in z around inf
Applied rewrites73.8%
(FPCore (x y z t a) :precision binary64 (+ x t))
double code(double x, double y, double z, double t, double a) {
return 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, 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 + t
end function
public static double code(double x, double y, double z, double t, double a) {
return x + t;
}
def code(x, y, z, t, a): return x + t
function code(x, y, z, t, a) return Float64(x + t) end
function tmp = code(x, y, z, t, a) tmp = x + t; end
code[x_, y_, z_, t_, a_] := N[(x + t), $MachinePrecision]
\begin{array}{l}
\\
x + t
\end{array}
Initial program 87.3%
Taylor expanded in z around inf
Applied rewrites65.9%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.3%
Taylor expanded in x around inf
Applied rewrites53.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (* (/ (- y z) (- a z)) t))))
(if (< t -1.0682974490174067e-39)
t_1
(if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) / (a - z)) * t);
double tmp;
if (t < -1.0682974490174067e-39) {
tmp = t_1;
} else if (t < 3.9110949887586375e-141) {
tmp = x + (((y - z) * t) / (a - z));
} 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, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = x + (((y - z) / (a - z)) * t)
if (t < (-1.0682974490174067d-39)) then
tmp = t_1
else if (t < 3.9110949887586375d-141) then
tmp = x + (((y - z) * t) / (a - z))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - z) / (a - z)) * t);
double tmp;
if (t < -1.0682974490174067e-39) {
tmp = t_1;
} else if (t < 3.9110949887586375e-141) {
tmp = x + (((y - z) * t) / (a - z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x + (((y - z) / (a - z)) * t) tmp = 0 if t < -1.0682974490174067e-39: tmp = t_1 elif t < 3.9110949887586375e-141: tmp = x + (((y - z) * t) / (a - z)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - z) / Float64(a - z)) * t)) tmp = 0.0 if (t < -1.0682974490174067e-39) tmp = t_1; elseif (t < 3.9110949887586375e-141) tmp = Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - z) / (a - z)) * t); tmp = 0.0; if (t < -1.0682974490174067e-39) tmp = t_1; elseif (t < 3.9110949887586375e-141) tmp = x + (((y - z) * t) / (a - z)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[Less[t, -1.0682974490174067e-39], t$95$1, If[Less[t, 3.9110949887586375e-141], N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{y - z}{a - z} \cdot t\\
\mathbf{if}\;t < -1.0682974490174067 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t < 3.9110949887586375 \cdot 10^{-141}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025026
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"
:precision binary64
:alt
(! :herbie-platform default (if (< t -10682974490174067/10000000000000000000000000000000000000000000000000000000) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 312887599100691/80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t)))))
(+ x (/ (* (- y z) t) (- a z))))