Average Error: 6.5 → 5.5
Time: 10.4s
Precision: binary64
Cost: 840
\[x - \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{if}\;y \leq -1.774297037521109 \cdot 10^{-158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.1129017943251568 \cdot 10^{-246}:\\ \;\;\;\;x - \frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- x (/ y (/ a (- z t))))))
   (if (<= y -1.774297037521109e-158)
     t_1
     (if (<= y -1.1129017943251568e-246) (- x (/ (* y z) a)) t_1))))
double code(double x, double y, double z, double t, double a) {
	return x - ((y * (z - t)) / a);
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = x - (y / (a / (z - t)));
	double tmp;
	if (y <= -1.774297037521109e-158) {
		tmp = t_1;
	} else if (y <= -1.1129017943251568e-246) {
		tmp = x - ((y * z) / a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x - ((y * (z - t)) / a)
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x - (y / (a / (z - t)))
    if (y <= (-1.774297037521109d-158)) then
        tmp = t_1
    else if (y <= (-1.1129017943251568d-246)) then
        tmp = x - ((y * z) / a)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x - ((y * (z - t)) / a);
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = x - (y / (a / (z - t)));
	double tmp;
	if (y <= -1.774297037521109e-158) {
		tmp = t_1;
	} else if (y <= -1.1129017943251568e-246) {
		tmp = x - ((y * z) / a);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x - ((y * (z - t)) / a)
def code(x, y, z, t, a):
	t_1 = x - (y / (a / (z - t)))
	tmp = 0
	if y <= -1.774297037521109e-158:
		tmp = t_1
	elif y <= -1.1129017943251568e-246:
		tmp = x - ((y * z) / a)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a)
	return Float64(x - Float64(Float64(y * Float64(z - t)) / a))
end
function code(x, y, z, t, a)
	t_1 = Float64(x - Float64(y / Float64(a / Float64(z - t))))
	tmp = 0.0
	if (y <= -1.774297037521109e-158)
		tmp = t_1;
	elseif (y <= -1.1129017943251568e-246)
		tmp = Float64(x - Float64(Float64(y * z) / a));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x - ((y * (z - t)) / a);
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = x - (y / (a / (z - t)));
	tmp = 0.0;
	if (y <= -1.774297037521109e-158)
		tmp = t_1;
	elseif (y <= -1.1129017943251568e-246)
		tmp = x - ((y * z) / a);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(y / N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.774297037521109e-158], t$95$1, If[LessEqual[y, -1.1129017943251568e-246], N[(x - N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
t_1 := x - \frac{y}{\frac{a}{z - t}}\\
\mathbf{if}\;y \leq -1.774297037521109 \cdot 10^{-158}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.1129017943251568 \cdot 10^{-246}:\\
\;\;\;\;x - \frac{y \cdot z}{a}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target0.7
Herbie5.5
\[\begin{array}{l} \mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x - \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.774297037521109e-158 or -1.1129017943251568e-246 < y

    1. Initial program 7.0

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

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

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

    if -1.774297037521109e-158 < y < -1.1129017943251568e-246

    1. Initial program 0.6

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

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

      \[\leadsto x - \color{blue}{\frac{y}{\frac{a}{z - t}}} \]
    4. Taylor expanded in t around 0 9.6

      \[\leadsto \color{blue}{x - \frac{y \cdot z}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.774297037521109 \cdot 10^{-158}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \mathbf{elif}\;y \leq -1.1129017943251568 \cdot 10^{-246}:\\ \;\;\;\;x - \frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array} \]

Alternatives

Alternative 1
Error10.4
Cost1108
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{z}}\\ t_2 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;t \leq -1.402001822068172 \cdot 10^{+66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -3081080439341305000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.3507539200825806 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 5.351519285771214 \cdot 10^{-255}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.2678034704621437 \cdot 10^{+46}:\\ \;\;\;\;x - \frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error10.5
Cost976
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{z}}\\ t_2 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;t \leq -1.402001822068172 \cdot 10^{+66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -3081080439341305000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.3507539200825806 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 4.2678034704621437 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error31.1
Cost848
\[\begin{array}{l} t_1 := \frac{y}{\frac{a}{t}}\\ \mathbf{if}\;t \leq -1.15 \cdot 10^{+249}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.6 \cdot 10^{+174}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -4.041190787364357 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.4 \cdot 10^{+187}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error29.9
Cost848
\[\begin{array}{l} t_1 := \frac{t}{\frac{a}{y}}\\ \mathbf{if}\;t \leq -1.15 \cdot 10^{+249}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -8.8 \cdot 10^{+213}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -4.041190787364357 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.4 \cdot 10^{+187}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error29.9
Cost848
\[\begin{array}{l} t_1 := t \cdot \frac{y}{a}\\ \mathbf{if}\;t \leq -1.15 \cdot 10^{+249}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -8.8 \cdot 10^{+213}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -4.041190787364357 \cdot 10^{+82}:\\ \;\;\;\;\frac{t}{\frac{a}{y}}\\ \mathbf{elif}\;t \leq 6.4 \cdot 10^{+187}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error28.6
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -6.636860264326105 \cdot 10^{-137}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.1103406851272273 \cdot 10^{-224}:\\ \;\;\;\;\frac{y \cdot t}{a}\\ \mathbf{elif}\;x \leq 3.338402219567645 \cdot 10^{-229}:\\ \;\;\;\;\frac{y \cdot \left(-z\right)}{a}\\ \mathbf{elif}\;x \leq 2.0276638745471298 \cdot 10^{-22}:\\ \;\;\;\;t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error19.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -3.465452985204399 \cdot 10^{+86}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1093827656294074 \cdot 10^{+64}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error16.2
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;x \leq -6.029874843556029 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.1093827656294074 \cdot 10^{+64}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error28.7
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -6.636860264326105 \cdot 10^{-137}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.8571565530538666 \cdot 10^{-34}:\\ \;\;\;\;\frac{y \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error30.7
Cost64
\[x \]

Error

Reproduce

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

  :herbie-target
  (if (< y -1.0761266216389975e-10) (- x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

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