?

Average Accuracy: 74.3% → 90.2%
Time: 15.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 -2 \cdot 10^{-219}:\\ \;\;\;\;x - \left(\frac{y}{\frac{a - t}{z - t}} - y\right)\\ \mathbf{elif}\;t_1 \leq 10^{-225}:\\ \;\;\;\;x - \frac{y \cdot \left(a - z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \mathsf{fma}\left(z - t, \frac{y}{t - a}, 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 -2e-219)
     (- x (- (/ y (/ (- a t) (- z t))) y))
     (if (<= t_1 1e-225)
       (- x (/ (* y (- a z)) t))
       (+ x (fma (- z t) (/ y (- t a)) 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 <= -2e-219) {
		tmp = x - ((y / ((a - t) / (z - t))) - y);
	} else if (t_1 <= 1e-225) {
		tmp = x - ((y * (a - z)) / t);
	} else {
		tmp = x + fma((z - t), (y / (t - a)), 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 <= -2e-219)
		tmp = Float64(x - Float64(Float64(y / Float64(Float64(a - t) / Float64(z - t))) - y));
	elseif (t_1 <= 1e-225)
		tmp = Float64(x - Float64(Float64(y * Float64(a - z)) / t));
	else
		tmp = Float64(x + fma(Float64(z - t), Float64(y / Float64(t - a)), 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, -2e-219], N[(x - N[(N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-225], N[(x - N[(N[(y * N[(a - z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] + 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 -2 \cdot 10^{-219}:\\
\;\;\;\;x - \left(\frac{y}{\frac{a - t}{z - t}} - y\right)\\

\mathbf{elif}\;t_1 \leq 10^{-225}:\\
\;\;\;\;x - \frac{y \cdot \left(a - z\right)}{t}\\

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


\end{array}

Error?

Target

Original74.3%
Target87.1%
Herbie90.2%
\[\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))) < -2.0000000000000001e-219

    1. Initial program 79.9%

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

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

      [Start]79.9

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

      +-rgt-identity [<=]79.9

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

      associate-+l+ [=>]79.9

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

      associate-+r- [<=]80.0

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

      +-rgt-identity [=>]80.0

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

      *-commutative [=>]80.0

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

      associate-/l* [=>]92.2

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

    if -2.0000000000000001e-219 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 9.9999999999999996e-226

    1. Initial program 17.5%

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

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

      [Start]17.5

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

      +-rgt-identity [<=]17.5

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

      associate-+l+ [=>]17.5

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

      associate-+r- [<=]52.2

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

      +-rgt-identity [=>]52.2

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

      *-commutative [=>]52.2

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

      associate-/l* [=>]53.1

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

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

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

      [Start]90.9

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

      *-commutative [<=]90.9

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

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

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

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

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

      associate-*r* [=>]90.9

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

      neg-mul-1 [<=]90.9

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

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

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

      [Start]90.9

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

      mul-1-neg [=>]90.9

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

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

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

      neg-sub0 [=>]90.9

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

      sub-neg [=>]90.9

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

      +-commutative [<=]90.9

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

      associate--r+ [=>]90.9

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

      neg-sub0 [<=]90.9

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

      remove-double-neg [=>]90.9

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

    if 9.9999999999999996e-226 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 80.2%

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

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

      [Start]80.2

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

      associate--l+ [=>]80.4

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

      sub-neg [=>]80.4

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

      +-commutative [=>]80.4

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

      distribute-neg-frac [=>]80.4

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

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

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

      associate-*r/ [<=]90.7

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

      mul-1-neg [<=]90.7

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

      associate-*r/ [<=]90.7

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

      fma-def [=>]88.1

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

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

Alternatives

Alternative 1
Accuracy92.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 -2 \cdot 10^{-219} \lor \neg \left(t_1 \leq 0\right):\\ \;\;\;\;x - \left(\frac{y}{\frac{a - t}{z - t}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(a - z\right)}{t}\\ \end{array} \]
Alternative 2
Accuracy90.2%
Cost2632
\[\begin{array}{l} t_1 := \left(x + y\right) + \frac{y \cdot \left(t - z\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-219}:\\ \;\;\;\;x - \left(\frac{y}{\frac{a - t}{z - t}} - y\right)\\ \mathbf{elif}\;t_1 \leq 10^{-225}:\\ \;\;\;\;x - \frac{y \cdot \left(a - z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) + \frac{t - z}{\frac{a - t}{y}}\\ \end{array} \]
Alternative 3
Accuracy73.6%
Cost1764
\[\begin{array}{l} t_1 := \left(x + y\right) + \frac{y}{\frac{a - t}{t}}\\ t_2 := x + \frac{y}{\frac{t - a}{z}}\\ \mathbf{if}\;z \leq -1.35 \cdot 10^{-18}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.65 \cdot 10^{-261}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{-248}:\\ \;\;\;\;x - \frac{y \cdot \left(a - z\right)}{t}\\ \mathbf{elif}\;z \leq 2.75 \cdot 10^{-149}:\\ \;\;\;\;\left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \mathbf{elif}\;z \leq 1.32 \cdot 10^{-30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.85 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+199}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+208}:\\ \;\;\;\;\frac{z}{\frac{t - a}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy79.2%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -1.75 \cdot 10^{+16} \lor \neg \left(a \leq 2.7 \cdot 10^{+51}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \end{array} \]
Alternative 5
Accuracy82.0%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -1.95 \cdot 10^{+39} \lor \neg \left(t \leq 1.2 \cdot 10^{+70}\right):\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \end{array} \]
Alternative 6
Accuracy83.1%
Cost840
\[\begin{array}{l} \mathbf{if}\;a \leq -2.7 \cdot 10^{+40}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 2.95 \cdot 10^{+50}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 7
Accuracy77.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;a \leq -3.4 \cdot 10^{-9} \lor \neg \left(a \leq 8.2 \cdot 10^{+47}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 8
Accuracy68.3%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{+35}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{+188}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Accuracy57.9%
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -1.38 \cdot 10^{+147}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+132}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 10
Accuracy2.8%
Cost64
\[0 \]
Alternative 11
Accuracy55.1%
Cost64
\[x \]

Error

Reproduce?

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