Average Error: 10.6 → 1.9
Time: 24.9s
Precision: 64
Internal precision: 128
\[\frac{x - y \cdot z}{t - a \cdot z}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -2.5926369593026417 \cdot 10^{+19}:\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\
\mathbf{if}\;z \le 4.0102291809654423 \cdot 10^{-147}:\\
\;\;\;\;\frac{x - y \cdot z}{t - a \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\
\end{array}\]
Target
| Original | 10.6 |
| Comparison | 1.8 |
| Herbie | 1.9 |
\[ \begin{array}{l}
\mathbf{if}\;z \lt -32113435955957344.0:\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\
\mathbf{if}\;z \lt 3.5139522372978296 \cdot 10^{-86}:\\
\;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t - a \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if z < -2.5926369593026417e+19 or 4.0102291809654423e-147 < z
Initial program 17.5
\[\frac{x - y \cdot z}{t - a \cdot z}\]
- Using strategy
rm
Applied div-sub 17.5
\[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}}\]
Applied simplify 3.1
\[\leadsto \frac{x}{t - a \cdot z} - \color{blue}{\frac{y}{\frac{t}{z} - a}}\]
if -2.5926369593026417e+19 < z < 4.0102291809654423e-147
Initial program 0.2
\[\frac{x - y \cdot z}{t - a \cdot z}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(795767902 2781468165 2684183434 2168953841 2127699199 2953697635)'
(FPCore (x y z t a)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
:target
(if (< z -32113435955957344.0) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))
(/ (- x (* y z)) (- t (* a z))))