Average Error: 11.0 → 0.8
Time: 13.2s
Precision: binary64
Cost: 1993
\[x + \frac{\left(y - z\right) \cdot t}{a - z} \]
\[\begin{array}{l} t_1 := \frac{t \cdot \left(y - z\right)}{a - z}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{-107}\right):\\ \;\;\;\;x + t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + t_1\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* t (- y z)) (- a z))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e-107)))
     (+ x (* t (/ (- y z) (- a z))))
     (+ x t_1))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - z) * t) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (t * (y - z)) / (a - z);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e-107)) {
		tmp = x + (t * ((y - z) / (a - z)));
	} else {
		tmp = x + t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
	return x + (((y - z) * t) / (a - z));
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = (t * (y - z)) / (a - z);
	double tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e-107)) {
		tmp = x + (t * ((y - z) / (a - z)));
	} else {
		tmp = x + t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + (((y - z) * t) / (a - z))
def code(x, y, z, t, a):
	t_1 = (t * (y - z)) / (a - z)
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 5e-107):
		tmp = x + (t * ((y - z) / (a - z)))
	else:
		tmp = x + t_1
	return tmp
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z)))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(t * Float64(y - z)) / Float64(a - z))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e-107))
		tmp = Float64(x + Float64(t * Float64(Float64(y - z) / Float64(a - z))));
	else
		tmp = Float64(x + t_1);
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + (((y - z) * t) / (a - z));
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = (t * (y - z)) / (a - z);
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 5e-107)))
		tmp = x + (t * ((y - z) / (a - z)));
	else
		tmp = x + t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e-107]], $MachinePrecision]], N[(x + N[(t * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + t$95$1), $MachinePrecision]]]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
t_1 := \frac{t \cdot \left(y - z\right)}{a - z}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{-107}\right):\\
\;\;\;\;x + t \cdot \frac{y - z}{a - z}\\

\mathbf{else}:\\
\;\;\;\;x + t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.0
Target0.5
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;t < -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t < 3.9110949887586375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -inf.0 or 4.99999999999999971e-107 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z))

    1. Initial program 27.5

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

      \[\leadsto \color{blue}{x + \frac{y - z}{a - z} \cdot t} \]
      Proof
      (+.f64 x (*.f64 (/.f64 (-.f64 y z) (-.f64 a z)) t)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)))): 1 points increase in error, 1 points decrease in error

    if -inf.0 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 4.99999999999999971e-107

    1. Initial program 0.2

      \[x + \frac{\left(y - z\right) \cdot t}{a - z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

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

Alternatives

Alternative 1
Error1.4
Cost7108
\[\begin{array}{l} \mathbf{if}\;t \leq -6.6 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{fma}\left(y - z, \frac{t}{a - z}, x\right)\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-239}:\\ \;\;\;\;x + \frac{t \cdot \left(y - z\right)}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot \frac{y - z}{a - z}\\ \end{array} \]
Alternative 2
Error19.1
Cost1500
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot \frac{t}{a - z}\\ t_2 := x + \frac{t}{\frac{a}{y}}\\ \mathbf{if}\;x \leq -1.28 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-83}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-18}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;x \leq 3300000:\\ \;\;\;\;x - z \cdot \frac{t}{a}\\ \mathbf{elif}\;x \leq 1.56 \cdot 10^{+38}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 3
Error14.4
Cost1104
\[\begin{array}{l} t_1 := x + \frac{y - z}{\frac{a}{t}}\\ \mathbf{if}\;z \leq -1.55 \cdot 10^{+49}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq -1.12 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{-109}:\\ \;\;\;\;x - \frac{t \cdot y}{z}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 4
Error12.2
Cost1104
\[\begin{array}{l} t_1 := x + \frac{y - z}{\frac{a}{t}}\\ t_2 := x - \frac{t}{\frac{z}{y - z}}\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+49}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.42 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-109}:\\ \;\;\;\;x - \frac{t \cdot y}{z}\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error1.0
Cost968
\[\begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-7}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t}}\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{-234}:\\ \;\;\;\;x + \frac{t \cdot \left(y - z\right)}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot \frac{y - z}{a - z}\\ \end{array} \]
Alternative 6
Error22.0
Cost852
\[\begin{array}{l} t_1 := y \cdot \frac{t}{a}\\ \mathbf{if}\;z \leq -4.15 \cdot 10^{-234}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-302}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-265}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 7
Error22.0
Cost852
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-234}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-278}:\\ \;\;\;\;\frac{t \cdot y}{a}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-302}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-266}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;z \leq 5.3 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 8
Error22.0
Cost852
\[\begin{array}{l} \mathbf{if}\;z \leq -9.6 \cdot 10^{-234}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-279}:\\ \;\;\;\;t \cdot \frac{y - z}{a}\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-302}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-266}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 9
Error22.6
Cost852
\[\begin{array}{l} \mathbf{if}\;z \leq -3.3 \cdot 10^{-161}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-278}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{t}{a}\\ \mathbf{elif}\;z \leq 3.85 \cdot 10^{-302}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-266}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 10
Error14.6
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+49} \lor \neg \left(z \leq 6 \cdot 10^{-18}\right):\\ \;\;\;\;t + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t}{\frac{a}{y}}\\ \end{array} \]
Alternative 11
Error14.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+49}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-20}:\\ \;\;\;\;x + \frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 12
Error1.4
Cost704
\[x + t \cdot \frac{y - z}{a - z} \]
Alternative 13
Error20.5
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+49}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 14
Error28.4
Cost196
\[\begin{array}{l} \mathbf{if}\;t \leq 1.15 \cdot 10^{+114}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error51.0
Cost64
\[t \]

Error

Reproduce

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

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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