?

Average Error: 6.5 → 1.7
Time: 9.6s
Precision: binary64
Cost: 1864

?

\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{-178}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;t_1 \leq 10^{+289}:\\ \;\;\;\;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 (/ (* (- z x) y) t))))
   (if (<= t_1 -4e-178)
     (+ x (* (- z x) (/ y t)))
     (if (<= t_1 1e+289) 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 + (((z - x) * y) / t);
	double tmp;
	if (t_1 <= -4e-178) {
		tmp = x + ((z - x) * (y / t));
	} else if (t_1 <= 1e+289) {
		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 + (((z - x) * y) / t)
    if (t_1 <= (-4d-178)) then
        tmp = x + ((z - x) * (y / t))
    else if (t_1 <= 1d+289) 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 + (((z - x) * y) / t);
	double tmp;
	if (t_1 <= -4e-178) {
		tmp = x + ((z - x) * (y / t));
	} else if (t_1 <= 1e+289) {
		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 + (((z - x) * y) / t)
	tmp = 0
	if t_1 <= -4e-178:
		tmp = x + ((z - x) * (y / t))
	elif t_1 <= 1e+289:
		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(Float64(z - x) * y) / t))
	tmp = 0.0
	if (t_1 <= -4e-178)
		tmp = Float64(x + Float64(Float64(z - x) * Float64(y / t)));
	elseif (t_1 <= 1e+289)
		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 + (((z - x) * y) / t);
	tmp = 0.0;
	if (t_1 <= -4e-178)
		tmp = x + ((z - x) * (y / t));
	elseif (t_1 <= 1e+289)
		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[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-178], N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+289], 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{\left(z - x\right) \cdot y}{t}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-178}:\\
\;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\

\mathbf{elif}\;t_1 \leq 10^{+289}:\\
\;\;\;\;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.5
Target1.9
Herbie1.7
\[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)) < -3.9999999999999998e-178

    1. Initial program 6.9

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

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

      [Start]6.9

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

      associate-*l/ [<=]1.7

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

    if -3.9999999999999998e-178 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.0000000000000001e289

    1. Initial program 1.0

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

    if 1.0000000000000001e289 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 46.4

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

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

      [Start]46.4

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

      associate-/l* [=>]5.8

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

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

Alternatives

Alternative 1
Error21.9
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{-80} \lor \neg \left(y \leq 2.4 \cdot 10^{-9} \lor \neg \left(y \leq 1.4 \cdot 10^{+56}\right) \land y \leq 2 \cdot 10^{+75}\right):\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error13.9
Cost977
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -1.05 \cdot 10^{-205}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{-169}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+93} \lor \neg \left(z \leq 3.3 \cdot 10^{+286}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \end{array} \]
Alternative 3
Error13.9
Cost977
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -4.3 \cdot 10^{-204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-169}:\\ \;\;\;\;x - \frac{x}{\frac{t}{y}}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+93} \lor \neg \left(z \leq 5.8 \cdot 10^{+287}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \end{array} \]
Alternative 4
Error21.2
Cost844
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;z \leq -5 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-53}:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \end{array} \]
Alternative 5
Error30.2
Cost717
\[\begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+54} \lor \neg \left(y \leq 1.6 \cdot 10^{+77}\right):\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error29.1
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1 \cdot 10^{+50}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{-43}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error29.1
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.05 \cdot 10^{+50}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 2.4 \cdot 10^{-40}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error1.9
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 9
Error1.7
Cost576
\[x + \frac{z - x}{\frac{t}{y}} \]
Alternative 10
Error32.0
Cost64
\[x \]

Error

Reproduce?

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