Average Error: 2.0 → 9.0
Time: 7.7s
Precision: binary64
Cost: 712
\[x + \left(y - x\right) \cdot \frac{z}{t} \]
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -6.375180198174095 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.021366376564123 \cdot 10^{-8}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* y (/ z t)))))
   (if (<= y -6.375180198174095e-9)
     t_1
     (if (<= y 8.021366376564123e-8) (- x (/ x (/ t z))) t_1))))
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 t_1 = x + (y * (z / t));
	double tmp;
	if (y <= -6.375180198174095e-9) {
		tmp = t_1;
	} else if (y <= 8.021366376564123e-8) {
		tmp = x - (x / (t / z));
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_1 = x + (y * (z / t))
    if (y <= (-6.375180198174095d-9)) then
        tmp = t_1
    else if (y <= 8.021366376564123d-8) then
        tmp = x - (x / (t / z))
    else
        tmp = t_1
    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 t_1 = x + (y * (z / t));
	double tmp;
	if (y <= -6.375180198174095e-9) {
		tmp = t_1;
	} else if (y <= 8.021366376564123e-8) {
		tmp = x - (x / (t / z));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y - x) * (z / t))
def code(x, y, z, t):
	t_1 = x + (y * (z / t))
	tmp = 0
	if y <= -6.375180198174095e-9:
		tmp = t_1
	elif y <= 8.021366376564123e-8:
		tmp = x - (x / (t / z))
	else:
		tmp = t_1
	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)
	t_1 = Float64(x + Float64(y * Float64(z / t)))
	tmp = 0.0
	if (y <= -6.375180198174095e-9)
		tmp = t_1;
	elseif (y <= 8.021366376564123e-8)
		tmp = Float64(x - Float64(x / Float64(t / z)));
	else
		tmp = t_1;
	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)
	t_1 = x + (y * (z / t));
	tmp = 0.0;
	if (y <= -6.375180198174095e-9)
		tmp = t_1;
	elseif (y <= 8.021366376564123e-8)
		tmp = x - (x / (t / z));
	else
		tmp = t_1;
	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_] := Block[{t$95$1 = N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.375180198174095e-9], t$95$1, If[LessEqual[y, 8.021366376564123e-8], N[(x - N[(x / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
t_1 := x + y \cdot \frac{z}{t}\\
\mathbf{if}\;y \leq -6.375180198174095 \cdot 10^{-9}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 8.021366376564123 \cdot 10^{-8}:\\
\;\;\;\;x - \frac{x}{\frac{t}{z}}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.0
Target2.3
Herbie9.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. Split input into 2 regimes
  2. if y < -6.3751801981740951e-9 or 8.0213663765641235e-8 < y

    1. Initial program 1.3

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

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}} \]
    3. Taylor expanded in y around inf 9.8

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    4. Applied egg-rr10.8

      \[\leadsto x + \color{blue}{\frac{y}{t} \cdot z} \]
    5. Taylor expanded in y around 0 9.8

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t}} \]
    6. Simplified5.2

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

    if -6.3751801981740951e-9 < y < 8.0213663765641235e-8

    1. Initial program 2.7

      \[x + \left(y - x\right) \cdot \frac{z}{t} \]
    2. Taylor expanded in x around inf 12.4

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{z}{t}\right) \cdot x} \]
    3. Simplified12.4

      \[\leadsto \color{blue}{x - x \cdot \frac{z}{t}} \]
    4. Applied egg-rr12.2

      \[\leadsto x - \color{blue}{\frac{x}{\frac{t}{z}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.375180198174095 \cdot 10^{-9}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 8.021366376564123 \cdot 10^{-8}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error23.1
Cost1944
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ t_2 := \frac{x \cdot z}{-t}\\ \mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{+31}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{-74}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq 0.05:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error23.3
Cost1684
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot \left(-x\right)\\ \mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq -2 \cdot 10^{-11}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{-74}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;\frac{z}{t} \leq 5:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error22.8
Cost1360
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -2 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 0.05:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error22.8
Cost1360
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -2 \cdot 10^{-11}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{z}{t} \leq 2 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 0.05:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error14.2
Cost968
\[\begin{array}{l} t_1 := \frac{z}{t} \cdot \left(-x\right)\\ \mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 5:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error6.1
Cost968
\[\begin{array}{l} t_1 := z \cdot \frac{y - x}{t}\\ \mathbf{if}\;\frac{z}{t} \leq -500000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{z}{t} \leq 0.05:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error11.7
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ \mathbf{if}\;y \leq -6.375180198174095 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.021366376564123 \cdot 10^{-8}:\\ \;\;\;\;x - x \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error11.6
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ \mathbf{if}\;y \leq -6.375180198174095 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.021366376564123 \cdot 10^{-8}:\\ \;\;\;\;x - \frac{x}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error31.2
Cost64
\[x \]

Error

Reproduce

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