
(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(Float64(x - Float64(y * z)) / Float64(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[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y \cdot z}{t - a \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 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(Float64(x - Float64(y * z)) / Float64(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[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y \cdot z}{t - a \cdot z}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* a z))) (t_2 (/ x t_1)))
(if (or (<= a -4.8e+23) (not (<= a 3.2e+137)))
(- t_2 (* y (/ -1.0 a)))
(- t_2 (* y (/ z t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double t_2 = x / t_1;
double tmp;
if ((a <= -4.8e+23) || !(a <= 3.2e+137)) {
tmp = t_2 - (y * (-1.0 / a));
} else {
tmp = t_2 - (y * (z / 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) :: t_2
real(8) :: tmp
t_1 = t - (a * z)
t_2 = x / t_1
if ((a <= (-4.8d+23)) .or. (.not. (a <= 3.2d+137))) then
tmp = t_2 - (y * ((-1.0d0) / a))
else
tmp = t_2 - (y * (z / 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 = t - (a * z);
double t_2 = x / t_1;
double tmp;
if ((a <= -4.8e+23) || !(a <= 3.2e+137)) {
tmp = t_2 - (y * (-1.0 / a));
} else {
tmp = t_2 - (y * (z / t_1));
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - (a * z) t_2 = x / t_1 tmp = 0 if (a <= -4.8e+23) or not (a <= 3.2e+137): tmp = t_2 - (y * (-1.0 / a)) else: tmp = t_2 - (y * (z / t_1)) return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(a * z)) t_2 = Float64(x / t_1) tmp = 0.0 if ((a <= -4.8e+23) || !(a <= 3.2e+137)) tmp = Float64(t_2 - Float64(y * Float64(-1.0 / a))); else tmp = Float64(t_2 - Float64(y * Float64(z / t_1))); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - (a * z); t_2 = x / t_1; tmp = 0.0; if ((a <= -4.8e+23) || ~((a <= 3.2e+137))) tmp = t_2 - (y * (-1.0 / a)); else tmp = t_2 - (y * (z / t_1)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$1), $MachinePrecision]}, If[Or[LessEqual[a, -4.8e+23], N[Not[LessEqual[a, 3.2e+137]], $MachinePrecision]], N[(t$95$2 - N[(y * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 - N[(y * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - a \cdot z\\
t_2 := \frac{x}{t\_1}\\
\mathbf{if}\;a \leq -4.8 \cdot 10^{+23} \lor \neg \left(a \leq 3.2 \cdot 10^{+137}\right):\\
\;\;\;\;t\_2 - y \cdot \frac{-1}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_2 - y \cdot \frac{z}{t\_1}\\
\end{array}
\end{array}
if a < -4.8e23 or 3.20000000000000019e137 < a Initial program 72.1%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6474.2
Applied rewrites74.2%
Taylor expanded in z around inf
lower-/.f6490.8
Applied rewrites90.8%
if -4.8e23 < a < 3.20000000000000019e137Initial program 90.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6497.3
Applied rewrites97.3%
Final simplification94.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- x (* y z))) (t_2 (- t (* a z))) (t_3 (/ t_1 t_2)))
(if (<= t_3 -2e+306)
(* (- y) (/ z t_2))
(if (<= t_3 1e+303) (/ t_1 (fma (- a) z t)) (/ (- (/ x z) y) (- a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - (y * z);
double t_2 = t - (a * z);
double t_3 = t_1 / t_2;
double tmp;
if (t_3 <= -2e+306) {
tmp = -y * (z / t_2);
} else if (t_3 <= 1e+303) {
tmp = t_1 / fma(-a, z, t);
} else {
tmp = ((x / z) - y) / -a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(y * z)) t_2 = Float64(t - Float64(a * z)) t_3 = Float64(t_1 / t_2) tmp = 0.0 if (t_3 <= -2e+306) tmp = Float64(Float64(-y) * Float64(z / t_2)); elseif (t_3 <= 1e+303) tmp = Float64(t_1 / fma(Float64(-a), z, t)); else tmp = Float64(Float64(Float64(x / z) - y) / Float64(-a)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -2e+306], N[((-y) * N[(z / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e+303], N[(t$95$1 / N[((-a) * z + t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / (-a)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - y \cdot z\\
t_2 := t - a \cdot z\\
t_3 := \frac{t\_1}{t\_2}\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+306}:\\
\;\;\;\;\left(-y\right) \cdot \frac{z}{t\_2}\\
\mathbf{elif}\;t\_3 \leq 10^{+303}:\\
\;\;\;\;\frac{t\_1}{\mathsf{fma}\left(-a, z, t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z} - y}{-a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -2.00000000000000003e306Initial program 63.3%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
associate-*r/N/A
sub-divN/A
mul-1-negN/A
associate-*r/N/A
lower-neg.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f6484.9
Applied rewrites84.9%
if -2.00000000000000003e306 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 1e303Initial program 93.2%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6493.2
Applied rewrites93.2%
if 1e303 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 34.1%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6462.5
Applied rewrites62.5%
Taylor expanded in a around inf
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6480.8
Applied rewrites80.8%
Final simplification90.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* a z))) (t_2 (/ (- x (* y z)) t_1)))
(if (<= t_2 -2e+306)
(* (- y) (/ z t_1))
(if (<= t_2 1e+303) t_2 (/ (- (/ x z) y) (- a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double t_2 = (x - (y * z)) / t_1;
double tmp;
if (t_2 <= -2e+306) {
tmp = -y * (z / t_1);
} else if (t_2 <= 1e+303) {
tmp = t_2;
} else {
tmp = ((x / z) - y) / -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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = t - (a * z)
t_2 = (x - (y * z)) / t_1
if (t_2 <= (-2d+306)) then
tmp = -y * (z / t_1)
else if (t_2 <= 1d+303) then
tmp = t_2
else
tmp = ((x / z) - y) / -a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double t_2 = (x - (y * z)) / t_1;
double tmp;
if (t_2 <= -2e+306) {
tmp = -y * (z / t_1);
} else if (t_2 <= 1e+303) {
tmp = t_2;
} else {
tmp = ((x / z) - y) / -a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - (a * z) t_2 = (x - (y * z)) / t_1 tmp = 0 if t_2 <= -2e+306: tmp = -y * (z / t_1) elif t_2 <= 1e+303: tmp = t_2 else: tmp = ((x / z) - y) / -a return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(a * z)) t_2 = Float64(Float64(x - Float64(y * z)) / t_1) tmp = 0.0 if (t_2 <= -2e+306) tmp = Float64(Float64(-y) * Float64(z / t_1)); elseif (t_2 <= 1e+303) tmp = t_2; else tmp = Float64(Float64(Float64(x / z) - y) / Float64(-a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - (a * z); t_2 = (x - (y * z)) / t_1; tmp = 0.0; if (t_2 <= -2e+306) tmp = -y * (z / t_1); elseif (t_2 <= 1e+303) tmp = t_2; else tmp = ((x / z) - y) / -a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+306], N[((-y) * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+303], t$95$2, N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / (-a)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - a \cdot z\\
t_2 := \frac{x - y \cdot z}{t\_1}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+306}:\\
\;\;\;\;\left(-y\right) \cdot \frac{z}{t\_1}\\
\mathbf{elif}\;t\_2 \leq 10^{+303}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z} - y}{-a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -2.00000000000000003e306Initial program 63.3%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6499.9
Applied rewrites99.9%
Taylor expanded in x around 0
associate-*r/N/A
sub-divN/A
mul-1-negN/A
associate-*r/N/A
lower-neg.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f6484.9
Applied rewrites84.9%
if -2.00000000000000003e306 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 1e303Initial program 93.2%
if 1e303 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 34.1%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6462.5
Applied rewrites62.5%
Taylor expanded in a around inf
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6480.8
Applied rewrites80.8%
Final simplification90.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -1.1e-28) (not (<= a 1.1e+138))) (- (/ x (- t (* a z))) (* y (/ -1.0 a))) (/ (- x (* y z)) (fma (- a) z t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -1.1e-28) || !(a <= 1.1e+138)) {
tmp = (x / (t - (a * z))) - (y * (-1.0 / a));
} else {
tmp = (x - (y * z)) / fma(-a, z, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -1.1e-28) || !(a <= 1.1e+138)) tmp = Float64(Float64(x / Float64(t - Float64(a * z))) - Float64(y * Float64(-1.0 / a))); else tmp = Float64(Float64(x - Float64(y * z)) / fma(Float64(-a), z, t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -1.1e-28], N[Not[LessEqual[a, 1.1e+138]], $MachinePrecision]], N[(N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[((-a) * z + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{-28} \lor \neg \left(a \leq 1.1 \cdot 10^{+138}\right):\\
\;\;\;\;\frac{x}{t - a \cdot z} - y \cdot \frac{-1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y \cdot z}{\mathsf{fma}\left(-a, z, t\right)}\\
\end{array}
\end{array}
if a < -1.09999999999999998e-28 or 1.1e138 < a Initial program 71.0%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6476.2
Applied rewrites76.2%
Taylor expanded in z around inf
lower-/.f6490.6
Applied rewrites90.6%
if -1.09999999999999998e-28 < a < 1.1e138Initial program 92.5%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6492.5
Applied rewrites92.5%
Final simplification91.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -4.9e+50) (not (<= z 2.2e-71))) (/ (- (/ x z) y) (- a)) (/ x (fma (- a) z t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -4.9e+50) || !(z <= 2.2e-71)) {
tmp = ((x / z) - y) / -a;
} else {
tmp = x / fma(-a, z, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -4.9e+50) || !(z <= 2.2e-71)) tmp = Float64(Float64(Float64(x / z) - y) / Float64(-a)); else tmp = Float64(x / fma(Float64(-a), z, t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -4.9e+50], N[Not[LessEqual[z, 2.2e-71]], $MachinePrecision]], N[(N[(N[(x / z), $MachinePrecision] - y), $MachinePrecision] / (-a)), $MachinePrecision], N[(x / N[((-a) * z + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+50} \lor \neg \left(z \leq 2.2 \cdot 10^{-71}\right):\\
\;\;\;\;\frac{\frac{x}{z} - y}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-a, z, t\right)}\\
\end{array}
\end{array}
if z < -4.9000000000000002e50 or 2.19999999999999997e-71 < z Initial program 69.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6482.5
Applied rewrites82.5%
Taylor expanded in a around inf
associate-*r/N/A
sub-divN/A
distribute-lft-out--N/A
associate-*r/N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f6472.5
Applied rewrites72.5%
if -4.9000000000000002e50 < z < 2.19999999999999997e-71Initial program 98.1%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6498.1
Applied rewrites98.1%
Taylor expanded in x around inf
Applied rewrites79.6%
Final simplification75.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.7e+77) (/ y a) (if (<= z 2.2e-71) (/ x (fma (- a) z t)) (* (- y) (/ z (- t (* a z)))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.7e+77) {
tmp = y / a;
} else if (z <= 2.2e-71) {
tmp = x / fma(-a, z, t);
} else {
tmp = -y * (z / (t - (a * z)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.7e+77) tmp = Float64(y / a); elseif (z <= 2.2e-71) tmp = Float64(x / fma(Float64(-a), z, t)); else tmp = Float64(Float64(-y) * Float64(z / Float64(t - Float64(a * z)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.7e+77], N[(y / a), $MachinePrecision], If[LessEqual[z, 2.2e-71], N[(x / N[((-a) * z + t), $MachinePrecision]), $MachinePrecision], N[((-y) * N[(z / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+77}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-71}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-a, z, t\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-y\right) \cdot \frac{z}{t - a \cdot z}\\
\end{array}
\end{array}
if z < -1.69999999999999998e77Initial program 66.2%
Taylor expanded in z around inf
lower-/.f6460.0
Applied rewrites60.0%
if -1.69999999999999998e77 < z < 2.19999999999999997e-71Initial program 96.7%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6496.8
Applied rewrites96.8%
Taylor expanded in x around inf
Applied rewrites77.4%
if 2.19999999999999997e-71 < z Initial program 70.8%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift--.f6484.0
Applied rewrites84.0%
Taylor expanded in x around 0
associate-*r/N/A
sub-divN/A
mul-1-negN/A
associate-*r/N/A
lower-neg.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f6467.0
Applied rewrites67.0%
Final simplification70.9%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.7e+77) (not (<= z 1.95e+51))) (/ y a) (/ x (fma (- a) z t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.7e+77) || !(z <= 1.95e+51)) {
tmp = y / a;
} else {
tmp = x / fma(-a, z, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.7e+77) || !(z <= 1.95e+51)) tmp = Float64(y / a); else tmp = Float64(x / fma(Float64(-a), z, t)); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.7e+77], N[Not[LessEqual[z, 1.95e+51]], $MachinePrecision]], N[(y / a), $MachinePrecision], N[(x / N[((-a) * z + t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+77} \lor \neg \left(z \leq 1.95 \cdot 10^{+51}\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-a, z, t\right)}\\
\end{array}
\end{array}
if z < -1.69999999999999998e77 or 1.94999999999999992e51 < z Initial program 65.5%
Taylor expanded in z around inf
lower-/.f6461.4
Applied rewrites61.4%
if -1.69999999999999998e77 < z < 1.94999999999999992e51Initial program 97.0%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6497.0
Applied rewrites97.0%
Taylor expanded in x around inf
Applied rewrites75.2%
Final simplification69.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.7e+77) (not (<= z 1.95e+51))) (/ y a) (/ x (- t (* a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.7e+77) || !(z <= 1.95e+51)) {
tmp = y / a;
} else {
tmp = x / (t - (a * 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 <= (-1.7d+77)) .or. (.not. (z <= 1.95d+51))) then
tmp = y / a
else
tmp = x / (t - (a * 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 <= -1.7e+77) || !(z <= 1.95e+51)) {
tmp = y / a;
} else {
tmp = x / (t - (a * z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.7e+77) or not (z <= 1.95e+51): tmp = y / a else: tmp = x / (t - (a * z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.7e+77) || !(z <= 1.95e+51)) tmp = Float64(y / a); else tmp = Float64(x / Float64(t - Float64(a * z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.7e+77) || ~((z <= 1.95e+51))) tmp = y / a; else tmp = x / (t - (a * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.7e+77], N[Not[LessEqual[z, 1.95e+51]], $MachinePrecision]], N[(y / a), $MachinePrecision], N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+77} \lor \neg \left(z \leq 1.95 \cdot 10^{+51}\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - a \cdot z}\\
\end{array}
\end{array}
if z < -1.69999999999999998e77 or 1.94999999999999992e51 < z Initial program 65.5%
Taylor expanded in z around inf
lower-/.f6461.4
Applied rewrites61.4%
if -1.69999999999999998e77 < z < 1.94999999999999992e51Initial program 97.0%
Taylor expanded in x around inf
Applied rewrites75.2%
Final simplification69.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.8e+50) (not (<= z 2.2e-71))) (/ y a) (/ x t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.8e+50) || !(z <= 2.2e-71)) {
tmp = y / a;
} else {
tmp = x / 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) :: tmp
if ((z <= (-3.8d+50)) .or. (.not. (z <= 2.2d-71))) then
tmp = y / a
else
tmp = x / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.8e+50) || !(z <= 2.2e-71)) {
tmp = y / a;
} else {
tmp = x / t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -3.8e+50) or not (z <= 2.2e-71): tmp = y / a else: tmp = x / t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.8e+50) || !(z <= 2.2e-71)) tmp = Float64(y / a); else tmp = Float64(x / t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -3.8e+50) || ~((z <= 2.2e-71))) tmp = y / a; else tmp = x / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.8e+50], N[Not[LessEqual[z, 2.2e-71]], $MachinePrecision]], N[(y / a), $MachinePrecision], N[(x / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+50} \lor \neg \left(z \leq 2.2 \cdot 10^{-71}\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t}\\
\end{array}
\end{array}
if z < -3.79999999999999987e50 or 2.19999999999999997e-71 < z Initial program 69.7%
Taylor expanded in z around inf
lower-/.f6456.0
Applied rewrites56.0%
if -3.79999999999999987e50 < z < 2.19999999999999997e-71Initial program 98.1%
Taylor expanded in z around 0
lower-/.f6455.0
Applied rewrites55.0%
Final simplification55.5%
(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}
\\
\frac{x}{t}
\end{array}
Initial program 83.0%
Taylor expanded in z around 0
lower-/.f6432.6
Applied rewrites32.6%
herbie shell --seed 2025084
(FPCore (x y z t a)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:alt
(! :herbie-platform default (if (< z -32113435955957344) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 4392440296622287/125000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (- x (* y z)) (/ 1 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))))))
(/ (- x (* y z)) (- t (* a z))))