?

Average Error: 2.1 → 1.6
Time: 21.9s
Precision: binary64
Cost: 1092

?

\[x + \left(y - x\right) \cdot \frac{z}{t} \]
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{+202}:\\ \;\;\;\;x + \frac{0.5}{\frac{\frac{0.5}{z}}{\frac{y - x}{t}}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ z t) -4e+202)
   (+ x (/ 0.5 (/ (/ 0.5 z) (/ (- y x) t))))
   (+ x (* (- y x) (/ z t)))))
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) {
	double tmp;
	if ((z / t) <= -4e+202) {
		tmp = x + (0.5 / ((0.5 / z) / ((y - x) / t)));
	} else {
		tmp = x + ((y - x) * (z / t));
	}
	return tmp;
}
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
    real(8) :: tmp
    if ((z / t) <= (-4d+202)) then
        tmp = x + (0.5d0 / ((0.5d0 / z) / ((y - x) / t)))
    else
        tmp = x + ((y - x) * (z / t))
    end if
    code = tmp
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) {
	double tmp;
	if ((z / t) <= -4e+202) {
		tmp = x + (0.5 / ((0.5 / z) / ((y - x) / t)));
	} else {
		tmp = x + ((y - x) * (z / t));
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y - x) * (z / t))
def code(x, y, z, t):
	tmp = 0
	if (z / t) <= -4e+202:
		tmp = x + (0.5 / ((0.5 / z) / ((y - x) / t)))
	else:
		tmp = x + ((y - x) * (z / t))
	return tmp
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y - x) * Float64(z / t)))
end
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z / t) <= -4e+202)
		tmp = Float64(x + Float64(0.5 / Float64(Float64(0.5 / z) / Float64(Float64(y - x) / t))));
	else
		tmp = Float64(x + Float64(Float64(y - x) * Float64(z / t)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x + ((y - x) * (z / t));
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z / t) <= -4e+202)
		tmp = x + (0.5 / ((0.5 / z) / ((y - x) / t)));
	else
		tmp = x + ((y - x) * (z / t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], -4e+202], N[(x + N[(0.5 / N[(N[(0.5 / z), $MachinePrecision] / N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{+202}:\\
\;\;\;\;x + \frac{0.5}{\frac{\frac{0.5}{z}}{\frac{y - x}{t}}}\\

\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target2.4
Herbie1.6
\[\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. Split input into 2 regimes
  2. if (/.f64 z t) < -3.9999999999999996e202

    1. Initial program 18.5

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

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

    if -3.9999999999999996e202 < (/.f64 z t)

    1. Initial program 1.6

      \[x + \left(y - x\right) \cdot \frac{z}{t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{+202}:\\ \;\;\;\;x + \frac{0.5}{\frac{\frac{0.5}{z}}{\frac{y - x}{t}}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error23.5
Cost2204
\[\begin{array}{l} t_1 := z \cdot \left(-\frac{x}{t}\right)\\ t_2 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{+230}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq -5 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{+17}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error22.7
Cost2204
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot \left(-x\right)\\ t_2 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -5 \cdot 10^{+163}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{-10}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{+17}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error22.6
Cost2204
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot \left(-x\right)\\ t_2 := y \cdot \frac{z}{t}\\ t_3 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;\frac{z}{t} \leq -5 \cdot 10^{+163}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq -1000000:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-91}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{-30}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{+17}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error22.6
Cost1360
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -1.36 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 5.1 \cdot 10^{-89}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 6.5 \cdot 10^{-54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 5.1 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error23.2
Cost1360
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -2 \cdot 10^{-10}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error23.1
Cost1360
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -2 \cdot 10^{-10}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error5.4
Cost1104
\[\begin{array}{l} t_1 := x + z \cdot \frac{y - x}{t}\\ t_2 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{+77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -8.8 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-234}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error1.6
Cost836
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -5 \cdot 10^{+182}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
Alternative 9
Error1.6
Cost836
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -4 \cdot 10^{+202}:\\ \;\;\;\;x + \frac{z}{\frac{t}{y - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
Alternative 10
Error10.6
Cost776
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-87}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-131}:\\ \;\;\;\;x + x \cdot \frac{z}{-t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 11
Error10.8
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-97}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error10.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.05 \cdot 10^{-89}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-130}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 13
Error32.0
Cost64
\[x \]

Error

Reproduce?

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