?

Average Accuracy: 95.7% → 99.7%
Time: 9.9s
Precision: binary64
Cost: 7817

?

\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[\frac{x}{y - z \cdot t} \]
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+285} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+250}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y + \mathsf{fma}\left(-z, t, z \cdot t\right)\right) - z \cdot t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (* z t) -5e+285) (not (<= (* z t) 2e+250)))
   (/ (/ x z) (- t))
   (/ x (- (+ y (fma (- z) t (* z t))) (* z t)))))
double code(double x, double y, double z, double t) {
	return x / (y - (z * t));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (((z * t) <= -5e+285) || !((z * t) <= 2e+250)) {
		tmp = (x / z) / -t;
	} else {
		tmp = x / ((y + fma(-z, t, (z * t))) - (z * t));
	}
	return tmp;
}
function code(x, y, z, t)
	return Float64(x / Float64(y - Float64(z * t)))
end
function code(x, y, z, t)
	tmp = 0.0
	if ((Float64(z * t) <= -5e+285) || !(Float64(z * t) <= 2e+250))
		tmp = Float64(Float64(x / z) / Float64(-t));
	else
		tmp = Float64(x / Float64(Float64(y + fma(Float64(-z), t, Float64(z * t))) - Float64(z * t)));
	end
	return tmp
end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e+285], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+250]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] / (-t)), $MachinePrecision], N[(x / N[(N[(y + N[((-z) * t + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+285} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+250}\right):\\
\;\;\;\;\frac{\frac{x}{z}}{-t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y + \mathsf{fma}\left(-z, t, z \cdot t\right)\right) - z \cdot t}\\


\end{array}

Error?

Target

Original95.7%
Target97.2%
Herbie99.7%
\[\begin{array}{l} \mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \mathbf{elif}\;x < 2.1378306434876444 \cdot 10^{+131}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 z t) < -5.00000000000000016e285 or 1.9999999999999998e250 < (*.f64 z t)

    1. Initial program 74.8%

      \[\frac{x}{y - z \cdot t} \]
    2. Taylor expanded in y around 0 73.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    3. Simplified73.8%

      \[\leadsto \color{blue}{\frac{-x}{t \cdot z}} \]
      Proof

      [Start]73.8

      \[ -1 \cdot \frac{x}{t \cdot z} \]

      *-commutative [<=]73.8

      \[ -1 \cdot \frac{x}{\color{blue}{z \cdot t}} \]

      associate-*r/ [=>]73.8

      \[ \color{blue}{\frac{-1 \cdot x}{z \cdot t}} \]

      neg-mul-1 [<=]73.8

      \[ \frac{\color{blue}{-x}}{z \cdot t} \]

      *-commutative [=>]73.8

      \[ \frac{-x}{\color{blue}{t \cdot z}} \]
    4. Taylor expanded in x around 0 73.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    5. Simplified98.9%

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{-t}} \]
      Proof

      [Start]73.8

      \[ -1 \cdot \frac{x}{t \cdot z} \]

      metadata-eval [<=]73.8

      \[ \color{blue}{\frac{1}{-1}} \cdot \frac{x}{t \cdot z} \]

      associate-/r* [=>]98.8

      \[ \frac{1}{-1} \cdot \color{blue}{\frac{\frac{x}{t}}{z}} \]

      times-frac [<=]98.8

      \[ \color{blue}{\frac{1 \cdot \frac{x}{t}}{-1 \cdot z}} \]

      *-lft-identity [=>]98.8

      \[ \frac{\color{blue}{\frac{x}{t}}}{-1 \cdot z} \]

      neg-mul-1 [<=]98.8

      \[ \frac{\frac{x}{t}}{\color{blue}{-z}} \]

      associate-/r* [<=]73.8

      \[ \color{blue}{\frac{x}{t \cdot \left(-z\right)}} \]

      distribute-rgt-neg-out [=>]73.8

      \[ \frac{x}{\color{blue}{-t \cdot z}} \]

      *-commutative [=>]73.8

      \[ \frac{x}{-\color{blue}{z \cdot t}} \]

      distribute-rgt-neg-in [=>]73.8

      \[ \frac{x}{\color{blue}{z \cdot \left(-t\right)}} \]

      associate-/r* [=>]98.9

      \[ \color{blue}{\frac{\frac{x}{z}}{-t}} \]

    if -5.00000000000000016e285 < (*.f64 z t) < 1.9999999999999998e250

    1. Initial program 99.9%

      \[\frac{x}{y - z \cdot t} \]
    2. Applied egg-rr99.9%

      \[\leadsto \frac{x}{\color{blue}{\left(-z \cdot t\right) + \left(y + \mathsf{fma}\left(-z, t, z \cdot t\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+285} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+250}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y + \mathsf{fma}\left(-z, t, z \cdot t\right)\right) - z \cdot t}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.7%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+285} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+250}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \end{array} \]
Alternative 2
Accuracy71.9%
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-5}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-95} \lor \neg \left(y \leq 5.3 \cdot 10^{-5}\right) \land y \leq 1.22 \cdot 10^{+41}:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 3
Accuracy54.4%
Cost717
\[\begin{array}{l} \mathbf{if}\;t \leq 2.3 \cdot 10^{+90} \lor \neg \left(t \leq 9.5 \cdot 10^{+102}\right) \land t \leq 10^{+206}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z \cdot t}\\ \end{array} \]
Alternative 4
Accuracy54.3%
Cost716
\[\begin{array}{l} \mathbf{if}\;t \leq 1.18 \cdot 10^{+84}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+102}:\\ \;\;\;\;\frac{\frac{x}{t}}{z}\\ \mathbf{elif}\;t \leq 1.16 \cdot 10^{+207}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z \cdot t}\\ \end{array} \]
Alternative 5
Accuracy71.3%
Cost649
\[\begin{array}{l} \mathbf{if}\;t \leq -1.26 \cdot 10^{-74} \lor \neg \left(t \leq 1.6 \cdot 10^{+42}\right):\\ \;\;\;\;\frac{\frac{x}{z}}{-t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 6
Accuracy72.6%
Cost649
\[\begin{array}{l} \mathbf{if}\;t \leq -3.9 \cdot 10^{-73} \lor \neg \left(t \leq 1.25 \cdot 10^{+42}\right):\\ \;\;\;\;\frac{\frac{x}{-t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 7
Accuracy52.4%
Cost192
\[\frac{x}{y} \]

Error

Reproduce?

herbie shell --seed 2023125 
(FPCore (x y z t)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))

  (/ x (- y (* z t))))