(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
↓
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- x (* y z)) (- t (* z a)))))
(if (<= t_1 (- INFINITY))
(* z (/ y (- (* z a) t)))
(if (<= t_1 -1e-286)
t_1
(if (<= t_1 0.0)
(- (/ y a) (/ (/ x a) z))
(if (<= t_1 5e+277) t_1 (/ y a)))))))
double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
↓
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)) {
tmp = z * (y / ((z * a) - t));
} else if (t_1 <= -1e-286) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = (y / a) - ((x / a) / z);
} else if (t_1 <= 5e+277) {
tmp = t_1;
} else {
tmp = y / a;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
↓
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) {
tmp = z * (y / ((z * a) - t));
} else if (t_1 <= -1e-286) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = (y / a) - ((x / a) / z);
} else if (t_1 <= 5e+277) {
tmp = t_1;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a):
return (x - (y * z)) / (t - (a * z))
↓
def code(x, y, z, t, a):
t_1 = (x - (y * z)) / (t - (z * a))
tmp = 0
if t_1 <= -math.inf:
tmp = z * (y / ((z * a) - t))
elif t_1 <= -1e-286:
tmp = t_1
elif t_1 <= 0.0:
tmp = (y / a) - ((x / a) / z)
elif t_1 <= 5e+277:
tmp = t_1
else:
tmp = y / a
return tmp
function code(x, y, z, t, a)
return Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z)))
end
↓
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))
tmp = Float64(z * Float64(y / Float64(Float64(z * a) - t)));
elseif (t_1 <= -1e-286)
tmp = t_1;
elseif (t_1 <= 0.0)
tmp = Float64(Float64(y / a) - Float64(Float64(x / a) / z));
elseif (t_1 <= 5e+277)
tmp = t_1;
else
tmp = Float64(y / a);
end
return tmp
end
function tmp = code(x, y, z, t, a)
tmp = (x - (y * z)) / (t - (a * z));
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)
tmp = z * (y / ((z * a) - t));
elseif (t_1 <= -1e-286)
tmp = t_1;
elseif (t_1 <= 0.0)
tmp = (y / a) - ((x / a) / z);
elseif (t_1 <= 5e+277)
tmp = t_1;
else
tmp = y / a;
end
tmp_2 = tmp;
end
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0
Initial program 64.0
\[\frac{x - y \cdot z}{t - a \cdot z}
\]
Applied egg-rr0.2
\[\leadsto \color{blue}{\frac{x}{t - z \cdot a} - \frac{y}{\frac{t - z \cdot a}{z}}}
\]
Applied egg-rr51.0
\[\leadsto \color{blue}{\frac{\left(-x\right) \cdot \frac{t - z \cdot a}{z} - \left(-\left(t - z \cdot a\right)\right) \cdot y}{\left(-\left(t - z \cdot a\right)\right) \cdot \frac{t - z \cdot a}{z}}}
\]
Taylor expanded in y around inf 64.0
\[\leadsto \color{blue}{\frac{y \cdot z}{a \cdot z - t}}
\]
Simplified0.3
\[\leadsto \color{blue}{\frac{y}{z \cdot a - t} \cdot z}
\]
Proof
(*.f64 (/.f64 y (-.f64 (*.f64 z a) t)) z): 0 points increase in error, 0 points decrease in error
(*.f64 (/.f64 y (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 a z)) t)) z): 0 points increase in error, 0 points decrease in error
(Rewrite<= associate-/r/_binary64 (/.f64 y (/.f64 (-.f64 (*.f64 a z) t) z))): 26 points increase in error, 51 points decrease in error
(Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 y z) (-.f64 (*.f64 a z) t))): 56 points increase in error, 36 points decrease in error
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.00000000000000005e-286 or -0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 4.99999999999999982e277
Initial program 0.2
\[\frac{x - y \cdot z}{t - a \cdot z}
\]
if -1.00000000000000005e-286 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -0.0
Initial program 22.8
\[\frac{x - y \cdot z}{t - a \cdot z}
\]
Taylor expanded in x around 0 22.8
\[\leadsto \color{blue}{\frac{x}{t - a \cdot z} + -1 \cdot \frac{y \cdot z}{t - a \cdot z}}
\]
(-.f64 (/.f64 y a) (/.f64 (-.f64 (/.f64 x a) (*.f64 (/.f64 t (*.f64 a a)) y)) z)): 0 points increase in error, 0 points decrease in error
(-.f64 (/.f64 y a) (/.f64 (-.f64 (/.f64 x a) (*.f64 (/.f64 t (Rewrite<= unpow2_binary64 (pow.f64 a 2))) y)) z)): 0 points increase in error, 0 points decrease in error
(-.f64 (/.f64 y a) (/.f64 (-.f64 (/.f64 x a) (Rewrite<= associate-/r/_binary64 (/.f64 t (/.f64 (pow.f64 a 2) y)))) z)): 0 points increase in error, 10 points decrease in error
(-.f64 (/.f64 y a) (/.f64 (-.f64 (/.f64 x a) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 t y) (pow.f64 a 2)))) z)): 15 points increase in error, 0 points decrease in error
(-.f64 (/.f64 y a) (/.f64 (-.f64 (/.f64 x a) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y t)) (pow.f64 a 2))) z)): 0 points increase in error, 0 points decrease in error
(Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 y a) (neg.f64 (/.f64 (-.f64 (/.f64 x a) (/.f64 (*.f64 y t) (pow.f64 a 2))) z)))): 0 points increase in error, 0 points decrease in error
(+.f64 (/.f64 y a) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (-.f64 (/.f64 x a) (/.f64 (*.f64 y t) (pow.f64 a 2))) z)))): 0 points increase in error, 0 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 (*.f64 -1 (/.f64 (-.f64 (/.f64 x a) (/.f64 (*.f64 y t) (pow.f64 a 2))) z)) (/.f64 y a))): 0 points increase in error, 0 points decrease in error
herbie shell --seed 2022316
(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))))