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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 2.0

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

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

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

Alternatives

Alternative 1
Error5.5
Cost1356
\[\begin{array}{l} t_1 := t + \frac{x}{\frac{y}{z - t}}\\ \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq -5 \cdot 10^{-132}:\\ \;\;\;\;t + \frac{z \cdot x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{x}{y}\\ \end{array} \]
Alternative 2
Error22.4
Cost1164
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -0.05:\\ \;\;\;\;\frac{x}{\frac{y}{z}}\\ \mathbf{elif}\;\frac{x}{y} \leq 0.001:\\ \;\;\;\;t\\ \mathbf{elif}\;\frac{x}{y} \leq 2 \cdot 10^{+118}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{x}}\\ \end{array} \]
Alternative 3
Error14.0
Cost968
\[\begin{array}{l} t_1 := \frac{\left(z - t\right) \cdot x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -0.05:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 0.001:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error14.2
Cost968
\[\begin{array}{l} t_1 := \frac{\left(z - t\right) \cdot x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -0.05:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{+53}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error5.9
Cost968
\[\begin{array}{l} t_1 := \frac{\left(z - t\right) \cdot x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -40000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 0.001:\\ \;\;\;\;t + \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error4.8
Cost968
\[\begin{array}{l} t_1 := \left(z - t\right) \cdot \frac{x}{y}\\ \mathbf{if}\;\frac{x}{y} \leq -40000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-20}:\\ \;\;\;\;t + \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error22.3
Cost840
\[\begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -0.05:\\ \;\;\;\;\frac{x}{\frac{y}{z}}\\ \mathbf{elif}\;\frac{x}{y} \leq 5 \cdot 10^{-20}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{x}}\\ \end{array} \]
Alternative 8
Error27.8
Cost584
\[\begin{array}{l} t_1 := \frac{x}{\frac{y}{z}}\\ \mathbf{if}\;x \leq -3.2 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+103}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error27.8
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \frac{z}{y}\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+103}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{z}}\\ \end{array} \]
Alternative 10
Error31.5
Cost64
\[t \]

Error

Reproduce

herbie shell --seed 2022316 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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