?

Average Error: 3.49% → 3.5%
Time: 8.4s
Precision: binary64
Cost: 840

?

\[x + \left(y - x\right) \cdot \frac{z}{t} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-269}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-278}:\\ \;\;\;\;x + z \cdot \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 (<= x -2.1e-269)
   (+ x (/ (- y x) (/ t z)))
   (if (<= x 2.5e-278) (+ x (* 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 (x <= -2.1e-269) {
		tmp = x + ((y - x) / (t / z));
	} else if (x <= 2.5e-278) {
		tmp = x + (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 (x <= (-2.1d-269)) then
        tmp = x + ((y - x) / (t / z))
    else if (x <= 2.5d-278) then
        tmp = x + (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 (x <= -2.1e-269) {
		tmp = x + ((y - x) / (t / z));
	} else if (x <= 2.5e-278) {
		tmp = x + (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 x <= -2.1e-269:
		tmp = x + ((y - x) / (t / z))
	elif x <= 2.5e-278:
		tmp = x + (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 (x <= -2.1e-269)
		tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z)));
	elseif (x <= 2.5e-278)
		tmp = Float64(x + Float64(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 (x <= -2.1e-269)
		tmp = x + ((y - x) / (t / z));
	elseif (x <= 2.5e-278)
		tmp = x + (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[x, -2.1e-269], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e-278], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $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}\;x \leq -2.1 \cdot 10^{-269}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\

\mathbf{elif}\;x \leq 2.5 \cdot 10^{-278}:\\
\;\;\;\;x + z \cdot \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

Original3.49%
Target3.67%
Herbie3.5%
\[\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 < -2.10000000000000005e-269

    1. Initial program 2.98

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

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

    if -2.10000000000000005e-269 < x < 2.49999999999999992e-278

    1. Initial program 9.22

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

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

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

    if 2.49999999999999992e-278 < x

    1. Initial program 3.25

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-269}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-278}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error38.3%
Cost1372
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;x \leq -3.5 \cdot 10^{-15}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-106}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-261}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-268}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error40.93%
Cost980
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ \mathbf{if}\;x \leq -4.1 \cdot 10^{-50}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-186}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-277}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-105}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error20.17%
Cost969
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{-6} \lor \neg \left(\frac{z}{t} \leq 4 \cdot 10^{-29}\right):\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error5.12%
Cost969
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -400000 \lor \neg \left(\frac{z}{t} \leq 10^{-5}\right):\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 5
Error5.04%
Cost968
\[\begin{array}{l} \mathbf{if}\;\frac{z}{t} \leq -400000:\\ \;\;\;\;\frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{-5}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z}{t}\\ \end{array} \]
Alternative 6
Error3.56%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-269} \lor \neg \left(x \leq 2.4 \cdot 10^{-278}\right):\\ \;\;\;\;x + \left(y - x\right) \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y - x}{t}\\ \end{array} \]
Alternative 7
Error40.87%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-48}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-103}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error40.4%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-50}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-100}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error3.49%
Cost576
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
Alternative 10
Error50.19%
Cost64
\[x \]

Error

Reproduce?

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