
(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 8 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 (/ y (- a (/ t z)))) (t_2 (/ (- x (* y z)) (- t (* z a)))))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -5e-312)
t_2
(if (<= t_2 0.0) (/ (- y (/ x z)) a) (if (<= t_2 2e+300) t_2 t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = y / (a - (t / z));
double t_2 = (x - (y * z)) / (t - (z * a));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -5e-312) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = (y - (x / z)) / a;
} else if (t_2 <= 2e+300) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = y / (a - (t / z));
double t_2 = (x - (y * z)) / (t - (z * a));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= -5e-312) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = (y - (x / z)) / a;
} else if (t_2 <= 2e+300) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = y / (a - (t / z)) t_2 = (x - (y * z)) / (t - (z * a)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= -5e-312: tmp = t_2 elif t_2 <= 0.0: tmp = (y - (x / z)) / a elif t_2 <= 2e+300: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(y / Float64(a - Float64(t / z))) t_2 = Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(z * a))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -5e-312) tmp = t_2; elseif (t_2 <= 0.0) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (t_2 <= 2e+300) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = y / (a - (t / z)); t_2 = (x - (y * z)) / (t - (z * a)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= -5e-312) tmp = t_2; elseif (t_2 <= 0.0) tmp = (y - (x / z)) / a; elseif (t_2 <= 2e+300) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y / N[(a - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -5e-312], t$95$2, If[LessEqual[t$95$2, 0.0], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$2, 2e+300], t$95$2, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{a - \frac{t}{z}}\\
t_2 := \frac{x - y \cdot z}{t - z \cdot a}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-312}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+300}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0 or 2.0000000000000001e300 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 28.8%
*-commutative28.8%
Simplified28.8%
div-sub28.8%
div-inv28.8%
fma-neg28.8%
Applied egg-rr28.8%
Taylor expanded in x around 0 12.2%
associate-*r/12.2%
mul-1-neg12.2%
distribute-rgt-neg-out12.2%
*-commutative12.2%
associate-/l*66.5%
Simplified66.5%
Taylor expanded in t around 0 83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -5.0000000000022e-312 or 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 2.0000000000000001e300Initial program 99.6%
if -5.0000000000022e-312 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0Initial program 45.0%
*-commutative45.0%
Simplified45.0%
div-sub45.0%
div-inv45.0%
fma-neg45.0%
Applied egg-rr45.0%
Taylor expanded in t around 0 65.4%
distribute-lft-out--65.4%
*-commutative65.4%
associate-/r*84.6%
div-sub84.6%
mul-1-neg84.6%
Simplified84.6%
Final simplification95.5%
(FPCore (x y z t a)
:precision binary64
(if (<= t -2.8e-59)
(/ x t)
(if (<= t -3e-244)
(/ y a)
(if (<= t 6.8e-157)
(/ (- x) (* z a))
(if (<= t 4.8e-51)
(/ y a)
(if (<= t 5e+194)
(/ x t)
(if (<= t 3.1e+264) (- (* z (/ y t))) (/ x t))))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -2.8e-59) {
tmp = x / t;
} else if (t <= -3e-244) {
tmp = y / a;
} else if (t <= 6.8e-157) {
tmp = -x / (z * a);
} else if (t <= 4.8e-51) {
tmp = y / a;
} else if (t <= 5e+194) {
tmp = x / t;
} else if (t <= 3.1e+264) {
tmp = -(z * (y / t));
} 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 (t <= (-2.8d-59)) then
tmp = x / t
else if (t <= (-3d-244)) then
tmp = y / a
else if (t <= 6.8d-157) then
tmp = -x / (z * a)
else if (t <= 4.8d-51) then
tmp = y / a
else if (t <= 5d+194) then
tmp = x / t
else if (t <= 3.1d+264) then
tmp = -(z * (y / t))
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 (t <= -2.8e-59) {
tmp = x / t;
} else if (t <= -3e-244) {
tmp = y / a;
} else if (t <= 6.8e-157) {
tmp = -x / (z * a);
} else if (t <= 4.8e-51) {
tmp = y / a;
} else if (t <= 5e+194) {
tmp = x / t;
} else if (t <= 3.1e+264) {
tmp = -(z * (y / t));
} else {
tmp = x / t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -2.8e-59: tmp = x / t elif t <= -3e-244: tmp = y / a elif t <= 6.8e-157: tmp = -x / (z * a) elif t <= 4.8e-51: tmp = y / a elif t <= 5e+194: tmp = x / t elif t <= 3.1e+264: tmp = -(z * (y / t)) else: tmp = x / t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -2.8e-59) tmp = Float64(x / t); elseif (t <= -3e-244) tmp = Float64(y / a); elseif (t <= 6.8e-157) tmp = Float64(Float64(-x) / Float64(z * a)); elseif (t <= 4.8e-51) tmp = Float64(y / a); elseif (t <= 5e+194) tmp = Float64(x / t); elseif (t <= 3.1e+264) tmp = Float64(-Float64(z * Float64(y / t))); else tmp = Float64(x / t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -2.8e-59) tmp = x / t; elseif (t <= -3e-244) tmp = y / a; elseif (t <= 6.8e-157) tmp = -x / (z * a); elseif (t <= 4.8e-51) tmp = y / a; elseif (t <= 5e+194) tmp = x / t; elseif (t <= 3.1e+264) tmp = -(z * (y / t)); else tmp = x / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -2.8e-59], N[(x / t), $MachinePrecision], If[LessEqual[t, -3e-244], N[(y / a), $MachinePrecision], If[LessEqual[t, 6.8e-157], N[((-x) / N[(z * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 4.8e-51], N[(y / a), $MachinePrecision], If[LessEqual[t, 5e+194], N[(x / t), $MachinePrecision], If[LessEqual[t, 3.1e+264], (-N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), N[(x / t), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.8 \cdot 10^{-59}:\\
\;\;\;\;\frac{x}{t}\\
\mathbf{elif}\;t \leq -3 \cdot 10^{-244}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;t \leq 6.8 \cdot 10^{-157}:\\
\;\;\;\;\frac{-x}{z \cdot a}\\
\mathbf{elif}\;t \leq 4.8 \cdot 10^{-51}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;t \leq 5 \cdot 10^{+194}:\\
\;\;\;\;\frac{x}{t}\\
\mathbf{elif}\;t \leq 3.1 \cdot 10^{+264}:\\
\;\;\;\;-z \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t}\\
\end{array}
\end{array}
if t < -2.79999999999999981e-59 or 4.8e-51 < t < 4.99999999999999989e194 or 3.09999999999999981e264 < t Initial program 84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in z around 0 50.0%
if -2.79999999999999981e-59 < t < -3.0000000000000001e-244 or 6.79999999999999955e-157 < t < 4.8e-51Initial program 79.0%
*-commutative79.0%
Simplified79.0%
Taylor expanded in z around inf 60.8%
if -3.0000000000000001e-244 < t < 6.79999999999999955e-157Initial program 86.8%
*-commutative86.8%
Simplified86.8%
Taylor expanded in t around 0 75.5%
associate-*r/75.5%
neg-mul-175.5%
neg-sub075.5%
sub-neg75.5%
distribute-rgt-neg-out75.5%
+-commutative75.5%
associate--r+75.5%
neg-sub075.5%
distribute-rgt-neg-out75.5%
remove-double-neg75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in y around 0 59.2%
neg-mul-159.2%
Simplified59.2%
if 4.99999999999999989e194 < t < 3.09999999999999981e264Initial program 65.7%
*-commutative65.7%
Simplified65.7%
Taylor expanded in z around 0 90.8%
fma-def90.8%
distribute-lft-out--90.8%
associate-/l*90.8%
unpow290.8%
Simplified90.8%
Taylor expanded in z around inf 73.9%
mul-1-neg73.9%
associate-*l/73.9%
unpow273.9%
distribute-rgt-neg-out73.9%
unpow273.9%
associate-*l/73.9%
associate-/l*73.9%
unpow273.9%
Simplified73.9%
Taylor expanded in y around inf 73.9%
Final simplification54.9%
(FPCore (x y z t a)
:precision binary64
(if (<= z -4.15e+93)
(/ y a)
(if (or (<= z 5.3e+17) (and (not (<= z 1.5e+77)) (<= z 5.2e+143)))
(/ x (- t (* z a)))
(/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.15e+93) {
tmp = y / a;
} else if ((z <= 5.3e+17) || (!(z <= 1.5e+77) && (z <= 5.2e+143))) {
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 <= (-4.15d+93)) then
tmp = y / a
else if ((z <= 5.3d+17) .or. (.not. (z <= 1.5d+77)) .and. (z <= 5.2d+143)) 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 <= -4.15e+93) {
tmp = y / a;
} else if ((z <= 5.3e+17) || (!(z <= 1.5e+77) && (z <= 5.2e+143))) {
tmp = x / (t - (z * a));
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4.15e+93: tmp = y / a elif (z <= 5.3e+17) or (not (z <= 1.5e+77) and (z <= 5.2e+143)): tmp = x / (t - (z * a)) else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.15e+93) tmp = Float64(y / a); elseif ((z <= 5.3e+17) || (!(z <= 1.5e+77) && (z <= 5.2e+143))) 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 <= -4.15e+93) tmp = y / a; elseif ((z <= 5.3e+17) || (~((z <= 1.5e+77)) && (z <= 5.2e+143))) tmp = x / (t - (z * a)); else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.15e+93], N[(y / a), $MachinePrecision], If[Or[LessEqual[z, 5.3e+17], And[N[Not[LessEqual[z, 1.5e+77]], $MachinePrecision], LessEqual[z, 5.2e+143]]], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.15 \cdot 10^{+93}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{+17} \lor \neg \left(z \leq 1.5 \cdot 10^{+77}\right) \land z \leq 5.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -4.1499999999999999e93 or 5.3e17 < z < 1.4999999999999999e77 or 5.1999999999999998e143 < z Initial program 54.7%
*-commutative54.7%
Simplified54.7%
Taylor expanded in z around inf 61.3%
if -4.1499999999999999e93 < z < 5.3e17 or 1.4999999999999999e77 < z < 5.1999999999999998e143Initial program 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around inf 71.2%
*-commutative71.2%
Simplified71.2%
Final simplification67.7%
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.5e+45)
(/ y a)
(if (<= z 3.1e+15)
(/ x t)
(if (<= z 5.9e+84)
(/ y a)
(if (<= z 9.8e+123) (- (* z (/ y t))) (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.5e+45) {
tmp = y / a;
} else if (z <= 3.1e+15) {
tmp = x / t;
} else if (z <= 5.9e+84) {
tmp = y / a;
} else if (z <= 9.8e+123) {
tmp = -(z * (y / 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 <= (-1.5d+45)) then
tmp = y / a
else if (z <= 3.1d+15) then
tmp = x / t
else if (z <= 5.9d+84) then
tmp = y / a
else if (z <= 9.8d+123) then
tmp = -(z * (y / 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 <= -1.5e+45) {
tmp = y / a;
} else if (z <= 3.1e+15) {
tmp = x / t;
} else if (z <= 5.9e+84) {
tmp = y / a;
} else if (z <= 9.8e+123) {
tmp = -(z * (y / t));
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.5e+45: tmp = y / a elif z <= 3.1e+15: tmp = x / t elif z <= 5.9e+84: tmp = y / a elif z <= 9.8e+123: tmp = -(z * (y / t)) else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.5e+45) tmp = Float64(y / a); elseif (z <= 3.1e+15) tmp = Float64(x / t); elseif (z <= 5.9e+84) tmp = Float64(y / a); elseif (z <= 9.8e+123) tmp = Float64(-Float64(z * Float64(y / t))); else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.5e+45) tmp = y / a; elseif (z <= 3.1e+15) tmp = x / t; elseif (z <= 5.9e+84) tmp = y / a; elseif (z <= 9.8e+123) tmp = -(z * (y / t)); else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.5e+45], N[(y / a), $MachinePrecision], If[LessEqual[z, 3.1e+15], N[(x / t), $MachinePrecision], If[LessEqual[z, 5.9e+84], N[(y / a), $MachinePrecision], If[LessEqual[z, 9.8e+123], (-N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), N[(y / a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{t}\\
\mathbf{elif}\;z \leq 5.9 \cdot 10^{+84}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 9.8 \cdot 10^{+123}:\\
\;\;\;\;-z \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -1.50000000000000005e45 or 3.1e15 < z < 5.89999999999999984e84 or 9.79999999999999952e123 < z Initial program 62.0%
*-commutative62.0%
Simplified62.0%
Taylor expanded in z around inf 55.4%
if -1.50000000000000005e45 < z < 3.1e15Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in z around 0 49.3%
if 5.89999999999999984e84 < z < 9.79999999999999952e123Initial program 87.6%
*-commutative87.6%
Simplified87.6%
Taylor expanded in z around 0 63.3%
fma-def63.3%
distribute-lft-out--63.3%
associate-/l*63.3%
unpow263.3%
Simplified63.3%
Taylor expanded in z around inf 63.3%
mul-1-neg63.3%
associate-*l/63.3%
unpow263.3%
distribute-rgt-neg-out63.3%
unpow263.3%
associate-*l/63.3%
associate-/l*63.3%
unpow263.3%
Simplified63.3%
Taylor expanded in y around inf 63.9%
Final simplification52.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= y -2.1e+85) (not (<= y 0.000105))) (/ y (- a (/ t z))) (/ x (- t (* z a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -2.1e+85) || !(y <= 0.000105)) {
tmp = y / (a - (t / z));
} 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 ((y <= (-2.1d+85)) .or. (.not. (y <= 0.000105d0))) then
tmp = y / (a - (t / z))
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 ((y <= -2.1e+85) || !(y <= 0.000105)) {
tmp = y / (a - (t / z));
} else {
tmp = x / (t - (z * a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (y <= -2.1e+85) or not (y <= 0.000105): tmp = y / (a - (t / z)) else: tmp = x / (t - (z * a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((y <= -2.1e+85) || !(y <= 0.000105)) tmp = Float64(y / Float64(a - Float64(t / z))); 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 ((y <= -2.1e+85) || ~((y <= 0.000105))) tmp = y / (a - (t / z)); else tmp = x / (t - (z * a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -2.1e+85], N[Not[LessEqual[y, 0.000105]], $MachinePrecision]], N[(y / N[(a - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+85} \lor \neg \left(y \leq 0.000105\right):\\
\;\;\;\;\frac{y}{a - \frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\end{array}
\end{array}
if y < -2.1000000000000001e85 or 1.05e-4 < y Initial program 68.7%
*-commutative68.7%
Simplified68.7%
div-sub68.7%
div-inv68.7%
fma-neg68.7%
Applied egg-rr68.7%
Taylor expanded in x around 0 47.4%
associate-*r/47.4%
mul-1-neg47.4%
distribute-rgt-neg-out47.4%
*-commutative47.4%
associate-/l*61.1%
Simplified61.1%
Taylor expanded in t around 0 72.3%
mul-1-neg72.3%
unsub-neg72.3%
Simplified72.3%
if -2.1000000000000001e85 < y < 1.05e-4Initial program 92.2%
*-commutative92.2%
Simplified92.2%
Taylor expanded in x around inf 75.1%
*-commutative75.1%
Simplified75.1%
Final simplification74.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.06e+45) (/ (- y (/ x z)) a) (if (<= z 1.15e-8) (/ x (- t (* z a))) (/ y (- a (/ t z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.06e+45) {
tmp = (y - (x / z)) / a;
} else if (z <= 1.15e-8) {
tmp = x / (t - (z * a));
} else {
tmp = y / (a - (t / z));
}
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.06d+45)) then
tmp = (y - (x / z)) / a
else if (z <= 1.15d-8) then
tmp = x / (t - (z * a))
else
tmp = y / (a - (t / 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.06e+45) {
tmp = (y - (x / z)) / a;
} else if (z <= 1.15e-8) {
tmp = x / (t - (z * a));
} else {
tmp = y / (a - (t / z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.06e+45: tmp = (y - (x / z)) / a elif z <= 1.15e-8: tmp = x / (t - (z * a)) else: tmp = y / (a - (t / z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.06e+45) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (z <= 1.15e-8) tmp = Float64(x / Float64(t - Float64(z * a))); else tmp = Float64(y / Float64(a - Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.06e+45) tmp = (y - (x / z)) / a; elseif (z <= 1.15e-8) tmp = x / (t - (z * a)); else tmp = y / (a - (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.06e+45], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[z, 1.15e-8], N[(x / N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(a - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06 \cdot 10^{+45}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{t - z \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a - \frac{t}{z}}\\
\end{array}
\end{array}
if z < -1.06e45Initial program 61.5%
*-commutative61.5%
Simplified61.5%
div-sub61.5%
div-inv61.4%
fma-neg61.4%
Applied egg-rr61.4%
Taylor expanded in t around 0 69.5%
distribute-lft-out--69.5%
*-commutative69.5%
associate-/r*75.1%
div-sub75.1%
mul-1-neg75.1%
Simplified75.1%
if -1.06e45 < z < 1.15e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 76.3%
*-commutative76.3%
Simplified76.3%
if 1.15e-8 < z Initial program 70.9%
*-commutative70.9%
Simplified70.9%
div-sub70.9%
div-inv70.8%
fma-neg70.8%
Applied egg-rr70.8%
Taylor expanded in x around 0 45.9%
associate-*r/45.9%
mul-1-neg45.9%
distribute-rgt-neg-out45.9%
*-commutative45.9%
associate-/l*58.5%
Simplified58.5%
Taylor expanded in t around 0 70.6%
mul-1-neg70.6%
unsub-neg70.6%
Simplified70.6%
Final simplification74.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -6.2e+44) (/ y a) (if (<= z 1.52e+16) (/ x t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -6.2e+44) {
tmp = y / a;
} else if (z <= 1.52e+16) {
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 <= (-6.2d+44)) then
tmp = y / a
else if (z <= 1.52d+16) 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 <= -6.2e+44) {
tmp = y / a;
} else if (z <= 1.52e+16) {
tmp = x / t;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -6.2e+44: tmp = y / a elif z <= 1.52e+16: tmp = x / t else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -6.2e+44) tmp = Float64(y / a); elseif (z <= 1.52e+16) 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 <= -6.2e+44) tmp = y / a; elseif (z <= 1.52e+16) tmp = x / t; else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -6.2e+44], N[(y / a), $MachinePrecision], If[LessEqual[z, 1.52e+16], N[(x / t), $MachinePrecision], N[(y / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+44}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 1.52 \cdot 10^{+16}:\\
\;\;\;\;\frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -6.19999999999999991e44 or 1.52e16 < z Initial program 63.7%
*-commutative63.7%
Simplified63.7%
Taylor expanded in z around inf 52.6%
if -6.19999999999999991e44 < z < 1.52e16Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in z around 0 49.3%
Final simplification50.8%
(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.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in z around 0 34.4%
Final simplification34.4%
(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 2023271
(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))))