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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target2.3
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} < -1013646692435.8867:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} < 0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]

Derivation

  1. Initial program 2.1

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

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

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

Alternatives

Alternative 1
Error4.2
Cost968
\[\begin{array}{l} t_1 := \frac{y - x}{\frac{t}{z}}\\ \mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error25.5
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -6.006350759445143 \cdot 10^{-164}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.815751373398074 \cdot 10^{-71}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error31.6
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022291 
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
  :precision binary64

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

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