Average Error: 10.7 → 0.4
Time: 13.2s
Precision: binary64
Cost: 1992
\[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 -\infty:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y} - \frac{t}{y}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+285}:\\ \;\;\;\;t_1 + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \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 (- INFINITY))
     (+ x (/ (- z t) (- (/ a y) (/ t y))))
     (if (<= t_1 2e+285) (+ t_1 x) (+ x (/ (- z t) (/ (- a t) y)))))))
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 <= -((double) INFINITY)) {
		tmp = x + ((z - t) / ((a / y) - (t / y)));
	} else if (t_1 <= 2e+285) {
		tmp = t_1 + x;
	} else {
		tmp = x + ((z - t) / ((a - t) / y));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / (a - t));
}
public static 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 <= -Double.POSITIVE_INFINITY) {
		tmp = x + ((z - t) / ((a / y) - (t / y)));
	} else if (t_1 <= 2e+285) {
		tmp = t_1 + x;
	} else {
		tmp = x + ((z - t) / ((a - t) / y));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + ((y * (z - t)) / (a - t))
def code(x, y, z, t, a):
	t_1 = (y * (z - t)) / (a - t)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = x + ((z - t) / ((a / y) - (t / y)))
	elif t_1 <= 2e+285:
		tmp = t_1 + x
	else:
		tmp = x + ((z - t) / ((a - t) / y))
	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 <= Float64(-Inf))
		tmp = Float64(x + Float64(Float64(z - t) / Float64(Float64(a / y) - Float64(t / y))));
	elseif (t_1 <= 2e+285)
		tmp = Float64(t_1 + x);
	else
		tmp = Float64(x + Float64(Float64(z - t) / Float64(Float64(a - t) / y)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y * (z - t)) / (a - t));
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (y * (z - t)) / (a - t);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = x + ((z - t) / ((a / y) - (t / y)));
	elseif (t_1 <= 2e+285)
		tmp = t_1 + x;
	else
		tmp = x + ((z - t) / ((a - t) / y));
	end
	tmp_2 = 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, (-Infinity)], N[(x + N[(N[(z - t), $MachinePrecision] / N[(N[(a / y), $MachinePrecision] - N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+285], N[(t$95$1 + x), $MachinePrecision], N[(x + N[(N[(z - t), $MachinePrecision] / N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;x + \frac{z - t}{\frac{a}{y} - \frac{t}{y}}\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;t_1 + x\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.7
Target1.3
Herbie0.4
\[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)) < -inf.0

    1. Initial program 64.0

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
    2. Taylor expanded in z around 0 64.0

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

      \[\leadsto x + \color{blue}{\frac{z - t}{\frac{a - t}{y}}} \]
      Proof
      (/.f64 (-.f64 z t) (/.f64 (-.f64 a t) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> div-sub_binary64 (-.f64 (/.f64 z (/.f64 (-.f64 a t) y)) (/.f64 t (/.f64 (-.f64 a t) y)))): 2 points increase in error, 1 points decrease in error
      (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z y) (-.f64 a t))) (/.f64 t (/.f64 (-.f64 a t) y))): 45 points increase in error, 26 points decrease in error
      (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y z)) (-.f64 a t)) (/.f64 t (/.f64 (-.f64 a t) y))): 0 points increase in error, 0 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 t y) (-.f64 a t)))): 55 points increase in error, 37 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y t)) (-.f64 a t))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (neg.f64 (/.f64 (*.f64 y t) (-.f64 a t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 y t) (-.f64 a t))))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr0.1

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

    if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 2e285

    1. Initial program 0.3

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

    if 2e285 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 60.6

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
    2. Taylor expanded in z around 0 60.6

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

      \[\leadsto x + \color{blue}{\frac{z - t}{\frac{a - t}{y}}} \]
      Proof
      (/.f64 (-.f64 z t) (/.f64 (-.f64 a t) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> div-sub_binary64 (-.f64 (/.f64 z (/.f64 (-.f64 a t) y)) (/.f64 t (/.f64 (-.f64 a t) y)))): 2 points increase in error, 1 points decrease in error
      (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z y) (-.f64 a t))) (/.f64 t (/.f64 (-.f64 a t) y))): 45 points increase in error, 26 points decrease in error
      (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y z)) (-.f64 a t)) (/.f64 t (/.f64 (-.f64 a t) y))): 0 points increase in error, 0 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 t y) (-.f64 a t)))): 55 points increase in error, 37 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y t)) (-.f64 a t))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (neg.f64 (/.f64 (*.f64 y t) (-.f64 a t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 y z) (-.f64 a t)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 y t) (-.f64 a t))))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

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

Alternatives

Alternative 1
Error0.4
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 -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+285}:\\ \;\;\;\;t_2 + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error15.2
Cost976
\[\begin{array}{l} \mathbf{if}\;t \leq -4.101312465113308 \cdot 10^{+208}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq -2.175705087915141 \cdot 10^{+171}:\\ \;\;\;\;\frac{y}{\frac{t - a}{t - z}}\\ \mathbf{elif}\;t \leq -7.098837352779528 \cdot 10^{-53}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 9.18287244730128 \cdot 10^{-67}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 3
Error9.4
Cost972
\[\begin{array}{l} t_1 := x - y \cdot \frac{t}{a - t}\\ \mathbf{if}\;t \leq -7.098837352779528 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-138}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{elif}\;t \leq 3.4391262444104223 \cdot 10^{-42}:\\ \;\;\;\;x + \frac{y \cdot z}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error8.4
Cost968
\[\begin{array}{l} t_1 := x - y \cdot \frac{t}{a - t}\\ \mathbf{if}\;t \leq -7.098837352779528 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.4391262444104223 \cdot 10^{-42}:\\ \;\;\;\;x + \frac{z}{\frac{a}{y} - \frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error9.9
Cost968
\[\begin{array}{l} \mathbf{if}\;t \leq -7.098837352779528 \cdot 10^{-53}:\\ \;\;\;\;x - y \cdot \frac{t}{a - t}\\ \mathbf{elif}\;t \leq 9.18287244730128 \cdot 10^{-67}:\\ \;\;\;\;x + \frac{z}{\frac{a}{y} - \frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) + \frac{y}{t} \cdot \left(a - z\right)\\ \end{array} \]
Alternative 6
Error2.8
Cost968
\[\begin{array}{l} t_1 := x + \frac{z - t}{\frac{a - t}{y}}\\ \mathbf{if}\;z \leq -8.835398421840407 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.7298130781119294 \cdot 10^{-178}:\\ \;\;\;\;x - y \cdot \frac{t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error10.4
Cost840
\[\begin{array}{l} t_1 := x - y \cdot \frac{t}{a - t}\\ \mathbf{if}\;t \leq -7.098837352779528 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.6426400631963737 \cdot 10^{-70}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error14.4
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -7.098837352779528 \cdot 10^{-53}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 9.18287244730128 \cdot 10^{-67}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 9
Error28.0
Cost592
\[\begin{array}{l} \mathbf{if}\;x \leq -6.397312807870599 \cdot 10^{-197}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.6217703460461606 \cdot 10^{-201}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq 5.379670348197073 \cdot 10^{-84}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.5634334007179 \cdot 10^{-10}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error23.2
Cost588
\[\begin{array}{l} \mathbf{if}\;a \leq -1.75 \cdot 10^{-28}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq -3 \cdot 10^{-84}:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{elif}\;a \leq 1.0464550742075862 \cdot 10^{+206}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error23.2
Cost588
\[\begin{array}{l} \mathbf{if}\;a \leq -1.75 \cdot 10^{-28}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;a \leq -3 \cdot 10^{-84}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{elif}\;a \leq 1.0464550742075862 \cdot 10^{+206}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error20.1
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -3.2312653445370984 \cdot 10^{-65}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 9.18287244730128 \cdot 10^{-67}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 13
Error51.4
Cost64
\[y \]

Error

Reproduce

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