Average Error: 6.2 → 2.5
Time: 10.4s
Precision: binary64
Cost: 840
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{if}\;t \leq -1 \cdot 10^{-220}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{-180}:\\ \;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\ \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 (* (- z x) (/ y t)))))
   (if (<= t -1e-220) t_1 (if (<= t 1e-180) (/ (* (- z x) y) t) 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 + ((z - x) * (y / t));
	double tmp;
	if (t <= -1e-220) {
		tmp = t_1;
	} else if (t <= 1e-180) {
		tmp = ((z - x) * y) / t;
	} else {
		tmp = t_1;
	}
	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 <= (-1d-220)) then
        tmp = t_1
    else if (t <= 1d-180) then
        tmp = ((z - x) * y) / t
    else
        tmp = t_1
    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 <= -1e-220) {
		tmp = t_1;
	} else if (t <= 1e-180) {
		tmp = ((z - x) * y) / t;
	} 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 + ((z - x) * (y / t))
	tmp = 0
	if t <= -1e-220:
		tmp = t_1
	elif t <= 1e-180:
		tmp = ((z - x) * y) / t
	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(Float64(z - x) * Float64(y / t)))
	tmp = 0.0
	if (t <= -1e-220)
		tmp = t_1;
	elseif (t <= 1e-180)
		tmp = Float64(Float64(Float64(z - x) * y) / t);
	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 + ((z - x) * (y / t));
	tmp = 0.0;
	if (t <= -1e-220)
		tmp = t_1;
	elseif (t <= 1e-180)
		tmp = ((z - x) * y) / t;
	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[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1e-220], t$95$1, If[LessEqual[t, 1e-180], N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \left(z - x\right) \cdot \frac{y}{t}\\
\mathbf{if}\;t \leq -1 \cdot 10^{-220}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq 10^{-180}:\\
\;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\

\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.0
Herbie2.5
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 2 regimes
  2. if t < -9.99999999999999992e-221 or 1e-180 < t

    1. Initial program 6.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)} \]
    3. Applied egg-rr1.5

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

    if -9.99999999999999992e-221 < t < 1e-180

    1. Initial program 4.3

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - x\right)}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.5

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

Alternatives

Alternative 1
Error27.5
Cost1372
\[\begin{array}{l} t_1 := \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{+121}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.0724497921171005 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.0718673482768 \cdot 10^{-232}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.605894121362422 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+220}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{-t}{x}}\\ \end{array} \]
Alternative 2
Error31.3
Cost1244
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ t_2 := \frac{y}{\frac{-t}{x}}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+172}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{+65}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{+28}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.0718673482768 \cdot 10^{-232}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.605894121362422 \cdot 10^{-285}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 3200000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error31.3
Cost1244
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+172}:\\ \;\;\;\;\frac{y}{\frac{-t}{x}}\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{+65}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{+28}:\\ \;\;\;\;y \cdot \frac{-x}{t}\\ \mathbf{elif}\;y \leq -3.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.0718673482768 \cdot 10^{-232}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.605894121362422 \cdot 10^{-285}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 3200000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error20.0
Cost1240
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ t_2 := \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{if}\;t \leq -5.5944865449233026 \cdot 10^{+292}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.4406503125448907 \cdot 10^{+267}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;t \leq -3.6 \cdot 10^{-15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-148}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.15 \cdot 10^{-200}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-152}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error31.5
Cost1112
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ \mathbf{if}\;t \leq -5.5944865449233026 \cdot 10^{+292}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.4406503125448907 \cdot 10^{+267}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -340000000:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.15 \cdot 10^{-200}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{-187}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error30.1
Cost1112
\[\begin{array}{l} t_1 := \frac{z \cdot y}{t}\\ \mathbf{if}\;t \leq -5.5944865449233026 \cdot 10^{+292}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.4406503125448907 \cdot 10^{+267}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;t \leq -340000000:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.15 \cdot 10^{-200}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 3 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error23.8
Cost976
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z - x}}\\ \mathbf{if}\;y \leq -3.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -7.0718673482768 \cdot 10^{-232}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.605894121362422 \cdot 10^{-285}:\\ \;\;\;\;\frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error30.9
Cost848
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+172}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq -7.0718673482768 \cdot 10^{-232}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.605894121362422 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3200000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error30.7
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+172}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq -7.0718673482768 \cdot 10^{-232}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.605894121362422 \cdot 10^{-285}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 3200000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 10
Error10.8
Cost844
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.5047312837452006 \cdot 10^{-93}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5324632596303813 \cdot 10^{-207}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \mathbf{elif}\;x \leq 6.129485746848649 \cdot 10^{+78}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error10.9
Cost712
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -3.859310713934391 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.129485746848649 \cdot 10^{+78}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error31.1
Cost64
\[x \]

Error

Reproduce

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