Average Error: 6.0 → 2.5
Time: 11.9s
Precision: binary64
Cost: 576
\[x + \frac{y \cdot \left(z - t\right)}{a} \]
\[x + \frac{z - t}{\frac{a}{y}} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
(FPCore (x y z t a) :precision binary64 (+ x (/ (- z t) (/ a y))))
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) {
	return x + ((z - t) / (a / y));
}
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
    code = x + ((z - t) / (a / y))
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) {
	return x + ((z - t) / (a / y));
}
def code(x, y, z, t, a):
	return x + ((y * (z - t)) / a)
def code(x, y, z, t, a):
	return x + ((z - t) / (a / y))
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)
	return Float64(x + Float64(Float64(z - t) / Float64(a / y)))
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y * (z - t)) / a);
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((z - t) / (a / y));
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_] := N[(x + N[(N[(z - t), $MachinePrecision] / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{y \cdot \left(z - t\right)}{a}
x + \frac{z - t}{\frac{a}{y}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.0
Target0.7
Herbie2.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. Initial program 6.0

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

    \[\leadsto x + \color{blue}{\frac{y}{a} \cdot \left(z - t\right)} \]
  3. Applied egg-rr2.5

    \[\leadsto x + \color{blue}{\frac{z - t}{\frac{a}{y}}} \]
  4. Final simplification2.5

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

Alternatives

Alternative 1
Error28.0
Cost1244
\[\begin{array}{l} t_1 := z \cdot \frac{y}{a}\\ t_2 := \frac{t \cdot \left(-y\right)}{a}\\ \mathbf{if}\;x \leq -4.507482250885998 \cdot 10^{-75}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.393902066024469 \cdot 10^{-306}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.8951589409718027 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3345476234698706 \cdot 10^{-235}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.729421160739016 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.782056327887322 \cdot 10^{-111}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error27.6
Cost1244
\[\begin{array}{l} t_1 := z \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -4.507482250885998 \cdot 10^{-75}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.393902066024469 \cdot 10^{-306}:\\ \;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 2.8951589409718027 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3345476234698706 \cdot 10^{-235}:\\ \;\;\;\;\frac{t \cdot \left(-y\right)}{a}\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.729421160739016 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.782056327887322 \cdot 10^{-111}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error27.6
Cost1244
\[\begin{array}{l} t_1 := z \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -4.507482250885998 \cdot 10^{-75}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.393902066024469 \cdot 10^{-306}:\\ \;\;\;\;\frac{y}{a} \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 2.8951589409718027 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3345476234698706 \cdot 10^{-235}:\\ \;\;\;\;\frac{t}{a} \cdot \left(-y\right)\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.729421160739016 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.782056327887322 \cdot 10^{-111}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error28.4
Cost848
\[\begin{array}{l} t_1 := \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;x \leq -1.2545293709540822 \cdot 10^{-107}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.729421160739016 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.782056327887322 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error28.4
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2545293709540822 \cdot 10^{-107}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;\frac{y}{\frac{a}{z}}\\ \mathbf{elif}\;x \leq 5.729421160739016 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.782056327887322 \cdot 10^{-111}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error28.1
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2545293709540822 \cdot 10^{-107}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{elif}\;x \leq 5.729421160739016 \cdot 10^{-126}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.782056327887322 \cdot 10^{-111}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error14.2
Cost844
\[\begin{array}{l} t_1 := x - t \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -4.9235899911462975 \cdot 10^{-105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{elif}\;x \leq 8.080443688791022 \cdot 10^{+130}:\\ \;\;\;\;x + y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error19.0
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0013054940819153 \cdot 10^{+55}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.840595679133457 \cdot 10^{-71}:\\ \;\;\;\;\frac{z - t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error18.9
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0013054940819153 \cdot 10^{+55}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.840595679133457 \cdot 10^{-71}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error15.4
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{a}\\ \mathbf{if}\;x \leq -3.14204748956194 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.151314293952634 \cdot 10^{-168}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error30.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
  :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)))