Average Error: 6.3 → 2.1
Time: 7.8s
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.3
Target2.2
Herbie2.1
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Initial program 6.3

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

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

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

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

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

Alternatives

Alternative 1
Error30.6
Cost1244
\[\begin{array}{l} \mathbf{if}\;t \leq -6 \cdot 10^{+31}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -2.6 \cdot 10^{-92}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;t \leq -4.5 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-214}:\\ \;\;\;\;\frac{y}{t} \cdot \left(-x\right)\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{-95}:\\ \;\;\;\;\frac{z \cdot y}{t}\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+38}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 4.791909451867119 \cdot 10^{+83}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error24.2
Cost1240
\[\begin{array}{l} t_1 := \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{if}\;t \leq -7 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -8.4 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.5 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+38}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 7.184467399990562 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.9
Cost976
\[\begin{array}{l} t_1 := \left(z - x\right) \cdot \frac{y}{t}\\ t_2 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -2.8954499251548366 \cdot 10^{-201}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.8400282005980855 \cdot 10^{-268}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.287739772796748 \cdot 10^{-178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 223471963747.05493:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error12.0
Cost976
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -1 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.1540895797096516 \cdot 10^{+111}:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq -1.5751455670162414 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1801263193.534293:\\ \;\;\;\;x - \frac{x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error29.2
Cost848
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -2.8954499251548366 \cdot 10^{-201}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.8400282005980855 \cdot 10^{-268}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.287739772796748 \cdot 10^{-178}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.5834260347304535 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error32.4
Cost64
\[x \]

Error

Reproduce

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