?

Average Accuracy: 91.4% → 94.6%
Time: 11.8s
Precision: binary64
Cost: 7304

?

\[ \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 -1 \cdot 10^{+162}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+277}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{x}{t}}{z}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z t) -1e+162)
   (* (/ x t) (/ -1.0 z))
   (if (<= (* z t) 2e+277) (/ x (fma (- z) t y)) (/ (- (/ x t)) z))))
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) <= -1e+162) {
		tmp = (x / t) * (-1.0 / z);
	} else if ((z * t) <= 2e+277) {
		tmp = x / fma(-z, t, y);
	} else {
		tmp = -(x / t) / z;
	}
	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) <= -1e+162)
		tmp = Float64(Float64(x / t) * Float64(-1.0 / z));
	elseif (Float64(z * t) <= 2e+277)
		tmp = Float64(x / fma(Float64(-z), t, y));
	else
		tmp = Float64(Float64(-Float64(x / t)) / z);
	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[LessEqual[N[(z * t), $MachinePrecision], -1e+162], N[(N[(x / t), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+277], N[(x / N[((-z) * t + y), $MachinePrecision]), $MachinePrecision], N[((-N[(x / t), $MachinePrecision]) / z), $MachinePrecision]]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+162}:\\
\;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+277}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-\frac{x}{t}}{z}\\


\end{array}

Error?

Target

Original91.4%
Target93.1%
Herbie94.6%
\[\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 3 regimes
  2. if (*.f64 z t) < -9.9999999999999994e161

    1. Initial program 86.2%

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{x}{y - z \cdot t}}\right)}^{3}} \]
      Step-by-step derivation

      [Start]86.2

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

      add-cube-cbrt [=>]85.7

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

      pow3 [=>]85.8

      \[ \color{blue}{{\left(\sqrt[3]{\frac{x}{y - z \cdot t}}\right)}^{3}} \]
    3. Taylor expanded in y around 0 86.1%

      \[\leadsto \color{blue}{-1 \cdot \left({1}^{0.3333333333333333} \cdot \frac{x}{t \cdot z}\right)} \]
    4. Simplified99.7%

      \[\leadsto \color{blue}{-\frac{\frac{x}{t}}{z}} \]
      Step-by-step derivation

      [Start]86.1

      \[ -1 \cdot \left({1}^{0.3333333333333333} \cdot \frac{x}{t \cdot z}\right) \]

      mul-1-neg [=>]86.1

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

      pow-base-1 [=>]86.1

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

      *-lft-identity [=>]86.1

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

      associate-/r* [=>]99.7

      \[ -\color{blue}{\frac{\frac{x}{t}}{z}} \]
    5. Applied egg-rr99.8%

      \[\leadsto -\color{blue}{\frac{x}{t} \cdot \frac{1}{z}} \]
      Step-by-step derivation

      [Start]99.7

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

      div-inv [=>]99.8

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

    if -9.9999999999999994e161 < (*.f64 z t) < 2.00000000000000001e277

    1. Initial program 94.7%

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

      \[\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(-z, t, y\right)}} \]
      Step-by-step derivation

      [Start]94.7

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

      sub-neg [=>]94.7

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

      +-commutative [=>]94.7

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

      distribute-lft-neg-in [=>]94.7

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

      fma-def [=>]94.8

      \[ \frac{x}{\color{blue}{\mathsf{fma}\left(-z, t, y\right)}} \]

    if 2.00000000000000001e277 < (*.f64 z t)

    1. Initial program 68.9%

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{x}{y - z \cdot t}}\right)}^{3}} \]
      Step-by-step derivation

      [Start]68.9

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

      add-cube-cbrt [=>]68.8

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

      pow3 [=>]68.8

      \[ \color{blue}{{\left(\sqrt[3]{\frac{x}{y - z \cdot t}}\right)}^{3}} \]
    3. Taylor expanded in y around 0 68.9%

      \[\leadsto \color{blue}{-1 \cdot \left({1}^{0.3333333333333333} \cdot \frac{x}{t \cdot z}\right)} \]
    4. Simplified99.9%

      \[\leadsto \color{blue}{-\frac{\frac{x}{t}}{z}} \]
      Step-by-step derivation

      [Start]68.9

      \[ -1 \cdot \left({1}^{0.3333333333333333} \cdot \frac{x}{t \cdot z}\right) \]

      mul-1-neg [=>]68.9

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

      pow-base-1 [=>]68.9

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

      *-lft-identity [=>]68.9

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

      associate-/r* [=>]99.9

      \[ -\color{blue}{\frac{\frac{x}{t}}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification95.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+162}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+277}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{x}{t}}{z}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy95.4%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+302}:\\ \;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+277}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z}\\ \end{array} \]
Alternative 2
Accuracy94.6%
Cost968
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+162}:\\ \;\;\;\;\frac{x}{t} \cdot \frac{-1}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+277}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\frac{x}{t}}{z}\\ \end{array} \]
Alternative 3
Accuracy67.4%
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq -1800000 \lor \neg \left(y \leq -1 \cdot 10^{-37}\right) \land y \leq 82000000:\\ \;\;\;\;\frac{-\frac{x}{t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 4
Accuracy68.8%
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq -3.2 \lor \neg \left(y \leq -1.1 \cdot 10^{-23}\right) \land y \leq 85000000:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 5
Accuracy69.0%
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq -950:\\ \;\;\;\;-\frac{\frac{x}{z}}{t}\\ \mathbf{elif}\;y \leq -1.1 \cdot 10^{-23}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;y \leq 26500000:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 6
Accuracy52.3%
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 4.8 \cdot 10^{+225}:\\ \;\;\;\;\frac{1}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{t}\\ \end{array} \]
Alternative 7
Accuracy49.6%
Cost320
\[\frac{1}{\frac{y}{x}} \]
Alternative 8
Accuracy50.0%
Cost192
\[\frac{x}{y} \]

Error

Reproduce?

herbie shell --seed 2023157 
(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))))