
(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 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.2
Applied rewrites99.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- y z) (/ (+ (- t z) 1.0) a)))) (if (or (<= t_1 -1e+125) (not (<= t_1 1e+76))) (- a) x)))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if ((t_1 <= -1e+125) || !(t_1 <= 1e+76)) {
tmp = -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) :: t_1
real(8) :: tmp
t_1 = (y - z) / (((t - z) + 1.0d0) / a)
if ((t_1 <= (-1d+125)) .or. (.not. (t_1 <= 1d+76))) then
tmp = -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 t_1 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if ((t_1 <= -1e+125) || !(t_1 <= 1e+76)) {
tmp = -a;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y - z) / (((t - z) + 1.0) / a) tmp = 0 if (t_1 <= -1e+125) or not (t_1 <= 1e+76): tmp = -a else: tmp = x return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a)) tmp = 0.0 if ((t_1 <= -1e+125) || !(t_1 <= 1e+76)) tmp = Float64(-a); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y - z) / (((t - z) + 1.0) / a); tmp = 0.0; if ((t_1 <= -1e+125) || ~((t_1 <= 1e+76))) tmp = -a; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e+125], N[Not[LessEqual[t$95$1, 1e+76]], $MachinePrecision]], (-a), x]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+125} \lor \neg \left(t\_1 \leq 10^{+76}\right):\\
\;\;\;\;-a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < -9.9999999999999992e124 or 1e76 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) Initial program 99.7%
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 a around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-+.f6456.5
Applied rewrites56.5%
Taylor expanded in z around inf
mul-1-negN/A
lift-neg.f6429.4
Applied rewrites29.4%
if -9.9999999999999992e124 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) #s(literal 1 binary64)) a)) < 1e76Initial program 98.7%
Taylor expanded in x around inf
Applied rewrites66.5%
Final simplification54.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) (- z)) a x)))
(if (<= z -1.33e-69)
t_1
(if (<= z 5.4e-174)
(- x (/ (* y a) t))
(if (<= z 5.8e-65)
(/ (* (- z y) a) (- 1.0 z))
(if (<= z 2000.0) (fma (/ (- z y) t) a x) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / -z), a, x);
double tmp;
if (z <= -1.33e-69) {
tmp = t_1;
} else if (z <= 5.4e-174) {
tmp = x - ((y * a) / t);
} else if (z <= 5.8e-65) {
tmp = ((z - y) * a) / (1.0 - z);
} else if (z <= 2000.0) {
tmp = fma(((z - y) / t), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / Float64(-z)), a, x) tmp = 0.0 if (z <= -1.33e-69) tmp = t_1; elseif (z <= 5.4e-174) tmp = Float64(x - Float64(Float64(y * a) / t)); elseif (z <= 5.8e-65) tmp = Float64(Float64(Float64(z - y) * a) / Float64(1.0 - z)); elseif (z <= 2000.0) tmp = fma(Float64(Float64(z - y) / t), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[z, -1.33e-69], t$95$1, If[LessEqual[z, 5.4e-174], N[(x - N[(N[(y * a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e-65], N[(N[(N[(z - y), $MachinePrecision] * a), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2000.0], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{if}\;z \leq -1.33 \cdot 10^{-69}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-174}:\\
\;\;\;\;x - \frac{y \cdot a}{t}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-65}:\\
\;\;\;\;\frac{\left(z - y\right) \cdot a}{1 - z}\\
\mathbf{elif}\;z \leq 2000:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.32999999999999992e-69 or 2e3 < z Initial program 98.5%
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 0
Applied rewrites88.3%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6483.5
Applied rewrites83.5%
if -1.32999999999999992e-69 < z < 5.39999999999999975e-174Initial program 99.9%
Taylor expanded in t around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6469.4
Applied rewrites69.4%
Taylor expanded in y around inf
Applied rewrites70.7%
if 5.39999999999999975e-174 < z < 5.7999999999999996e-65Initial program 99.7%
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 a around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-+.f6475.7
Applied rewrites75.7%
Taylor expanded in t around 0
Applied rewrites71.4%
if 5.7999999999999996e-65 < z < 2e3Initial program 99.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-+.f64100.0
Applied rewrites100.0%
Taylor expanded in t around inf
associate--l+90.9
+-commutative90.9
Applied rewrites90.9%
Final simplification79.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- z y) t) a x)))
(if (<= t -4.6e+43)
t_1
(if (<= t -2.3e-99)
(- x a)
(if (<= t 4.8e-278)
(/ (* (- z y) a) (- 1.0 z))
(if (<= t 7.8e+25) (- x a) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / t), a, x);
double tmp;
if (t <= -4.6e+43) {
tmp = t_1;
} else if (t <= -2.3e-99) {
tmp = x - a;
} else if (t <= 4.8e-278) {
tmp = ((z - y) * a) / (1.0 - z);
} else if (t <= 7.8e+25) {
tmp = x - a;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / t), a, x) tmp = 0.0 if (t <= -4.6e+43) tmp = t_1; elseif (t <= -2.3e-99) tmp = Float64(x - a); elseif (t <= 4.8e-278) tmp = Float64(Float64(Float64(z - y) * a) / Float64(1.0 - z)); elseif (t <= 7.8e+25) tmp = Float64(x - a); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision]}, If[LessEqual[t, -4.6e+43], t$95$1, If[LessEqual[t, -2.3e-99], N[(x - a), $MachinePrecision], If[LessEqual[t, 4.8e-278], N[(N[(N[(z - y), $MachinePrecision] * a), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 7.8e+25], N[(x - a), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{if}\;t \leq -4.6 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq -2.3 \cdot 10^{-99}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;t \leq 4.8 \cdot 10^{-278}:\\
\;\;\;\;\frac{\left(z - y\right) \cdot a}{1 - z}\\
\mathbf{elif}\;t \leq 7.8 \cdot 10^{+25}:\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.6000000000000005e43 or 7.8000000000000004e25 < t Initial program 99.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-+.f6498.1
Applied rewrites98.1%
Taylor expanded in t around inf
associate--l+86.5
+-commutative86.5
Applied rewrites86.5%
if -4.6000000000000005e43 < t < -2.2999999999999998e-99 or 4.8e-278 < t < 7.8000000000000004e25Initial program 98.9%
Taylor expanded in z around inf
Applied rewrites66.9%
if -2.2999999999999998e-99 < t < 4.8e-278Initial program 98.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 a around inf
sub-divN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-+.f6461.4
Applied rewrites61.4%
Taylor expanded in t around 0
Applied rewrites61.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -430000.0) (not (<= t 1.95e-28))) (fma (/ (- z y) (- t z)) a x) (fma (/ (- z y) (- 1.0 z)) a x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -430000.0) || !(t <= 1.95e-28)) {
tmp = fma(((z - y) / (t - z)), a, x);
} else {
tmp = fma(((z - y) / (1.0 - z)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -430000.0) || !(t <= 1.95e-28)) tmp = fma(Float64(Float64(z - y) / Float64(t - z)), a, x); else tmp = fma(Float64(Float64(z - y) / Float64(1.0 - z)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -430000.0], N[Not[LessEqual[t, 1.95e-28]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -430000 \lor \neg \left(t \leq 1.95 \cdot 10^{-28}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t - z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 - z}, a, x\right)\\
\end{array}
\end{array}
if t < -4.3e5 or 1.94999999999999999e-28 < t Initial program 99.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-+.f6498.4
Applied rewrites98.4%
Taylor expanded in t around inf
Applied rewrites97.9%
if -4.3e5 < t < 1.94999999999999999e-28Initial program 98.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 0
Applied rewrites99.9%
Final simplification98.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.25e+136) (not (<= t 3.5e+45))) (- x (* (- y z) (/ a t))) (fma (/ (- z y) (- 1.0 z)) a x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.25e+136) || !(t <= 3.5e+45)) {
tmp = x - ((y - z) * (a / t));
} else {
tmp = fma(((z - y) / (1.0 - z)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.25e+136) || !(t <= 3.5e+45)) tmp = Float64(x - Float64(Float64(y - z) * Float64(a / t))); else tmp = fma(Float64(Float64(z - y) / Float64(1.0 - z)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.25e+136], N[Not[LessEqual[t, 3.5e+45]], $MachinePrecision]], N[(x - N[(N[(y - z), $MachinePrecision] * N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z - y), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.25 \cdot 10^{+136} \lor \neg \left(t \leq 3.5 \cdot 10^{+45}\right):\\
\;\;\;\;x - \left(y - z\right) \cdot \frac{a}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{1 - z}, a, x\right)\\
\end{array}
\end{array}
if t < -1.25e136 or 3.50000000000000023e45 < t Initial program 99.8%
Taylor expanded in t around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f6482.9
Applied rewrites82.9%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f6494.6
Applied rewrites94.6%
if -1.25e136 < t < 3.50000000000000023e45Initial program 98.7%
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 0
Applied rewrites94.9%
Final simplification94.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -0.0057) (not (<= z 196.0))) (fma (/ (- z y) (- z)) a x) (- x (/ (* a y) (+ 1.0 t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -0.0057) || !(z <= 196.0)) {
tmp = fma(((z - y) / -z), a, x);
} else {
tmp = x - ((a * y) / (1.0 + t));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -0.0057) || !(z <= 196.0)) tmp = fma(Float64(Float64(z - y) / Float64(-z)), a, x); else tmp = Float64(x - Float64(Float64(a * y) / Float64(1.0 + t))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -0.0057], N[Not[LessEqual[z, 196.0]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision], N[(x - N[(N[(a * y), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0057 \lor \neg \left(z \leq 196\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{a \cdot y}{1 + t}\\
\end{array}
\end{array}
if z < -0.0057000000000000002 or 196 < z Initial program 98.4%
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 0
Applied rewrites87.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6487.1
Applied rewrites87.1%
if -0.0057000000000000002 < z < 196Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites38.4%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f64N/A
lift-+.f6490.6
Applied rewrites90.6%
Final simplification88.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -8e+17) (not (<= z 225.0))) (fma (/ (- z y) (- z)) a x) (- x (* a (/ y (+ 1.0 t))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -8e+17) || !(z <= 225.0)) {
tmp = fma(((z - y) / -z), a, x);
} else {
tmp = x - (a * (y / (1.0 + t)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -8e+17) || !(z <= 225.0)) tmp = fma(Float64(Float64(z - y) / Float64(-z)), a, x); else tmp = Float64(x - Float64(a * Float64(y / Float64(1.0 + t)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -8e+17], N[Not[LessEqual[z, 225.0]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / (-z)), $MachinePrecision] * a + x), $MachinePrecision], N[(x - N[(a * N[(y / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+17} \lor \neg \left(z \leq 225\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{-z}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a \cdot \frac{y}{1 + t}\\
\end{array}
\end{array}
if z < -8e17 or 225 < z Initial program 98.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 0
Applied rewrites88.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6488.0
Applied rewrites88.0%
if -8e17 < z < 225Initial program 99.8%
Taylor expanded in z around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f6488.6
Applied rewrites88.6%
Final simplification88.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -4.6e+43) (not (<= t 7.8e+25))) (fma (/ (- z y) t) a x) (- x a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -4.6e+43) || !(t <= 7.8e+25)) {
tmp = fma(((z - y) / t), a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -4.6e+43) || !(t <= 7.8e+25)) tmp = fma(Float64(Float64(z - y) / t), a, x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -4.6e+43], N[Not[LessEqual[t, 7.8e+25]], $MachinePrecision]], N[(N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision] * a + x), $MachinePrecision], N[(x - a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{+43} \lor \neg \left(t \leq 7.8 \cdot 10^{+25}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if t < -4.6000000000000005e43 or 7.8000000000000004e25 < t Initial program 99.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-+.f6498.1
Applied rewrites98.1%
Taylor expanded in t around inf
associate--l+86.5
+-commutative86.5
Applied rewrites86.5%
if -4.6000000000000005e43 < t < 7.8000000000000004e25Initial program 98.6%
Taylor expanded in z around inf
Applied rewrites57.7%
Final simplification69.6%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -4.1e+43) (not (<= t 1.36e+29))) (fma (/ (- y) t) a x) (- x a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -4.1e+43) || !(t <= 1.36e+29)) {
tmp = fma((-y / t), a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -4.1e+43) || !(t <= 1.36e+29)) tmp = fma(Float64(Float64(-y) / t), a, x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -4.1e+43], N[Not[LessEqual[t, 1.36e+29]], $MachinePrecision]], N[(N[((-y) / t), $MachinePrecision] * a + x), $MachinePrecision], N[(x - a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.1 \cdot 10^{+43} \lor \neg \left(t \leq 1.36 \cdot 10^{+29}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-y}{t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if t < -4.1e43 or 1.36e29 < t Initial program 99.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-+.f6498.1
Applied rewrites98.1%
Taylor expanded in t around inf
associate--l+86.5
+-commutative86.5
Applied rewrites86.5%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6479.9
Applied rewrites79.9%
if -4.1e43 < t < 1.36e29Initial program 98.6%
Taylor expanded in z around inf
Applied rewrites57.7%
Final simplification66.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.33e-69) (not (<= z 1.4e+59))) (- x a) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.33e-69) || !(z <= 1.4e+59)) {
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 <= (-1.33d-69)) .or. (.not. (z <= 1.4d+59))) 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 <= -1.33e-69) || !(z <= 1.4e+59)) {
tmp = x - a;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.33e-69) or not (z <= 1.4e+59): tmp = x - a else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.33e-69) || !(z <= 1.4e+59)) 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 <= -1.33e-69) || ~((z <= 1.4e+59))) tmp = x - a; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.33e-69], N[Not[LessEqual[z, 1.4e+59]], $MachinePrecision]], N[(x - a), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.33 \cdot 10^{-69} \lor \neg \left(z \leq 1.4 \cdot 10^{+59}\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.32999999999999992e-69 or 1.3999999999999999e59 < z Initial program 98.4%
Taylor expanded in z around inf
Applied rewrites71.1%
if -1.32999999999999992e-69 < z < 1.3999999999999999e59Initial program 99.8%
Taylor expanded in x around inf
Applied rewrites51.5%
Final simplification62.0%
(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 99.1%
Taylor expanded in x around inf
Applied rewrites47.9%
(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(Float64(y - z) / 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[(N[(y - z), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\left(t - z\right) + 1} \cdot a
\end{array}
herbie shell --seed 2025064
(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))))