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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target2.2
Herbie2.1
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Initial program 6.4

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

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

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

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

Alternatives

Alternative 1
Error25.8
Cost980
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -5.751085135312617 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -9.870121280897563 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.1292509909742563 \cdot 10^{-169}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.3970343556013374 \cdot 10^{-274}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;x \leq 4.272794682655018 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error24.2
Cost976
\[\begin{array}{l} t_1 := \frac{z - x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -5.751085135312617 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.272794682655018 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.243548503255611 \cdot 10^{+104}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+141}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error11.2
Cost976
\[\begin{array}{l} t_1 := x + \frac{z \cdot y}{t}\\ t_2 := x - x \cdot \frac{y}{t}\\ \mathbf{if}\;x \leq -2.0307850805105914 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 6.269791038530099 \cdot 10^{-253}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.518083584242054 \cdot 10^{-198}:\\ \;\;\;\;\frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;x \leq 9.46027295064604 \cdot 10^{-43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error11.1
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -2.6 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{-102}:\\ \;\;\;\;\frac{z - x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error25.8
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -5.751085135312617 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.272794682655018 \cdot 10^{-101}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error31.8
Cost64
\[x \]

Error

Reproduce

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