
(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));
}
real(8) function code(x, y, z, t, a)
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 9 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));
}
real(8) function code(x, y, z, t, a)
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 (* z a)))
(t_2 (* y (+ (/ z (- (* z a) t)) (/ x (* y t_1)))))
(t_3 (/ (- x (* y z)) t_1)))
(if (<= t_3 (- INFINITY))
t_2
(if (<= t_3 1e+223) t_3 (if (<= t_3 INFINITY) t_2 (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (z * a);
double t_2 = y * ((z / ((z * a) - t)) + (x / (y * t_1)));
double t_3 = (x - (y * z)) / t_1;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_3 <= 1e+223) {
tmp = t_3;
} else if (t_3 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = y / a;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t - (z * a);
double t_2 = y * ((z / ((z * a) - t)) + (x / (y * t_1)));
double t_3 = (x - (y * z)) / t_1;
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_3 <= 1e+223) {
tmp = t_3;
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - (z * a) t_2 = y * ((z / ((z * a) - t)) + (x / (y * t_1))) t_3 = (x - (y * z)) / t_1 tmp = 0 if t_3 <= -math.inf: tmp = t_2 elif t_3 <= 1e+223: tmp = t_3 elif t_3 <= math.inf: tmp = t_2 else: tmp = y / a return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(z * a)) t_2 = Float64(y * Float64(Float64(z / Float64(Float64(z * a) - t)) + Float64(x / Float64(y * t_1)))) t_3 = Float64(Float64(x - Float64(y * z)) / t_1) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = t_2; elseif (t_3 <= 1e+223) tmp = t_3; elseif (t_3 <= Inf) tmp = t_2; else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - (z * a); t_2 = y * ((z / ((z * a) - t)) + (x / (y * t_1))); t_3 = (x - (y * z)) / t_1; tmp = 0.0; if (t_3 <= -Inf) tmp = t_2; elseif (t_3 <= 1e+223) tmp = t_3; elseif (t_3 <= Inf) tmp = t_2; else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(N[(z / N[(N[(z * a), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(x / N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], t$95$2, If[LessEqual[t$95$3, 1e+223], t$95$3, If[LessEqual[t$95$3, Infinity], t$95$2, N[(y / a), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - z \cdot a\\
t_2 := y \cdot \left(\frac{z}{z \cdot a - t} + \frac{x}{y \cdot t\_1}\right)\\
t_3 := \frac{x - y \cdot z}{t\_1}\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 10^{+223}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0 or 1.00000000000000005e223 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0Initial program 68.3%
*-commutative68.3%
Simplified68.3%
Taylor expanded in y around inf 99.8%
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 1.00000000000000005e223Initial program 92.6%
if +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in z around inf 100.0%
Final simplification94.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- x (* y z)) t)))
(if (<= y -5.7e+227)
(/ y a)
(if (<= y -4.8e-31)
t_1
(if (<= y 1150000.0)
(/ x (- t (* z a)))
(if (<= y 1.6e+188) t_1 (/ y a)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (x - (y * z)) / t;
double tmp;
if (y <= -5.7e+227) {
tmp = y / a;
} else if (y <= -4.8e-31) {
tmp = t_1;
} else if (y <= 1150000.0) {
tmp = x / (t - (z * a));
} else if (y <= 1.6e+188) {
tmp = t_1;
} else {
tmp = y / a;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (x - (y * z)) / t
if (y <= (-5.7d+227)) then
tmp = y / a
else if (y <= (-4.8d-31)) then
tmp = t_1
else if (y <= 1150000.0d0) then
tmp = x / (t - (z * a))
else if (y <= 1.6d+188) then
tmp = t_1
else
tmp = 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 = (x - (y * z)) / t;
double tmp;
if (y <= -5.7e+227) {
tmp = y / a;
} else if (y <= -4.8e-31) {
tmp = t_1;
} else if (y <= 1150000.0) {
tmp = x / (t - (z * a));
} else if (y <= 1.6e+188) {
tmp = t_1;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (x - (y * z)) / t tmp = 0 if y <= -5.7e+227: tmp = y / a elif y <= -4.8e-31: tmp = t_1 elif y <= 1150000.0: tmp = x / (t - (z * a)) elif y <= 1.6e+188: tmp = t_1 else: tmp = y / a return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(x - Float64(y * z)) / t) tmp = 0.0 if (y <= -5.7e+227) tmp = Float64(y / a); elseif (y <= -4.8e-31) tmp = t_1; elseif (y <= 1150000.0) tmp = Float64(x / Float64(t - Float64(z * a))); elseif (y <= 1.6e+188) tmp = t_1; else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (x - (y * z)) / t; tmp = 0.0; if (y <= -5.7e+227) tmp = y / a; elseif (y <= -4.8e-31) tmp = t_1; elseif (y <= 1150000.0) tmp = x / (t - (z * a)); elseif (y <= 1.6e+188) tmp = t_1; else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[y, -5.7e+227], N[(y / a), $MachinePrecision], If[LessEqual[y, -4.8e-31], t$95$1, If[LessEqual[y, 1150000.0], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e+188], t$95$1, N[(y / a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x - y \cdot z}{t}\\
\mathbf{if}\;y \leq -5.7 \cdot 10^{+227}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1150000:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+188}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if y < -5.70000000000000011e227 or 1.59999999999999985e188 < y Initial program 60.8%
*-commutative60.8%
Simplified60.8%
Taylor expanded in z around inf 62.4%
if -5.70000000000000011e227 < y < -4.8e-31 or 1.15e6 < y < 1.59999999999999985e188Initial program 88.3%
*-commutative88.3%
Simplified88.3%
Taylor expanded in t around inf 66.3%
*-commutative66.3%
Simplified66.3%
if -4.8e-31 < y < 1.15e6Initial program 91.0%
*-commutative91.0%
Simplified91.0%
Taylor expanded in x around inf 77.4%
Final simplification70.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- x (* y z)) (- t (* z a))))) (if (<= t_1 1e+306) t_1 (- (/ y a) (/ (/ x z) a)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (x - (y * z)) / (t - (z * a));
double tmp;
if (t_1 <= 1e+306) {
tmp = t_1;
} else {
tmp = (y / a) - ((x / z) / a);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (x - (y * z)) / (t - (z * a))
if (t_1 <= 1d+306) then
tmp = t_1
else
tmp = (y / a) - ((x / z) / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x - (y * z)) / (t - (z * a));
double tmp;
if (t_1 <= 1e+306) {
tmp = t_1;
} else {
tmp = (y / a) - ((x / z) / a);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (x - (y * z)) / (t - (z * a)) tmp = 0 if t_1 <= 1e+306: tmp = t_1 else: tmp = (y / a) - ((x / z) / a) return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(z * a))) tmp = 0.0 if (t_1 <= 1e+306) tmp = t_1; else tmp = Float64(Float64(y / a) - Float64(Float64(x / z) / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (x - (y * z)) / (t - (z * a)); tmp = 0.0; if (t_1 <= 1e+306) tmp = t_1; else tmp = (y / a) - ((x / z) / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+306], t$95$1, N[(N[(y / a), $MachinePrecision] - N[(N[(x / z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x - y \cdot z}{t - z \cdot a}\\
\mathbf{if}\;t\_1 \leq 10^{+306}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} - \frac{\frac{x}{z}}{a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 1.00000000000000002e306Initial program 90.6%
if 1.00000000000000002e306 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 31.5%
*-commutative31.5%
Simplified31.5%
Taylor expanded in t around 0 21.5%
associate-*r/21.5%
mul-1-neg21.5%
sub-neg21.5%
distribute-rgt-neg-out21.5%
+-commutative21.5%
fma-define21.5%
neg-sub021.5%
fma-define21.5%
associate--r+21.5%
neg-sub021.5%
distribute-rgt-neg-out21.5%
remove-double-neg21.5%
*-commutative21.5%
Simplified21.5%
Taylor expanded in z around inf 83.5%
+-commutative83.5%
mul-1-neg83.5%
sub-neg83.5%
*-commutative83.5%
associate-/r*83.5%
Simplified83.5%
Final simplification89.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (/ y a) (/ (/ x z) a))))
(if (<= z -3.5e-58)
t_1
(if (<= z 1.2e-98)
(/ x (- t (* z a)))
(if (<= z 4.2e+20) (/ (- x (* y z)) t) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / a) - ((x / z) / a);
double tmp;
if (z <= -3.5e-58) {
tmp = t_1;
} else if (z <= 1.2e-98) {
tmp = x / (t - (z * a));
} else if (z <= 4.2e+20) {
tmp = (x - (y * z)) / t;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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 / a) - ((x / z) / a)
if (z <= (-3.5d-58)) then
tmp = t_1
else if (z <= 1.2d-98) then
tmp = x / (t - (z * a))
else if (z <= 4.2d+20) then
tmp = (x - (y * z)) / t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y / a) - ((x / z) / a);
double tmp;
if (z <= -3.5e-58) {
tmp = t_1;
} else if (z <= 1.2e-98) {
tmp = x / (t - (z * a));
} else if (z <= 4.2e+20) {
tmp = (x - (y * z)) / t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y / a) - ((x / z) / a) tmp = 0 if z <= -3.5e-58: tmp = t_1 elif z <= 1.2e-98: tmp = x / (t - (z * a)) elif z <= 4.2e+20: tmp = (x - (y * z)) / t else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y / a) - Float64(Float64(x / z) / a)) tmp = 0.0 if (z <= -3.5e-58) tmp = t_1; elseif (z <= 1.2e-98) tmp = Float64(x / Float64(t - Float64(z * a))); elseif (z <= 4.2e+20) tmp = Float64(Float64(x - Float64(y * z)) / t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y / a) - ((x / z) / a); tmp = 0.0; if (z <= -3.5e-58) tmp = t_1; elseif (z <= 1.2e-98) tmp = x / (t - (z * a)); elseif (z <= 4.2e+20) tmp = (x - (y * z)) / t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / a), $MachinePrecision] - N[(N[(x / z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.5e-58], t$95$1, If[LessEqual[z, 1.2e-98], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e+20], N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a} - \frac{\frac{x}{z}}{a}\\
\mathbf{if}\;z \leq -3.5 \cdot 10^{-58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-98}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+20}:\\
\;\;\;\;\frac{x - y \cdot z}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.4999999999999999e-58 or 4.2e20 < z Initial program 71.2%
*-commutative71.2%
Simplified71.2%
Taylor expanded in t around 0 48.2%
associate-*r/48.2%
mul-1-neg48.2%
sub-neg48.2%
distribute-rgt-neg-out48.2%
+-commutative48.2%
fma-define48.2%
neg-sub048.2%
fma-define48.2%
associate--r+48.2%
neg-sub048.2%
distribute-rgt-neg-out48.2%
remove-double-neg48.2%
*-commutative48.2%
Simplified48.2%
Taylor expanded in z around inf 70.2%
+-commutative70.2%
mul-1-neg70.2%
sub-neg70.2%
*-commutative70.2%
associate-/r*73.4%
Simplified73.4%
if -3.4999999999999999e-58 < z < 1.20000000000000002e-98Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around inf 82.2%
if 1.20000000000000002e-98 < z < 4.2e20Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in t around inf 74.6%
*-commutative74.6%
Simplified74.6%
Final simplification76.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= x -4.7e-26) (not (<= x 2.3e-26))) (/ x (- t (* z a))) (* y (/ z (- (* z a) t)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x <= -4.7e-26) || !(x <= 2.3e-26)) {
tmp = x / (t - (z * a));
} else {
tmp = y * (z / ((z * a) - t));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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 ((x <= (-4.7d-26)) .or. (.not. (x <= 2.3d-26))) then
tmp = x / (t - (z * a))
else
tmp = y * (z / ((z * a) - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x <= -4.7e-26) || !(x <= 2.3e-26)) {
tmp = x / (t - (z * a));
} else {
tmp = y * (z / ((z * a) - t));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (x <= -4.7e-26) or not (x <= 2.3e-26): tmp = x / (t - (z * a)) else: tmp = y * (z / ((z * a) - t)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((x <= -4.7e-26) || !(x <= 2.3e-26)) tmp = Float64(x / Float64(t - Float64(z * a))); else tmp = Float64(y * Float64(z / Float64(Float64(z * a) - t))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((x <= -4.7e-26) || ~((x <= 2.3e-26))) tmp = x / (t - (z * a)); else tmp = y * (z / ((z * a) - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[x, -4.7e-26], N[Not[LessEqual[x, 2.3e-26]], $MachinePrecision]], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(z / N[(N[(z * a), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7 \cdot 10^{-26} \lor \neg \left(x \leq 2.3 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{z \cdot a - t}\\
\end{array}
\end{array}
if x < -4.69999999999999989e-26 or 2.30000000000000009e-26 < x Initial program 82.3%
*-commutative82.3%
Simplified82.3%
Taylor expanded in x around inf 64.8%
if -4.69999999999999989e-26 < x < 2.30000000000000009e-26Initial program 85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in x around 0 72.1%
mul-1-neg72.1%
associate-/l*74.7%
distribute-rgt-neg-in74.7%
sub-neg74.7%
mul-1-neg74.7%
+-commutative74.7%
mul-1-neg74.7%
distribute-rgt-neg-in74.7%
fma-undefine74.7%
distribute-neg-frac274.7%
neg-sub074.7%
fma-undefine74.7%
distribute-rgt-neg-in74.7%
mul-1-neg74.7%
associate-*r*74.7%
neg-mul-174.7%
*-commutative74.7%
associate--r+74.7%
neg-sub074.7%
distribute-rgt-neg-out74.7%
remove-double-neg74.7%
*-commutative74.7%
Simplified74.7%
Final simplification69.4%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.6e-58)
(/ y a)
(if (<= z -1.24e-141)
(/ (- x) (* z a))
(if (<= z 6800000000.0) (/ x t) (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.6e-58) {
tmp = y / a;
} else if (z <= -1.24e-141) {
tmp = -x / (z * a);
} else if (z <= 6800000000.0) {
tmp = x / t;
} else {
tmp = y / a;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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 <= (-2.6d-58)) then
tmp = y / a
else if (z <= (-1.24d-141)) then
tmp = -x / (z * a)
else if (z <= 6800000000.0d0) then
tmp = x / t
else
tmp = y / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.6e-58) {
tmp = y / a;
} else if (z <= -1.24e-141) {
tmp = -x / (z * a);
} else if (z <= 6800000000.0) {
tmp = x / t;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -2.6e-58: tmp = y / a elif z <= -1.24e-141: tmp = -x / (z * a) elif z <= 6800000000.0: tmp = x / t else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.6e-58) tmp = Float64(y / a); elseif (z <= -1.24e-141) tmp = Float64(Float64(-x) / Float64(z * a)); elseif (z <= 6800000000.0) tmp = Float64(x / t); else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -2.6e-58) tmp = y / a; elseif (z <= -1.24e-141) tmp = -x / (z * a); elseif (z <= 6800000000.0) tmp = x / t; else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.6e-58], N[(y / a), $MachinePrecision], If[LessEqual[z, -1.24e-141], N[((-x) / N[(z * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6800000000.0], N[(x / t), $MachinePrecision], N[(y / a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{-58}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq -1.24 \cdot 10^{-141}:\\
\;\;\;\;\frac{-x}{z \cdot a}\\
\mathbf{elif}\;z \leq 6800000000:\\
\;\;\;\;\frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -2.60000000000000007e-58 or 6.8e9 < z Initial program 72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in z around inf 56.6%
if -2.60000000000000007e-58 < z < -1.24e-141Initial program 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in t around 0 58.5%
associate-*r/58.5%
mul-1-neg58.5%
sub-neg58.5%
distribute-rgt-neg-out58.5%
+-commutative58.5%
fma-define58.5%
neg-sub058.5%
fma-define58.5%
associate--r+58.5%
neg-sub058.5%
distribute-rgt-neg-out58.5%
remove-double-neg58.5%
*-commutative58.5%
Simplified58.5%
Taylor expanded in z around 0 49.3%
associate-*r/49.3%
neg-mul-149.3%
*-commutative49.3%
Simplified49.3%
if -1.24e-141 < z < 6.8e9Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 66.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3.7e-58) (not (<= z 2.05e+84))) (/ y a) (/ x (- t (* z a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3.7e-58) || !(z <= 2.05e+84)) {
tmp = y / a;
} else {
tmp = x / (t - (z * a));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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.7d-58)) .or. (.not. (z <= 2.05d+84))) then
tmp = y / a
else
tmp = x / (t - (z * a))
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.7e-58) || !(z <= 2.05e+84)) {
tmp = y / a;
} else {
tmp = x / (t - (z * a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -3.7e-58) or not (z <= 2.05e+84): tmp = y / a else: tmp = x / (t - (z * a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3.7e-58) || !(z <= 2.05e+84)) tmp = Float64(y / a); else tmp = Float64(x / Float64(t - Float64(z * a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -3.7e-58) || ~((z <= 2.05e+84))) tmp = y / a; else tmp = x / (t - (z * a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3.7e-58], N[Not[LessEqual[z, 2.05e+84]], $MachinePrecision]], N[(y / a), $MachinePrecision], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-58} \lor \neg \left(z \leq 2.05 \cdot 10^{+84}\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\end{array}
\end{array}
if z < -3.7000000000000003e-58 or 2.05000000000000015e84 < z Initial program 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in z around inf 59.6%
if -3.7000000000000003e-58 < z < 2.05000000000000015e84Initial program 97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around inf 73.8%
Final simplification66.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.24e-141) (not (<= z 120000000000.0))) (/ y a) (/ x t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.24e-141) || !(z <= 120000000000.0)) {
tmp = y / a;
} else {
tmp = x / t;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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.24d-141)) .or. (.not. (z <= 120000000000.0d0))) 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 <= -1.24e-141) || !(z <= 120000000000.0)) {
tmp = y / a;
} else {
tmp = x / t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.24e-141) or not (z <= 120000000000.0): tmp = y / a else: tmp = x / t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.24e-141) || !(z <= 120000000000.0)) 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 <= -1.24e-141) || ~((z <= 120000000000.0))) tmp = y / a; else tmp = x / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.24e-141], N[Not[LessEqual[z, 120000000000.0]], $MachinePrecision]], N[(y / a), $MachinePrecision], N[(x / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.24 \cdot 10^{-141} \lor \neg \left(z \leq 120000000000\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t}\\
\end{array}
\end{array}
if z < -1.24e-141 or 1.2e11 < z Initial program 75.3%
*-commutative75.3%
Simplified75.3%
Taylor expanded in z around inf 52.9%
if -1.24e-141 < z < 1.2e11Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 66.8%
Final simplification57.6%
(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;
}
real(8) function code(x, y, z, t, a)
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.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in z around 0 30.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* a z))) (t_2 (- (/ x t_1) (/ y (- (/ t z) a)))))
(if (< z -32113435955957344.0)
t_2
(if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 t_1)) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double t_2 = (x / t_1) - (y / ((t / z) - a));
double tmp;
if (z < -32113435955957344.0) {
tmp = t_2;
} else if (z < 3.5139522372978296e-86) {
tmp = (x - (y * z)) * (1.0 / t_1);
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) - (y / ((t / z) - a))
if (z < (-32113435955957344.0d0)) then
tmp = t_2
else if (z < 3.5139522372978296d-86) then
tmp = (x - (y * z)) * (1.0d0 / t_1)
else
tmp = t_2
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) - (y / ((t / z) - a));
double tmp;
if (z < -32113435955957344.0) {
tmp = t_2;
} else if (z < 3.5139522372978296e-86) {
tmp = (x - (y * z)) * (1.0 / t_1);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - (a * z) t_2 = (x / t_1) - (y / ((t / z) - a)) tmp = 0 if z < -32113435955957344.0: tmp = t_2 elif z < 3.5139522372978296e-86: tmp = (x - (y * z)) * (1.0 / t_1) else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(a * z)) t_2 = Float64(Float64(x / t_1) - Float64(y / Float64(Float64(t / z) - a))) tmp = 0.0 if (z < -32113435955957344.0) tmp = t_2; elseif (z < 3.5139522372978296e-86) tmp = Float64(Float64(x - Float64(y * z)) * Float64(1.0 / t_1)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - (a * z); t_2 = (x / t_1) - (y / ((t / z) - a)); tmp = 0.0; if (z < -32113435955957344.0) tmp = t_2; elseif (z < 3.5139522372978296e-86) tmp = (x - (y * z)) * (1.0 / t_1); else tmp = t_2; 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 / t$95$1), $MachinePrecision] - N[(y / N[(N[(t / z), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -32113435955957344.0], t$95$2, If[Less[z, 3.5139522372978296e-86], N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - a \cdot z\\
t_2 := \frac{x}{t\_1} - \frac{y}{\frac{t}{z} - a}\\
\mathbf{if}\;z < -32113435955957344:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z < 3.5139522372978296 \cdot 10^{-86}:\\
\;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
herbie shell --seed 2024165
(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))))