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

\mathbf{elif}\;t \leq 1.2729909712006244 \cdot 10^{-13}:\\
\;\;\;\;x - \frac{y}{\frac{a}{z}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target0.7
Herbie11.3
\[\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 t < -5.50000000000000003e120 or 1.27299097120062436e-13 < t

    1. Initial program 10.3

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

      \[\leadsto x - \color{blue}{-1 \cdot \frac{y \cdot t}{a}} \]
    3. Simplified10.1

      \[\leadsto x - \color{blue}{\left(-t\right) \cdot \frac{y}{a}} \]
    4. Applied egg-rr10.1

      \[\leadsto \color{blue}{t \cdot \frac{y}{a} + x} \]

    if -5.50000000000000003e120 < t < 1.27299097120062436e-13

    1. Initial program 3.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5.5 \cdot 10^{+120}:\\ \;\;\;\;t \cdot \frac{y}{a} + x\\ \mathbf{elif}\;t \leq 1.2729909712006244 \cdot 10^{-13}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y}{a} + x\\ \end{array} \]

Alternatives

Alternative 1
Error20.3
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3903158634800512 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.251745803953851 \cdot 10^{-54}:\\ \;\;\;\;\frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error18.5
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5639119254976997 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 24151598768137.45:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error15.0
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;x \leq -7.443501525911245 \cdot 10^{-124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.7413345596741496 \cdot 10^{-35}:\\ \;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error28.8
Cost648
\[\begin{array}{l} \mathbf{if}\;x \leq -7.731210893386766 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.251745803953851 \cdot 10^{-54}:\\ \;\;\;\;\frac{y \cdot z}{-a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error28.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7627249209107922 \cdot 10^{-149}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.7413345596741496 \cdot 10^{-35}:\\ \;\;\;\;\frac{t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error31.8
Cost64
\[x \]

Error

Reproduce

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