?

Average Accuracy: 77.1% → 89.6%
Time: 20.4s
Precision: binary64
Cost: 8905

?

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

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


\end{array}

Error?

Target

Original77.1%
Target88.2%
Herbie89.6%
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < 1.4754293444577233 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 4.9999999999999997e-245 or 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 72.5%

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
    2. Simplified86.3%

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

      [Start]72.5

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

      associate--l+ [=>]75.4

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

      sub-neg [=>]75.4

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

      +-commutative [=>]75.4

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

      associate-/l* [=>]82.4

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

      distribute-neg-frac [=>]82.4

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

      associate-/r/ [=>]86.3

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

      fma-def [=>]86.3

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

      sub-neg [=>]86.3

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

      +-commutative [=>]86.3

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

      distribute-neg-in [=>]86.3

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

      unsub-neg [=>]86.3

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

      remove-double-neg [=>]86.3

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

    if 4.9999999999999997e-245 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0

    1. Initial program 72.5%

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
    2. Simplified82.4%

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

      [Start]72.5

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

      associate--l+ [=>]75.4

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

      associate-/l* [=>]82.4

      \[ x + \left(y - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\right) \]
    3. Taylor expanded in t around inf 59.7%

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{y \cdot a}{t} + x\right) - -1 \cdot \frac{y \cdot z}{t}} \]
    4. Simplified64.8%

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

      [Start]59.7

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

      +-commutative [=>]59.7

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

      associate-+r- [<=]59.7

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

      distribute-lft-out-- [=>]59.7

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

      div-sub [<=]59.8

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

      mul-1-neg [=>]59.8

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

      unsub-neg [=>]59.8

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

      distribute-lft-out-- [=>]60.6

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

      associate-/l* [=>]64.8

      \[ x - \color{blue}{\frac{y}{\frac{t}{a - z}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.3%

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

Alternatives

Alternative 1
Accuracy52.8%
Cost1476
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{if}\;t \leq 4.8 \cdot 10^{+80}:\\ \;\;\;\;t_1 + \frac{y}{\frac{t}{z - a}} \cdot \frac{a}{t}\\ \mathbf{elif}\;t \leq 1.15:\\ \;\;\;\;x + \left(y - \frac{z - t}{\frac{a - t}{y}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy60.4%
Cost1097
\[\begin{array}{l} \mathbf{if}\;t \leq 2.2 \cdot 10^{+82} \lor \neg \left(t \leq 1300\right):\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - \frac{z - t}{\frac{a - t}{y}}\right)\\ \end{array} \]
Alternative 3
Accuracy51.0%
Cost976
\[\begin{array}{l} \mathbf{if}\;t \leq 5.1 \cdot 10^{+147}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 9 \cdot 10^{+82}:\\ \;\;\;\;y \cdot \frac{z - a}{t}\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-218}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 2.3 \cdot 10^{-121}:\\ \;\;\;\;y \cdot \left(1 - \frac{z}{a}\right)\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{+124}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy60.3%
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq 7.2 \cdot 10^{+89}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2.1 \cdot 10^{+26}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 4.9 \cdot 10^{+95}:\\ \;\;\;\;y \cdot \left(1 - \frac{z}{a}\right)\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 5
Accuracy59.9%
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq 10^{+72}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 5.8 \cdot 10^{+25}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 9 \cdot 10^{+98}:\\ \;\;\;\;y \cdot \left(1 - \frac{z}{a}\right)\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 6
Accuracy60.0%
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq 7.5 \cdot 10^{+73}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 1.55 \cdot 10^{+25}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;a \leq 7.5 \cdot 10^{+95}:\\ \;\;\;\;y \cdot \left(1 - \frac{z}{a}\right)\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 7
Accuracy59.9%
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq 4.8 \cdot 10^{+73}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 1.5 \cdot 10^{+26}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;a \leq 1.8 \cdot 10^{+98}:\\ \;\;\;\;y - \frac{z}{\frac{a}{y}}\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 8
Accuracy59.9%
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq 9 \cdot 10^{+71}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2 \cdot 10^{+26}:\\ \;\;\;\;x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;a \leq 7.6 \cdot 10^{+95}:\\ \;\;\;\;y - \frac{z}{\frac{a}{y}}\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 9
Accuracy59.9%
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq 3.4 \cdot 10^{+72}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2.1 \cdot 10^{+26}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{elif}\;a \leq 3.1 \cdot 10^{+96}:\\ \;\;\;\;y - \frac{z}{\frac{a}{y}}\\ \mathbf{elif}\;a \leq 2.15 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 10
Accuracy60.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq 4.2 \cdot 10^{+78} \lor \neg \left(t \leq 0.00182\right):\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - y \cdot \frac{z}{a}\\ \end{array} \]
Alternative 11
Accuracy60.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq 1.8 \cdot 10^{+74} \lor \neg \left(t \leq 920\right):\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \end{array} \]
Alternative 12
Accuracy60.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq 1.75 \cdot 10^{+80} \lor \neg \left(t \leq 0.0023\right):\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - \frac{z}{\frac{a}{y}}\\ \end{array} \]
Alternative 13
Accuracy48.2%
Cost592
\[\begin{array}{l} \mathbf{if}\;a \leq 2.1 \cdot 10^{+26}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 4.9 \cdot 10^{+95}:\\ \;\;\;\;y\\ \mathbf{elif}\;a \leq 3.8 \cdot 10^{+146}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 2.6 \cdot 10^{+275}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Accuracy61.1%
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq 1.1 \cdot 10^{+94}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 3.2 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 15
Accuracy51.0%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023159 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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