Average Error: 1.9 → 2.3
Time: 8.1s
Precision: binary64
Cost: 840
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9 \cdot 10^{+37}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-277}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= x -3.9e+37)
   (+ x (* (- y x) (/ z t)))
   (if (<= x -1.7e-277) (+ x (* z (/ (- y x) t))) (+ 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) {
	double tmp;
	if (x <= -3.9e+37) {
		tmp = x + ((y - x) * (z / t));
	} else if (x <= -1.7e-277) {
		tmp = x + (z * ((y - x) / t));
	} else {
		tmp = x + ((y - x) / (t / z));
	}
	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 (x <= (-3.9d+37)) then
        tmp = x + ((y - x) * (z / t))
    else if (x <= (-1.7d-277)) then
        tmp = x + (z * ((y - x) / t))
    else
        tmp = x + ((y - x) / (t / z))
    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 (x <= -3.9e+37) {
		tmp = x + ((y - x) * (z / t));
	} else if (x <= -1.7e-277) {
		tmp = x + (z * ((y - x) / t));
	} else {
		tmp = x + ((y - x) / (t / z));
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y - x) * (z / t))
def code(x, y, z, t):
	tmp = 0
	if x <= -3.9e+37:
		tmp = x + ((y - x) * (z / t))
	elif x <= -1.7e-277:
		tmp = x + (z * ((y - x) / t))
	else:
		tmp = x + ((y - x) / (t / z))
	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 (x <= -3.9e+37)
		tmp = Float64(x + Float64(Float64(y - x) * Float64(z / t)));
	elseif (x <= -1.7e-277)
		tmp = Float64(x + Float64(z * Float64(Float64(y - x) / t)));
	else
		tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z)));
	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 (x <= -3.9e+37)
		tmp = x + ((y - x) * (z / t));
	elseif (x <= -1.7e-277)
		tmp = x + (z * ((y - x) / t));
	else
		tmp = x + ((y - x) / (t / z));
	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[x, -3.9e+37], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.7e-277], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;x \leq -3.9 \cdot 10^{+37}:\\
\;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\

\mathbf{elif}\;x \leq -1.7 \cdot 10^{-277}:\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original1.9
Target2.0
Herbie2.3
\[\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 3 regimes
  2. if x < -3.8999999999999999e37

    1. Initial program 0.1

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

    if -3.8999999999999999e37 < x < -1.69999999999999991e-277

    1. Initial program 2.6

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}} \]
    3. Applied egg-rr4.1

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

    if -1.69999999999999991e-277 < x

    1. Initial program 2.2

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.9 \cdot 10^{+37}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq -1.7 \cdot 10^{-277}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array} \]

Alternatives

Alternative 1
Error11.4
Cost1748
\[\begin{array}{l} t_1 := x \cdot \frac{z}{-t}\\ t_2 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -2 \cdot 10^{+157}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+50}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{+152}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \end{array} \]
Alternative 2
Error11.0
Cost1240
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ t_2 := x - \frac{z}{\frac{t}{x}}\\ t_3 := x - \frac{x}{\frac{t}{z}}\\ \mathbf{if}\;x \leq -7.2 \cdot 10^{+88}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-88}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-47}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error11.0
Cost1240
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ t_2 := x - \frac{z}{\frac{t}{x}}\\ \mathbf{if}\;x \leq -4.7 \cdot 10^{+88}:\\ \;\;\;\;x + x \cdot \frac{z}{-t}\\ \mathbf{elif}\;x \leq -1.12 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.1 \cdot 10^{-87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-159}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-47}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \end{array} \]
Alternative 4
Error11.9
Cost1228
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq 2 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+119}:\\ \;\;\;\;x \cdot \frac{z}{-t}\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \end{array} \]
Alternative 5
Error11.8
Cost1228
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq 2 \cdot 10^{+50}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{+119}:\\ \;\;\;\;x \cdot \frac{z}{-t}\\ \mathbf{elif}\;\frac{z}{t} \leq 4 \cdot 10^{+152}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \end{array} \]
Alternative 6
Error1.8
Cost1220
\[\begin{array}{l} t_1 := x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{if}\;t_1 \leq 10^{+305}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \end{array} \]
Alternative 7
Error22.0
Cost904
\[\begin{array}{l} t_1 := x \cdot \frac{z}{-t}\\ \mathbf{if}\;\frac{z}{t} \leq -100000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error22.4
Cost904
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -100000:\\ \;\;\;\;x \cdot \frac{z}{-t}\\ \mathbf{elif}\;\frac{z}{t} \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \frac{-x}{t}\\ \end{array} \]
Alternative 9
Error22.4
Cost904
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -100000:\\ \;\;\;\;x \cdot \frac{z}{-t}\\ \mathbf{elif}\;\frac{z}{t} \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(-x\right)}{t}\\ \end{array} \]
Alternative 10
Error2.3
Cost840
\[\begin{array}{l} t_1 := x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{if}\;x \leq -1 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-299}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error8.1
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{-50}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-39}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 12
Error31.0
Cost64
\[x \]

Error

Reproduce

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