Average Error: 6.2 → 1.0
Time: 12.9s
Precision: binary64
Cost: 1864
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{y}{\frac{t}{z - x}}\\ t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+295}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ y (/ t (- z x))))) (t_2 (+ x (/ (* y (- z x)) t))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+295) t_2 t_1))))
double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
	double t_1 = x + (y / (t / (z - x)));
	double t_2 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 2e+295) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x + (y / (t / (z - x)));
	double t_2 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 2e+295) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
def code(x, y, z, t):
	t_1 = x + (y / (t / (z - x)))
	t_2 = x + ((y * (z - x)) / t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 2e+295:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * Float64(z - x)) / t))
end
function code(x, y, z, t)
	t_1 = Float64(x + Float64(y / Float64(t / Float64(z - x))))
	t_2 = Float64(x + Float64(Float64(y * Float64(z - x)) / t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 2e+295)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * (z - x)) / t);
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (y / (t / (z - x)));
	t_2 = x + ((y * (z - x)) / t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 2e+295)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(y / N[(t / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+295], t$95$2, t$95$1]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{y}{\frac{t}{z - x}}\\
t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+295}:\\
\;\;\;\;t_2\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target2.1
Herbie1.0
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 2 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -inf.0 or 2e295 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 56.2

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

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

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
      Proof
      (/.f64 y (/.f64 t (-.f64 z x))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 y t) (-.f64 z x))): 50 points increase in error, 65 points decrease in error
      (Rewrite<= distribute-lft-out--_binary64 (-.f64 (*.f64 (/.f64 y t) z) (*.f64 (/.f64 y t) x))): 3 points increase in error, 2 points decrease in error
      (-.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y z) t)) (*.f64 (/.f64 y t) x)): 37 points increase in error, 30 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) t) (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y x) t))): 37 points increase in error, 29 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 y z) t) (neg.f64 (/.f64 (*.f64 y x) t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 y z) t) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 y x) t)))): 0 points increase in error, 0 points decrease in error

    if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 2e295

    1. Initial program 0.7

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

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

Alternatives

Alternative 1
Error22.9
Cost1504
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ t_2 := x - y \cdot \frac{x}{t}\\ t_3 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -5.233250163420243 \cdot 10^{-141}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.672661968860339 \cdot 10^{-269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.412441028118032 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.774255823852012 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.157704683336963 \cdot 10^{-113}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.0467171955771116 \cdot 10^{-93}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.3312679548968838 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.740593431790754 \cdot 10^{+20}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error28.4
Cost1376
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ t_2 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.744242690733691 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.9110022202364485 \cdot 10^{-87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -5.233250163420243 \cdot 10^{-141}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.672661968860339 \cdot 10^{-269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.412441028118032 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.774255823852012 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.157704683336963 \cdot 10^{-113}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.740593431790754 \cdot 10^{+20}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error19.5
Cost976
\[\begin{array}{l} t_1 := \frac{z - x}{\frac{t}{y}}\\ t_2 := x - y \cdot \frac{x}{t}\\ \mathbf{if}\;t \leq -2.15 \cdot 10^{-56}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -6.5 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.2 \cdot 10^{-186}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 9 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error11.9
Cost976
\[\begin{array}{l} t_1 := \frac{z - x}{\frac{t}{y}}\\ \mathbf{if}\;y \leq -7 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+116}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+177}:\\ \;\;\;\;x - y \cdot \frac{x}{t}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+296}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{-x}{t}\\ \end{array} \]
Alternative 5
Error28.5
Cost848
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;t \leq -2.15 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -6.5 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.9 \cdot 10^{-172}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error28.4
Cost848
\[\begin{array}{l} t_1 := \frac{y \cdot z}{t}\\ \mathbf{if}\;t \leq -2.15 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -6.5 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.9 \cdot 10^{-172}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error11.9
Cost844
\[\begin{array}{l} t_1 := \frac{z - x}{\frac{t}{y}}\\ \mathbf{if}\;y \leq -7 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+116}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+177}:\\ \;\;\;\;x - y \cdot \frac{x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error4.4
Cost840
\[\begin{array}{l} t_1 := x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{if}\;t \leq -1 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{-140}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error9.6
Cost712
\[\begin{array}{l} t_1 := x - x \cdot \frac{y}{t}\\ \mathbf{if}\;x \leq -2.3616402981098235 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.0008295601268171 \cdot 10^{+27}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error31.4
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022316 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

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

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