
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- z y) (- (+ 1.0 t) z)) a x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - y) / ((1.0 + t) - z)), a, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - y) / Float64(Float64(1.0 + t) - z)), a, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - y), $MachinePrecision] / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - y}{\left(1 + t\right) - z}, a, x\right)
\end{array}
Initial program 96.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a) :precision binary64 (if (<= (/ (- y z) (/ (+ (- t z) 1.0) a)) 2e+171) x (- a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((y - z) / (((t - z) + 1.0) / a)) <= 2e+171) {
tmp = x;
} else {
tmp = -a;
}
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) :: tmp
if (((y - z) / (((t - z) + 1.0d0) / a)) <= 2d+171) then
tmp = x
else
tmp = -a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((y - z) / (((t - z) + 1.0) / a)) <= 2e+171) {
tmp = x;
} else {
tmp = -a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((y - z) / (((t - z) + 1.0) / a)) <= 2e+171: tmp = x else: tmp = -a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a)) <= 2e+171) tmp = x; else tmp = Float64(-a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((y - z) / (((t - z) + 1.0) / a)) <= 2e+171) tmp = x; else tmp = -a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], 2e+171], x, (-a)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{y - z}{\frac{\left(t - z\right) + 1}{a}} \leq 2 \cdot 10^{+171}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-a\\
\end{array}
\end{array}
if (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < 1.99999999999999991e171Initial program 95.6%
Taylor expanded in x around inf
Applied rewrites55.8%
if 1.99999999999999991e171 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) Initial program 99.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6484.8
Applied rewrites84.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6438.8
Applied rewrites38.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -90000000000.0) (not (<= t 1.02e-16))) (fma (/ (- z y) (- t z)) a x) (- x (* (- y z) (/ a (- 1.0 z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -90000000000.0) || !(t <= 1.02e-16)) {
tmp = fma(((z - y) / (t - z)), a, x);
} else {
tmp = x - ((y - z) * (a / (1.0 - z)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -90000000000.0) || !(t <= 1.02e-16)) tmp = fma(Float64(Float64(z - y) / Float64(t - z)), a, x); else tmp = Float64(x - Float64(Float64(y - z) * Float64(a / Float64(1.0 - z)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -90000000000.0], N[Not[LessEqual[t, 1.02e-16]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -90000000000 \lor \neg \left(t \leq 1.02 \cdot 10^{-16}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \left(y - z\right) \cdot \frac{a}{1 - z}\\
\end{array}
\end{array}
if t < -9e10 or 1.0200000000000001e-16 < t Initial program 96.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites99.7%
if -9e10 < t < 1.0200000000000001e-16Initial program 96.2%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6484.6
Applied rewrites84.6%
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f64N/A
lift--.f6495.4
Applied rewrites95.4%
Final simplification97.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.4e-25) (not (<= z 0.9))) (fma (/ (- z y) (- t z)) a x) (fma (/ y (- -1.0 t)) a x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.4e-25) || !(z <= 0.9)) {
tmp = fma(((z - y) / (t - z)), a, x);
} else {
tmp = fma((y / (-1.0 - t)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.4e-25) || !(z <= 0.9)) tmp = fma(Float64(Float64(z - y) / Float64(t - z)), a, x); else tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.4e-25], N[Not[LessEqual[z, 0.9]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-25} \lor \neg \left(z \leq 0.9\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\end{array}
\end{array}
if z < -1.39999999999999994e-25 or 0.900000000000000022 < z Initial program 93.2%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites97.3%
if -1.39999999999999994e-25 < z < 0.900000000000000022Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6491.1
Applied rewrites91.1%
Final simplification94.2%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -7.6e-87) (not (<= z 3e-69))) (fma (/ z (- (+ 1.0 t) z)) a x) (fma (/ y (- -1.0 t)) a x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -7.6e-87) || !(z <= 3e-69)) {
tmp = fma((z / ((1.0 + t) - z)), a, x);
} else {
tmp = fma((y / (-1.0 - t)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -7.6e-87) || !(z <= 3e-69)) tmp = fma(Float64(z / Float64(Float64(1.0 + t) - z)), a, x); else tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -7.6e-87], N[Not[LessEqual[z, 3e-69]], $MachinePrecision]], N[(N[(z / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{-87} \lor \neg \left(z \leq 3 \cdot 10^{-69}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\left(1 + t\right) - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\end{array}
\end{array}
if z < -7.6e-87 or 2.99999999999999989e-69 < z Initial program 94.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites86.1%
if -7.6e-87 < z < 2.99999999999999989e-69Initial program 98.9%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6494.4
Applied rewrites94.4%
Final simplification89.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.05e-23) (not (<= z 2.9e+25))) (fma (/ z (- t z)) a x) (fma (/ y (- -1.0 t)) a x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.05e-23) || !(z <= 2.9e+25)) {
tmp = fma((z / (t - z)), a, x);
} else {
tmp = fma((y / (-1.0 - t)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.05e-23) || !(z <= 2.9e+25)) tmp = fma(Float64(z / Float64(t - z)), a, x); else tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.05e-23], N[Not[LessEqual[z, 2.9e+25]], $MachinePrecision]], N[(N[(z / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-23} \lor \neg \left(z \leq 2.9 \cdot 10^{+25}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\end{array}
\end{array}
if z < -1.05e-23 or 2.8999999999999999e25 < z Initial program 93.0%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites98.0%
Taylor expanded in y around 0
Applied rewrites85.4%
if -1.05e-23 < z < 2.8999999999999999e25Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6490.0
Applied rewrites90.0%
Final simplification87.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.6e-38) (not (<= z 3.3e-6))) (fma (/ z (- t z)) a x) (- x (* a (+ y (* y z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.6e-38) || !(z <= 3.3e-6)) {
tmp = fma((z / (t - z)), a, x);
} else {
tmp = x - (a * (y + (y * z)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.6e-38) || !(z <= 3.3e-6)) tmp = fma(Float64(z / Float64(t - z)), a, x); else tmp = Float64(x - Float64(a * Float64(y + Float64(y * z)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.6e-38], N[Not[LessEqual[z, 3.3e-6]], $MachinePrecision]], N[(N[(z / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(x - N[(a * N[(y + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{-38} \lor \neg \left(z \leq 3.3 \cdot 10^{-6}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a \cdot \left(y + y \cdot z\right)\\
\end{array}
\end{array}
if z < -2.60000000000000011e-38 or 3.30000000000000017e-6 < z Initial program 93.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites97.3%
Taylor expanded in y around 0
Applied rewrites83.1%
if -2.60000000000000011e-38 < z < 3.30000000000000017e-6Initial program 99.1%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6476.1
Applied rewrites76.1%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6471.0
Applied rewrites71.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6471.0
Applied rewrites71.0%
Final simplification77.3%
(FPCore (x y z t a) :precision binary64 (if (<= z -4200000.0) (fma (/ (- z y) (- z)) a x) (if (<= z 2.9e+25) (fma (/ y (- -1.0 t)) a x) (fma (/ z (- t z)) a x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4200000.0) {
tmp = fma(((z - y) / -z), a, x);
} else if (z <= 2.9e+25) {
tmp = fma((y / (-1.0 - t)), a, x);
} else {
tmp = fma((z / (t - z)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4200000.0) tmp = fma(Float64(Float64(z - y) / Float64(-z)), a, x); elseif (z <= 2.9e+25) tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); else tmp = fma(Float64(z / Float64(t - z)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4200000.0], N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision], If[LessEqual[z, 2.9e+25], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(z / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4200000:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t - z}, a, x\right)\\
\end{array}
\end{array}
if z < -4.2e6Initial program 90.8%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6481.2
Applied rewrites81.2%
if -4.2e6 < z < 2.8999999999999999e25Initial program 99.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-+.f6488.9
Applied rewrites88.9%
if 2.8999999999999999e25 < z Initial program 94.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites91.5%
Final simplification88.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1200000.0) (not (<= z 2.8))) (- x a) (- x (* a (+ y (* y z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1200000.0) || !(z <= 2.8)) {
tmp = x - a;
} else {
tmp = x - (a * (y + (y * z)));
}
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) :: tmp
if ((z <= (-1200000.0d0)) .or. (.not. (z <= 2.8d0))) then
tmp = x - a
else
tmp = x - (a * (y + (y * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1200000.0) || !(z <= 2.8)) {
tmp = x - a;
} else {
tmp = x - (a * (y + (y * z)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1200000.0) or not (z <= 2.8): tmp = x - a else: tmp = x - (a * (y + (y * z))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1200000.0) || !(z <= 2.8)) tmp = Float64(x - a); else tmp = Float64(x - Float64(a * Float64(y + Float64(y * z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1200000.0) || ~((z <= 2.8))) tmp = x - a; else tmp = x - (a * (y + (y * z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1200000.0], N[Not[LessEqual[z, 2.8]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(a * N[(y + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1200000 \lor \neg \left(z \leq 2.8\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - a \cdot \left(y + y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.2e6 or 2.7999999999999998 < z Initial program 92.8%
Taylor expanded in z around inf
Applied rewrites75.3%
if -1.2e6 < z < 2.7999999999999998Initial program 99.1%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lower--.f6475.0
Applied rewrites75.0%
Taylor expanded in y around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6470.6
Applied rewrites70.6%
Taylor expanded in z around 0
lower-+.f64N/A
lower-*.f6470.6
Applied rewrites70.6%
Final simplification72.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -600000.0) (not (<= z 2.8))) (- x a) (- x (* a y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -600000.0) || !(z <= 2.8)) {
tmp = x - a;
} else {
tmp = x - (a * y);
}
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) :: tmp
if ((z <= (-600000.0d0)) .or. (.not. (z <= 2.8d0))) then
tmp = x - a
else
tmp = x - (a * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -600000.0) || !(z <= 2.8)) {
tmp = x - a;
} else {
tmp = x - (a * y);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -600000.0) or not (z <= 2.8): tmp = x - a else: tmp = x - (a * y) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -600000.0) || !(z <= 2.8)) tmp = Float64(x - a); else tmp = Float64(x - Float64(a * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -600000.0) || ~((z <= 2.8))) tmp = x - a; else tmp = x - (a * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -600000.0], N[Not[LessEqual[z, 2.8]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(a * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -600000 \lor \neg \left(z \leq 2.8\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - a \cdot y\\
\end{array}
\end{array}
if z < -6e5 or 2.7999999999999998 < z Initial program 92.8%
Taylor expanded in z around inf
Applied rewrites75.3%
if -6e5 < z < 2.7999999999999998Initial program 99.1%
Taylor expanded in z around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6489.9
Applied rewrites89.9%
Taylor expanded in t around 0
Applied rewrites70.6%
Final simplification72.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -470000.0) (not (<= z 42000.0))) (- x a) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -470000.0) || !(z <= 42000.0)) {
tmp = x - a;
} 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, 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) :: tmp
if ((z <= (-470000.0d0)) .or. (.not. (z <= 42000.0d0))) then
tmp = x - a
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -470000.0) || !(z <= 42000.0)) {
tmp = x - a;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -470000.0) or not (z <= 42000.0): tmp = x - a else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -470000.0) || !(z <= 42000.0)) tmp = Float64(x - a); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -470000.0) || ~((z <= 42000.0))) tmp = x - a; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -470000.0], N[Not[LessEqual[z, 42000.0]], $MachinePrecision]], N[(x - a), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -470000 \lor \neg \left(z \leq 42000\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.7e5 or 42000 < z Initial program 92.7%
Taylor expanded in z around inf
Applied rewrites76.2%
if -4.7e5 < z < 42000Initial program 99.1%
Taylor expanded in x around inf
Applied rewrites50.4%
Final simplification62.7%
(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 96.1%
Taylor expanded in x around inf
Applied rewrites50.3%
herbie shell --seed 2025085
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (- x (* (/ (- y z) (+ (- t z) 1)) a)))
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))