Average Error: 11.2 → 0.9
Time: 19.0s
Precision: binary64
Cost: 8264
\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{+83}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+267}:\\ \;\;\;\;t_1 + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - z, \frac{y}{t - a}, x\right)\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* y (- z t)) (- a t))))
   (if (<= t_1 -5e+83)
     (+ x (/ (- z t) (/ (- a t) y)))
     (if (<= t_1 5e+267) (+ t_1 x) (fma (- t z) (/ y (- t a)) x)))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (y * (z - t)) / (a - t);
	double tmp;
	if (t_1 <= -5e+83) {
		tmp = x + ((z - t) / ((a - t) / y));
	} else if (t_1 <= 5e+267) {
		tmp = t_1 + x;
	} else {
		tmp = fma((t - z), (y / (t - a)), x);
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t)))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(y * Float64(z - t)) / Float64(a - t))
	tmp = 0.0
	if (t_1 <= -5e+83)
		tmp = Float64(x + Float64(Float64(z - t) / Float64(Float64(a - t) / y)));
	elseif (t_1 <= 5e+267)
		tmp = Float64(t_1 + x);
	else
		tmp = fma(Float64(t - z), Float64(y / Float64(t - a)), x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+83], N[(x + N[(N[(z - t), $MachinePrecision] / N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+267], N[(t$95$1 + x), $MachinePrecision], N[(N[(t - z), $MachinePrecision] * N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+83}:\\
\;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+267}:\\
\;\;\;\;t_1 + x\\

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


\end{array}

Error

Target

Original11.2
Target1.3
Herbie0.9
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < -5.00000000000000029e83

    1. Initial program 31.1

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

      \[\leadsto x + \color{blue}{\frac{1}{a - t} \cdot \left(y \cdot \left(z - t\right)\right)} \]
    3. Applied egg-rr2.7

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

    if -5.00000000000000029e83 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 4.9999999999999999e267

    1. Initial program 0.3

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

    if 4.9999999999999999e267 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 58.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(t - z, \frac{y}{t - a}, x\right)} \]
      Proof
      (fma.f64 (-.f64 t z) (/.f64 y (-.f64 t a)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 y (-.f64 t a)))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 y (-.f64 t a))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 y) (*.f64 -1 (-.f64 t a)))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (/.f64 (*.f64 -1 y) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 t a)))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (/.f64 (*.f64 -1 y) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 t a)))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (/.f64 (*.f64 -1 y) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 t) a))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (/.f64 (*.f64 -1 y) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 t)) a)) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (/.f64 (*.f64 -1 y) (Rewrite<= +-commutative_binary64 (+.f64 a (neg.f64 t)))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (/.f64 (*.f64 -1 y) (Rewrite<= sub-neg_binary64 (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (fma.f64 (-.f64 t z) (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 y (-.f64 a t)))) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 t z) (*.f64 -1 (/.f64 y (-.f64 a t)))) x)): 2 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (-.f64 t z) -1) (/.f64 y (-.f64 a t)))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1 (-.f64 t z))) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 t z))) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 t z))) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 t) z)) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 t)) z) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (Rewrite<= +-commutative_binary64 (+.f64 z (neg.f64 t))) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (Rewrite<= sub-neg_binary64 (-.f64 z t)) (/.f64 y (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) x): 54 points increase in error, 20 points decrease in error
      (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y (-.f64 z t))) (-.f64 a t)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

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

Alternatives

Alternative 1
Error0.9
Cost1992
\[\begin{array}{l} t_1 := x + \frac{z - t}{\frac{a - t}{y}}\\ t_2 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_2 \leq -5 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+267}:\\ \;\;\;\;t_2 + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error10.7
Cost1236
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{t} + -1}\\ t_2 := x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{if}\;a \leq -8.209559077079785 \cdot 10^{+82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -3.25 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1 \cdot 10^{-50}:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{elif}\;a \leq 6 \cdot 10^{-173}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z}{t}\right)\\ \mathbf{elif}\;a \leq 4.8418111066876926 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error10.7
Cost1236
\[\begin{array}{l} t_1 := x - y \cdot \frac{t}{a - t}\\ t_2 := x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{if}\;a \leq -8.209559077079785 \cdot 10^{+82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -3.25 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1 \cdot 10^{-50}:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{elif}\;a \leq 6 \cdot 10^{-173}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z}{t}\right)\\ \mathbf{elif}\;a \leq 4.8418111066876926 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error16.2
Cost976
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{a}\\ \mathbf{if}\;t \leq -4.456717719577908 \cdot 10^{-6}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{-197}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.2273351137180652 \cdot 10^{-48}:\\ \;\;\;\;x - t \cdot \frac{y}{a}\\ \mathbf{elif}\;t \leq 7.156054475498363 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 5
Error13.1
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -3.4545460160444 \cdot 10^{+49}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 1974074805.1075013:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 6
Error12.1
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -3.4545460160444 \cdot 10^{+49}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 9.246082269212135 \cdot 10^{-15}:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - t \cdot \frac{y}{a - t}\\ \end{array} \]
Alternative 7
Error11.1
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -3.4545460160444 \cdot 10^{+49}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z}{t}\right)\\ \mathbf{elif}\;t \leq 9.246082269212135 \cdot 10^{-15}:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - t \cdot \frac{y}{a - t}\\ \end{array} \]
Alternative 8
Error8.1
Cost840
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{a - t}\\ \mathbf{if}\;z \leq -3.33043214345205 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.7003583520702786 \cdot 10^{+55}:\\ \;\;\;\;x - y \cdot \frac{t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error2.8
Cost836
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1971846849361738 \cdot 10^{+181}:\\ \;\;\;\;x + \left(y - y \cdot \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \end{array} \]
Alternative 10
Error18.7
Cost712
\[\begin{array}{l} t_1 := x - t \cdot \frac{y}{a}\\ \mathbf{if}\;a \leq -1.9817983067121436 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.7655907419517845 \cdot 10^{+106}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error14.7
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -3.4545460160444 \cdot 10^{+49}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 7.156054475498363 \cdot 10^{+46}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 12
Error20.6
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq -1.9817983067121436 \cdot 10^{+62}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 1.7655907419517845 \cdot 10^{+106}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error26.9
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+173}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+187}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 14
Error50.8
Cost64
\[y \]

Error

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- a t) (- z t))))

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