
(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 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));
}
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 (fma z (- a) t)))
(if (<= (/ (- x (* y z)) (- t (* z a))) INFINITY)
(fma -1.0 (* y (/ z t_1)) (/ x t_1))
(/ y a))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(z, -a, t);
double tmp;
if (((x - (y * z)) / (t - (z * a))) <= ((double) INFINITY)) {
tmp = fma(-1.0, (y * (z / t_1)), (x / t_1));
} else {
tmp = y / a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(z, Float64(-a), t) tmp = 0.0 if (Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(z * a))) <= Inf) tmp = fma(-1.0, Float64(y * Float64(z / t_1)), Float64(x / t_1)); else tmp = Float64(y / a); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z * (-a) + t), $MachinePrecision]}, If[LessEqual[N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(-1.0 * N[(y * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(x / t$95$1), $MachinePrecision]), $MachinePrecision], N[(y / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, -a, t\right)\\
\mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(-1, y \cdot \frac{z}{t\_1}, \frac{x}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0Initial program 90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in x around 0 90.5%
fma-define90.5%
associate-/l*94.5%
sub-neg94.5%
mul-1-neg94.5%
+-commutative94.5%
mul-1-neg94.5%
distribute-rgt-neg-in94.5%
fma-undefine94.5%
fma-undefine94.5%
distribute-rgt-neg-in94.5%
mul-1-neg94.5%
associate-*r*94.5%
neg-mul-194.5%
*-commutative94.5%
fma-define94.5%
cancel-sign-sub-inv94.5%
*-commutative94.5%
+-commutative94.5%
fma-define94.5%
Simplified94.5%
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.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* z a))) (t_2 (/ (- x (* y z)) t_1)))
(if (or (<= t_2 (- INFINITY)) (not (<= t_2 5e+300)))
(/ (- y (/ x z)) a)
(+ (/ (* y z) (- (* z a) t)) (/ x t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (z * a);
double t_2 = (x - (y * z)) / t_1;
double tmp;
if ((t_2 <= -((double) INFINITY)) || !(t_2 <= 5e+300)) {
tmp = (y - (x / z)) / a;
} else {
tmp = ((y * z) / ((z * a) - t)) + (x / t_1);
}
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 = (x - (y * z)) / t_1;
double tmp;
if ((t_2 <= -Double.POSITIVE_INFINITY) || !(t_2 <= 5e+300)) {
tmp = (y - (x / z)) / a;
} else {
tmp = ((y * z) / ((z * a) - t)) + (x / t_1);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - (z * a) t_2 = (x - (y * z)) / t_1 tmp = 0 if (t_2 <= -math.inf) or not (t_2 <= 5e+300): tmp = (y - (x / z)) / a else: tmp = ((y * z) / ((z * a) - t)) + (x / t_1) return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(z * a)) t_2 = Float64(Float64(x - Float64(y * z)) / t_1) tmp = 0.0 if ((t_2 <= Float64(-Inf)) || !(t_2 <= 5e+300)) tmp = Float64(Float64(y - Float64(x / z)) / a); else tmp = Float64(Float64(Float64(y * z) / Float64(Float64(z * a) - t)) + Float64(x / t_1)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - (z * a); t_2 = (x - (y * z)) / t_1; tmp = 0.0; if ((t_2 <= -Inf) || ~((t_2 <= 5e+300))) tmp = (y - (x / z)) / a; else tmp = ((y * z) / ((z * a) - t)) + (x / t_1); 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[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, (-Infinity)], N[Not[LessEqual[t$95$2, 5e+300]], $MachinePrecision]], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(N[(y * z), $MachinePrecision] / N[(N[(z * a), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(x / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - z \cdot a\\
t_2 := \frac{x - y \cdot z}{t\_1}\\
\mathbf{if}\;t\_2 \leq -\infty \lor \neg \left(t\_2 \leq 5 \cdot 10^{+300}\right):\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot z}{z \cdot a - t} + \frac{x}{t\_1}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0 or 5.00000000000000026e300 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 41.6%
*-commutative41.6%
Simplified41.6%
Taylor expanded in x around 0 41.6%
fma-define41.6%
associate-/l*78.3%
sub-neg78.3%
mul-1-neg78.3%
+-commutative78.3%
mul-1-neg78.3%
distribute-rgt-neg-in78.3%
fma-undefine78.3%
fma-undefine78.3%
distribute-rgt-neg-in78.3%
mul-1-neg78.3%
associate-*r*78.3%
neg-mul-178.3%
*-commutative78.3%
fma-define78.3%
cancel-sign-sub-inv78.3%
*-commutative78.3%
+-commutative78.3%
fma-define78.3%
Simplified78.3%
Taylor expanded in a around inf 83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 5.00000000000000026e300Initial program 95.3%
*-commutative95.3%
Simplified95.3%
Taylor expanded in x around 0 95.3%
Final simplification93.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- x (* y z)) (- t (* z a)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+300)))
(/ (- y (/ x z)) a)
t_1)))
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 <= -((double) INFINITY)) || !(t_1 <= 5e+300)) {
tmp = (y - (x / z)) / a;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x - (y * z)) / (t - (z * a));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+300)) {
tmp = (y - (x / z)) / a;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (x - (y * z)) / (t - (z * a)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 5e+300): tmp = (y - (x / z)) / a else: tmp = t_1 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 <= Float64(-Inf)) || !(t_1 <= 5e+300)) tmp = Float64(Float64(y - Float64(x / z)) / a); else tmp = t_1; 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 <= -Inf) || ~((t_1 <= 5e+300))) tmp = (y - (x / z)) / a; else tmp = t_1; 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[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+300]], $MachinePrecision]], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x - y \cdot z}{t - z \cdot a}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{+300}\right):\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0 or 5.00000000000000026e300 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 41.6%
*-commutative41.6%
Simplified41.6%
Taylor expanded in x around 0 41.6%
fma-define41.6%
associate-/l*78.3%
sub-neg78.3%
mul-1-neg78.3%
+-commutative78.3%
mul-1-neg78.3%
distribute-rgt-neg-in78.3%
fma-undefine78.3%
fma-undefine78.3%
distribute-rgt-neg-in78.3%
mul-1-neg78.3%
associate-*r*78.3%
neg-mul-178.3%
*-commutative78.3%
fma-define78.3%
cancel-sign-sub-inv78.3%
*-commutative78.3%
+-commutative78.3%
fma-define78.3%
Simplified78.3%
Taylor expanded in a around inf 83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 5.00000000000000026e300Initial program 95.3%
Final simplification93.6%
(FPCore (x y z t a)
:precision binary64
(if (<= z -7.4e+143)
(/ y a)
(if (<= z -7.5e-110)
(/ (- x (* y z)) t)
(if (<= z 1800000.0) (/ x (- t (* z a))) (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -7.4e+143) {
tmp = y / a;
} else if (z <= -7.5e-110) {
tmp = (x - (y * z)) / t;
} else if (z <= 1800000.0) {
tmp = x / (t - (z * a));
} 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 <= (-7.4d+143)) then
tmp = y / a
else if (z <= (-7.5d-110)) then
tmp = (x - (y * z)) / t
else if (z <= 1800000.0d0) then
tmp = x / (t - (z * a))
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 <= -7.4e+143) {
tmp = y / a;
} else if (z <= -7.5e-110) {
tmp = (x - (y * z)) / t;
} else if (z <= 1800000.0) {
tmp = x / (t - (z * a));
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -7.4e+143: tmp = y / a elif z <= -7.5e-110: tmp = (x - (y * z)) / t elif z <= 1800000.0: tmp = x / (t - (z * a)) else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -7.4e+143) tmp = Float64(y / a); elseif (z <= -7.5e-110) tmp = Float64(Float64(x - Float64(y * z)) / t); elseif (z <= 1800000.0) tmp = Float64(x / Float64(t - Float64(z * a))); else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -7.4e+143) tmp = y / a; elseif (z <= -7.5e-110) tmp = (x - (y * z)) / t; elseif (z <= 1800000.0) tmp = x / (t - (z * a)); else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -7.4e+143], N[(y / a), $MachinePrecision], If[LessEqual[z, -7.5e-110], N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 1800000.0], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.4 \cdot 10^{+143}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq -7.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{x - y \cdot z}{t}\\
\mathbf{elif}\;z \leq 1800000:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -7.4000000000000003e143 or 1.8e6 < z Initial program 65.8%
*-commutative65.8%
Simplified65.8%
Taylor expanded in z around inf 69.0%
if -7.4000000000000003e143 < z < -7.50000000000000053e-110Initial program 91.5%
*-commutative91.5%
Simplified91.5%
Taylor expanded in t around inf 64.0%
if -7.50000000000000053e-110 < z < 1.8e6Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 75.0%
Final simplification70.8%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- y (/ x z)) a)))
(if (<= z -2.95e+35)
t_1
(if (<= z -1.22e-107)
(/ (- x (* y z)) t)
(if (<= z 2.4e-30) (/ x (- t (* z a))) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y - (x / z)) / a;
double tmp;
if (z <= -2.95e+35) {
tmp = t_1;
} else if (z <= -1.22e-107) {
tmp = (x - (y * z)) / t;
} else if (z <= 2.4e-30) {
tmp = x / (t - (z * a));
} 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 - (x / z)) / a
if (z <= (-2.95d+35)) then
tmp = t_1
else if (z <= (-1.22d-107)) then
tmp = (x - (y * z)) / t
else if (z <= 2.4d-30) then
tmp = x / (t - (z * a))
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 - (x / z)) / a;
double tmp;
if (z <= -2.95e+35) {
tmp = t_1;
} else if (z <= -1.22e-107) {
tmp = (x - (y * z)) / t;
} else if (z <= 2.4e-30) {
tmp = x / (t - (z * a));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y - (x / z)) / a tmp = 0 if z <= -2.95e+35: tmp = t_1 elif z <= -1.22e-107: tmp = (x - (y * z)) / t elif z <= 2.4e-30: tmp = x / (t - (z * a)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y - Float64(x / z)) / a) tmp = 0.0 if (z <= -2.95e+35) tmp = t_1; elseif (z <= -1.22e-107) tmp = Float64(Float64(x - Float64(y * z)) / t); elseif (z <= 2.4e-30) tmp = Float64(x / Float64(t - Float64(z * a))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y - (x / z)) / a; tmp = 0.0; if (z <= -2.95e+35) tmp = t_1; elseif (z <= -1.22e-107) tmp = (x - (y * z)) / t; elseif (z <= 2.4e-30) tmp = x / (t - (z * a)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[z, -2.95e+35], t$95$1, If[LessEqual[z, -1.22e-107], N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 2.4e-30], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y - \frac{x}{z}}{a}\\
\mathbf{if}\;z \leq -2.95 \cdot 10^{+35}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.22 \cdot 10^{-107}:\\
\;\;\;\;\frac{x - y \cdot z}{t}\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-30}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.94999999999999993e35 or 2.39999999999999985e-30 < z Initial program 73.8%
*-commutative73.8%
Simplified73.8%
Taylor expanded in x around 0 73.8%
fma-define73.8%
associate-/l*83.9%
sub-neg83.9%
mul-1-neg83.9%
+-commutative83.9%
mul-1-neg83.9%
distribute-rgt-neg-in83.9%
fma-undefine83.9%
fma-undefine83.9%
distribute-rgt-neg-in83.9%
mul-1-neg83.9%
associate-*r*83.9%
neg-mul-183.9%
*-commutative83.9%
fma-define83.9%
cancel-sign-sub-inv83.9%
*-commutative83.9%
+-commutative83.9%
fma-define83.9%
Simplified83.9%
Taylor expanded in a around inf 73.4%
mul-1-neg73.4%
unsub-neg73.4%
Simplified73.4%
if -2.94999999999999993e35 < z < -1.22000000000000001e-107Initial program 94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in t around inf 73.9%
if -1.22000000000000001e-107 < z < 2.39999999999999985e-30Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 78.5%
Final simplification75.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- y (/ x z)) a)))
(if (<= z -4.2e+34)
t_1
(if (<= z -1.05e-105)
(- (/ x t) (* y (/ z t)))
(if (<= z 2.1e-31) (/ x (- t (* z a))) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y - (x / z)) / a;
double tmp;
if (z <= -4.2e+34) {
tmp = t_1;
} else if (z <= -1.05e-105) {
tmp = (x / t) - (y * (z / t));
} else if (z <= 2.1e-31) {
tmp = x / (t - (z * a));
} 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 - (x / z)) / a
if (z <= (-4.2d+34)) then
tmp = t_1
else if (z <= (-1.05d-105)) then
tmp = (x / t) - (y * (z / t))
else if (z <= 2.1d-31) then
tmp = x / (t - (z * a))
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 - (x / z)) / a;
double tmp;
if (z <= -4.2e+34) {
tmp = t_1;
} else if (z <= -1.05e-105) {
tmp = (x / t) - (y * (z / t));
} else if (z <= 2.1e-31) {
tmp = x / (t - (z * a));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y - (x / z)) / a tmp = 0 if z <= -4.2e+34: tmp = t_1 elif z <= -1.05e-105: tmp = (x / t) - (y * (z / t)) elif z <= 2.1e-31: tmp = x / (t - (z * a)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y - Float64(x / z)) / a) tmp = 0.0 if (z <= -4.2e+34) tmp = t_1; elseif (z <= -1.05e-105) tmp = Float64(Float64(x / t) - Float64(y * Float64(z / t))); elseif (z <= 2.1e-31) tmp = Float64(x / Float64(t - Float64(z * a))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y - (x / z)) / a; tmp = 0.0; if (z <= -4.2e+34) tmp = t_1; elseif (z <= -1.05e-105) tmp = (x / t) - (y * (z / t)); elseif (z <= 2.1e-31) tmp = x / (t - (z * a)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[z, -4.2e+34], t$95$1, If[LessEqual[z, -1.05e-105], N[(N[(x / t), $MachinePrecision] - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e-31], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y - \frac{x}{z}}{a}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-105}:\\
\;\;\;\;\frac{x}{t} - y \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-31}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.20000000000000035e34 or 2.09999999999999991e-31 < z Initial program 73.8%
*-commutative73.8%
Simplified73.8%
Taylor expanded in x around 0 73.8%
fma-define73.8%
associate-/l*83.9%
sub-neg83.9%
mul-1-neg83.9%
+-commutative83.9%
mul-1-neg83.9%
distribute-rgt-neg-in83.9%
fma-undefine83.9%
fma-undefine83.9%
distribute-rgt-neg-in83.9%
mul-1-neg83.9%
associate-*r*83.9%
neg-mul-183.9%
*-commutative83.9%
fma-define83.9%
cancel-sign-sub-inv83.9%
*-commutative83.9%
+-commutative83.9%
fma-define83.9%
Simplified83.9%
Taylor expanded in a around inf 73.4%
mul-1-neg73.4%
unsub-neg73.4%
Simplified73.4%
if -4.20000000000000035e34 < z < -1.05e-105Initial program 94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around 0 94.4%
fma-define94.4%
associate-/l*99.6%
sub-neg99.6%
mul-1-neg99.6%
+-commutative99.6%
mul-1-neg99.6%
distribute-rgt-neg-in99.6%
fma-undefine99.6%
fma-undefine99.6%
distribute-rgt-neg-in99.6%
mul-1-neg99.6%
associate-*r*99.6%
neg-mul-199.6%
*-commutative99.6%
fma-define99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
+-commutative99.6%
fma-define99.6%
Simplified99.6%
Taylor expanded in a around 0 73.9%
+-commutative73.9%
mul-1-neg73.9%
sub-neg73.9%
*-commutative73.9%
div-sub73.9%
Simplified73.9%
div-sub73.9%
*-commutative73.9%
associate-/l*76.5%
Applied egg-rr76.5%
if -1.05e-105 < z < 2.09999999999999991e-31Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 78.5%
Final simplification76.0%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.4e+35)
(- (/ y a) (/ (/ x a) z))
(if (<= z -3.95e-106)
(- (/ x t) (* y (/ z t)))
(if (<= z 6.3e-31) (/ x (- t (* z a))) (/ (- y (/ x z)) a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e+35) {
tmp = (y / a) - ((x / a) / z);
} else if (z <= -3.95e-106) {
tmp = (x / t) - (y * (z / t));
} else if (z <= 6.3e-31) {
tmp = x / (t - (z * a));
} else {
tmp = (y - (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) :: tmp
if (z <= (-2.4d+35)) then
tmp = (y / a) - ((x / a) / z)
else if (z <= (-3.95d-106)) then
tmp = (x / t) - (y * (z / t))
else if (z <= 6.3d-31) then
tmp = x / (t - (z * a))
else
tmp = (y - (x / 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 <= -2.4e+35) {
tmp = (y / a) - ((x / a) / z);
} else if (z <= -3.95e-106) {
tmp = (x / t) - (y * (z / t));
} else if (z <= 6.3e-31) {
tmp = x / (t - (z * a));
} else {
tmp = (y - (x / z)) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -2.4e+35: tmp = (y / a) - ((x / a) / z) elif z <= -3.95e-106: tmp = (x / t) - (y * (z / t)) elif z <= 6.3e-31: tmp = x / (t - (z * a)) else: tmp = (y - (x / z)) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.4e+35) tmp = Float64(Float64(y / a) - Float64(Float64(x / a) / z)); elseif (z <= -3.95e-106) tmp = Float64(Float64(x / t) - Float64(y * Float64(z / t))); elseif (z <= 6.3e-31) tmp = Float64(x / Float64(t - Float64(z * a))); else tmp = Float64(Float64(y - Float64(x / z)) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -2.4e+35) tmp = (y / a) - ((x / a) / z); elseif (z <= -3.95e-106) tmp = (x / t) - (y * (z / t)); elseif (z <= 6.3e-31) tmp = x / (t - (z * a)); else tmp = (y - (x / z)) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.4e+35], N[(N[(y / a), $MachinePrecision] - N[(N[(x / a), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.95e-106], N[(N[(x / t), $MachinePrecision] - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.3e-31], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+35}:\\
\;\;\;\;\frac{y}{a} - \frac{\frac{x}{a}}{z}\\
\mathbf{elif}\;z \leq -3.95 \cdot 10^{-106}:\\
\;\;\;\;\frac{x}{t} - y \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 6.3 \cdot 10^{-31}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\end{array}
\end{array}
if z < -2.40000000000000015e35Initial program 77.9%
*-commutative77.9%
Simplified77.9%
Taylor expanded in z around inf 57.4%
+-commutative57.4%
associate--l+57.4%
associate-/r*59.6%
associate-*r/59.6%
associate-/r*59.6%
associate-*r/59.6%
div-sub59.6%
distribute-lft-out--59.6%
associate-*r/59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
Taylor expanded in x around inf 70.7%
associate-/r*72.9%
Simplified72.9%
if -2.40000000000000015e35 < z < -3.94999999999999993e-106Initial program 94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around 0 94.4%
fma-define94.4%
associate-/l*99.6%
sub-neg99.6%
mul-1-neg99.6%
+-commutative99.6%
mul-1-neg99.6%
distribute-rgt-neg-in99.6%
fma-undefine99.6%
fma-undefine99.6%
distribute-rgt-neg-in99.6%
mul-1-neg99.6%
associate-*r*99.6%
neg-mul-199.6%
*-commutative99.6%
fma-define99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
+-commutative99.6%
fma-define99.6%
Simplified99.6%
Taylor expanded in a around 0 73.9%
+-commutative73.9%
mul-1-neg73.9%
sub-neg73.9%
*-commutative73.9%
div-sub73.9%
Simplified73.9%
div-sub73.9%
*-commutative73.9%
associate-/l*76.5%
Applied egg-rr76.5%
if -3.94999999999999993e-106 < z < 6.3000000000000002e-31Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 78.5%
if 6.3000000000000002e-31 < z Initial program 71.2%
*-commutative71.2%
Simplified71.2%
Taylor expanded in x around 0 71.2%
fma-define71.2%
associate-/l*82.1%
sub-neg82.1%
mul-1-neg82.1%
+-commutative82.1%
mul-1-neg82.1%
distribute-rgt-neg-in82.1%
fma-undefine82.1%
fma-undefine82.1%
distribute-rgt-neg-in82.1%
mul-1-neg82.1%
associate-*r*82.1%
neg-mul-182.1%
*-commutative82.1%
fma-define82.1%
cancel-sign-sub-inv82.1%
*-commutative82.1%
+-commutative82.1%
fma-define82.1%
Simplified82.1%
Taylor expanded in a around inf 73.9%
mul-1-neg73.9%
unsub-neg73.9%
Simplified73.9%
Final simplification76.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.2e+90) (not (<= z 11500000.0))) (/ y a) (/ x (- t (* z a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.2e+90) || !(z <= 11500000.0)) {
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 <= (-2.2d+90)) .or. (.not. (z <= 11500000.0d0))) 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 <= -2.2e+90) || !(z <= 11500000.0)) {
tmp = y / a;
} else {
tmp = x / (t - (z * a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -2.2e+90) or not (z <= 11500000.0): tmp = y / a else: tmp = x / (t - (z * a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.2e+90) || !(z <= 11500000.0)) 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 <= -2.2e+90) || ~((z <= 11500000.0))) tmp = y / a; else tmp = x / (t - (z * a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.2e+90], N[Not[LessEqual[z, 11500000.0]], $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 -2.2 \cdot 10^{+90} \lor \neg \left(z \leq 11500000\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\end{array}
\end{array}
if z < -2.1999999999999999e90 or 1.15e7 < z Initial program 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in z around inf 66.2%
if -2.1999999999999999e90 < z < 1.15e7Initial program 97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in x around inf 65.2%
Final simplification65.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -7e+15) (not (<= z 1.4e-30))) (/ y a) (/ x t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -7e+15) || !(z <= 1.4e-30)) {
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 <= (-7d+15)) .or. (.not. (z <= 1.4d-30))) 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 <= -7e+15) || !(z <= 1.4e-30)) {
tmp = y / a;
} else {
tmp = x / t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -7e+15) or not (z <= 1.4e-30): tmp = y / a else: tmp = x / t return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -7e+15) || !(z <= 1.4e-30)) 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 <= -7e+15) || ~((z <= 1.4e-30))) tmp = y / a; else tmp = x / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -7e+15], N[Not[LessEqual[z, 1.4e-30]], $MachinePrecision]], N[(y / a), $MachinePrecision], N[(x / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{+15} \lor \neg \left(z \leq 1.4 \cdot 10^{-30}\right):\\
\;\;\;\;\frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t}\\
\end{array}
\end{array}
if z < -7e15 or 1.39999999999999994e-30 < z Initial program 73.1%
*-commutative73.1%
Simplified73.1%
Taylor expanded in z around inf 57.3%
if -7e15 < z < 1.39999999999999994e-30Initial program 99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in z around 0 54.3%
Final simplification55.7%
(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 87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in z around 0 36.7%
Final simplification36.7%
(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 2024044
(FPCore (x y z t a)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< z -32113435955957344.0) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))
(/ (- x (* y z)) (- t (* a z))))