?

Average Accuracy: 74.3% → 91.9%
Time: 16.5s
Precision: binary64
Cost: 8904

?

\[\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^{-239}:\\ \;\;\;\;x + \left(y + \frac{t - z}{\frac{a - t}{y}}\right)\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \mathbf{else}:\\ \;\;\;\;x + \mathsf{fma}\left(\frac{t - z}{a - t}, y, y\right)\\ \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 (<= t_1 -5e-239)
     (+ x (+ y (/ (- t z) (/ (- a t) y))))
     (if (<= t_1 0.0)
       (- x (/ y (/ t (- a z))))
       (+ x (fma (/ (- t z) (- a t)) y y))))))
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-239) {
		tmp = x + (y + ((t - z) / ((a - t) / y)));
	} else if (t_1 <= 0.0) {
		tmp = x - (y / (t / (a - z)));
	} else {
		tmp = x + fma(((t - z) / (a - t)), y, y);
	}
	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-239)
		tmp = Float64(x + Float64(y + Float64(Float64(t - z) / Float64(Float64(a - t) / y))));
	elseif (t_1 <= 0.0)
		tmp = Float64(x - Float64(y / Float64(t / Float64(a - z))));
	else
		tmp = Float64(x + fma(Float64(Float64(t - z) / Float64(a - t)), y, y));
	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[LessEqual[t$95$1, -5e-239], N[(x + N[(y + N[(N[(t - z), $MachinePrecision] / N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(x - N[(y / N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(t - z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + y), $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^{-239}:\\
\;\;\;\;x + \left(y + \frac{t - z}{\frac{a - t}{y}}\right)\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\

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


\end{array}

Error?

Target

Original74.3%
Target86.8%
Herbie91.9%
\[\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 3 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -5e-239

    1. Initial program 81.9%

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

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

      [Start]81.9

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

      associate--l+ [=>]82.1

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

      associate-/l* [=>]91.1

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

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

    1. Initial program 9.5%

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

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

      [Start]9.5

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

      associate-*l/ [<=]9.7

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot a - y \cdot z}{t} + x} \]
    4. Simplified96.1%

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

      [Start]96.1

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

      +-commutative [=>]96.1

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

      mul-1-neg [=>]96.1

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

      unsub-neg [=>]96.1

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

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

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

      associate-/l* [=>]96.1

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

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

    1. Initial program 79.4%

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

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

      [Start]79.4

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

      associate--l+ [=>]79.6

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

      sub-neg [=>]79.6

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

      +-commutative [=>]79.6

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

      associate-/l* [=>]90.4

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

      distribute-neg-frac [=>]90.4

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

      associate-/r/ [=>]91.9

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

      fma-def [=>]91.9

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

      sub-neg [=>]91.9

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

      +-commutative [=>]91.9

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

      distribute-neg-in [=>]91.9

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

      unsub-neg [=>]91.9

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

      remove-double-neg [=>]91.9

      \[ x + \mathsf{fma}\left(\frac{\color{blue}{t} - z}{a - t}, y, y\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.9%

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

Alternatives

Alternative 1
Accuracy91.3%
Cost2633
\[\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^{-239} \lor \neg \left(t_1 \leq 0\right):\\ \;\;\;\;x + \left(y + \frac{t - z}{\frac{a - t}{y}}\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \end{array} \]
Alternative 2
Accuracy76.9%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -7.2 \cdot 10^{-14} \lor \neg \left(t \leq 8 \cdot 10^{-33}\right):\\ \;\;\;\;x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 3
Accuracy76.8%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -7.4 \cdot 10^{-16} \lor \neg \left(t \leq 4.8 \cdot 10^{-35}\right):\\ \;\;\;\;x + \frac{z - a}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 4
Accuracy78.8%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -2.1 \cdot 10^{+51} \lor \neg \left(a \leq 2.1 \cdot 10^{+68}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \end{array} \]
Alternative 5
Accuracy81.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -2.1 \cdot 10^{+51} \lor \neg \left(a \leq 2 \cdot 10^{+68}\right):\\ \;\;\;\;\left(x + y\right) - z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \end{array} \]
Alternative 6
Accuracy81.8%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -1.08 \cdot 10^{+52} \lor \neg \left(a \leq 2 \cdot 10^{+68}\right):\\ \;\;\;\;\left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{t}{a - z}}\\ \end{array} \]
Alternative 7
Accuracy77.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -9.5 \cdot 10^{-53}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2.5 \cdot 10^{-90}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 8
Accuracy77.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -3.5 \cdot 10^{-53}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2 \cdot 10^{-90}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 9
Accuracy77.7%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.9 \cdot 10^{-52}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{-90}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 10
Accuracy68.8%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -2.6 \cdot 10^{+136}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{+76}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy56.5%
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+189}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 4.7 \cdot 10^{+27}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 12
Accuracy55.4%
Cost64
\[x \]

Error

Reproduce?

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