Average Error: 6.0 → 0.9
Time: 11.4s
Precision: binary64
Cost: 1864
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+255}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;t_1 \leq 10^{+306}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \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 (- z x)) t))))
   (if (<= t_1 -2e+255)
     (+ x (/ (- z x) (/ t y)))
     (if (<= t_1 1e+306) t_1 (+ x (/ y (/ t (- z x))))))))
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 * (z - x)) / t);
	double tmp;
	if (t_1 <= -2e+255) {
		tmp = x + ((z - x) / (t / y));
	} else if (t_1 <= 1e+306) {
		tmp = t_1;
	} else {
		tmp = x + (y / (t / (z - x)));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * (z - x)) / t)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + ((y * (z - x)) / t)
    if (t_1 <= (-2d+255)) then
        tmp = x + ((z - x) / (t / y))
    else if (t_1 <= 1d+306) then
        tmp = t_1
    else
        tmp = x + (y / (t / (z - x)))
    end if
    code = tmp
end function
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 * (z - x)) / t);
	double tmp;
	if (t_1 <= -2e+255) {
		tmp = x + ((z - x) / (t / y));
	} else if (t_1 <= 1e+306) {
		tmp = t_1;
	} else {
		tmp = x + (y / (t / (z - x)));
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
def code(x, y, z, t):
	t_1 = x + ((y * (z - x)) / t)
	tmp = 0
	if t_1 <= -2e+255:
		tmp = x + ((z - x) / (t / y))
	elif t_1 <= 1e+306:
		tmp = t_1
	else:
		tmp = x + (y / (t / (z - x)))
	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(Float64(y * Float64(z - x)) / t))
	tmp = 0.0
	if (t_1 <= -2e+255)
		tmp = Float64(x + Float64(Float64(z - x) / Float64(t / y)));
	elseif (t_1 <= 1e+306)
		tmp = t_1;
	else
		tmp = Float64(x + Float64(y / Float64(t / Float64(z - x))));
	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 * (z - x)) / t);
	tmp = 0.0;
	if (t_1 <= -2e+255)
		tmp = x + ((z - x) / (t / y));
	elseif (t_1 <= 1e+306)
		tmp = t_1;
	else
		tmp = x + (y / (t / (z - x)));
	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[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+255], N[(x + N[(N[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+306], t$95$1, N[(x + N[(y / N[(t / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+255}:\\
\;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\

\mathbf{elif}\;t_1 \leq 10^{+306}:\\
\;\;\;\;t_1\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -1.99999999999999998e255

    1. Initial program 27.2

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

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

      [Start]27.2

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

      associate-*l/ [<=]3.3

      \[ x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Applied egg-rr3.2

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

    if -1.99999999999999998e255 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.00000000000000002e306

    1. Initial program 0.6

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

    if 1.00000000000000002e306 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 60.8

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

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

      [Start]60.8

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

      associate-/l* [=>]1.4

      \[ x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

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

Alternatives

Alternative 1
Error1.1
Cost1864
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+197}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;t_1 \leq 10^{+306}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \end{array} \]
Alternative 2
Error31.7
Cost1376
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{+133}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-61}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-80}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-262}:\\ \;\;\;\;\frac{-y}{\frac{t}{x}}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+142}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error31.9
Cost1376
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -1.95 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{+135}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-61}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-80}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-262}:\\ \;\;\;\;\frac{y}{t} \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 6.9 \cdot 10^{+143}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error31.8
Cost1376
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -4.8 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.32 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-80}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{\frac{-t}{y}}\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{+141}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.3
Cost1240
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{+133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-80}:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;z \leq 1.04 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error29.7
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{+131}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-60}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-81}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{+143}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error29.7
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -2.9 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{+132}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-61}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-80}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+142}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error11.5
Cost977
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -2.7 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-181}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;z \leq 2.75 \cdot 10^{+163} \lor \neg \left(z \leq 3.9 \cdot 10^{+234}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 9
Error11.9
Cost977
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -1 \cdot 10^{-84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-180}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;z \leq 2.75 \cdot 10^{+163} \lor \neg \left(z \leq 3.1 \cdot 10^{+234}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \end{array} \]
Alternative 10
Error11.3
Cost977
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -4 \cdot 10^{-84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-180}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{+170} \lor \neg \left(z \leq 6.5 \cdot 10^{+234}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z - x}{\frac{t}{y}}\\ \end{array} \]
Alternative 11
Error28.5
Cost850
\[\begin{array}{l} \mathbf{if}\;y \leq -2.05 \cdot 10^{+70} \lor \neg \left(y \leq 4.8 \cdot 10^{-82}\right) \land \left(y \leq 1.55 \cdot 10^{-43} \lor \neg \left(y \leq 2000\right)\right):\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error17.6
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-131} \lor \neg \left(x \leq 1.1 \cdot 10^{-70}\right):\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 13
Error2.1
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 14
Error30.9
Cost64
\[x \]

Error

Reproduce

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