Average Error: 1.4 → 1.3
Time: 12.6s
Precision: binary64
Cost: 969
\[x + y \cdot \frac{z - t}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -8 \cdot 10^{+16} \lor \neg \left(t \leq 10\right):\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- a t)))))
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= t -8e+16) (not (<= t 10.0)))
   (+ x (* y (/ (- z t) (- a t))))
   (+ x (/ (- z t) (/ (- a t) y)))))
double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (a - t)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -8e+16) || !(t <= 10.0)) {
		tmp = x + (y * ((z - t) / (a - t)));
	} else {
		tmp = x + ((z - t) / ((a - t) / y));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + (y * ((z - t) / (a - t)))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((t <= (-8d+16)) .or. (.not. (t <= 10.0d0))) then
        tmp = x + (y * ((z - t) / (a - t)))
    else
        tmp = x + ((z - t) / ((a - t) / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (a - t)));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -8e+16) || !(t <= 10.0)) {
		tmp = x + (y * ((z - t) / (a - t)));
	} else {
		tmp = x + ((z - t) / ((a - t) / y));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + (y * ((z - t) / (a - t)))
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -8e+16) or not (t <= 10.0):
		tmp = x + (y * ((z - t) / (a - t)))
	else:
		tmp = x + ((z - t) / ((a - t) / y))
	return tmp
function code(x, y, z, t, a)
	return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t))))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -8e+16) || !(t <= 10.0))
		tmp = Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t))));
	else
		tmp = Float64(x + Float64(Float64(z - t) / Float64(Float64(a - t) / y)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + (y * ((z - t) / (a - t)));
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((t <= -8e+16) || ~((t <= 10.0)))
		tmp = x + (y * ((z - t) / (a - t)));
	else
		tmp = x + ((z - t) / ((a - t) / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -8e+16], N[Not[LessEqual[t, 10.0]], $MachinePrecision]], N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z - t), $MachinePrecision] / N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -8 \cdot 10^{+16} \lor \neg \left(t \leq 10\right):\\
\;\;\;\;x + y \cdot \frac{z - t}{a - t}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original1.4
Target0.4
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;y < -8.508084860551241 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if t < -8e16 or 10 < t

    1. Initial program 0.1

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

    if -8e16 < t < 10

    1. Initial program 2.9

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Applied egg-rr2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -8 \cdot 10^{+16} \lor \neg \left(t \leq 10\right):\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \end{array} \]

Alternatives

Alternative 1
Error12.9
Cost2640
\[\begin{array}{l} t_1 := \frac{z - t}{a - t}\\ t_2 := x + \frac{y \cdot z}{a}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{+19}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-12}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 50000000:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;y \cdot t_1\\ \end{array} \]
Alternative 2
Error11.5
Cost2124
\[\begin{array}{l} t_1 := \frac{z - t}{a - t}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+110}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{+19}:\\ \;\;\;\;x - y \cdot \frac{z}{t}\\ \mathbf{elif}\;t_1 \leq 50000000:\\ \;\;\;\;x - y \cdot \frac{t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;y \cdot t_1\\ \end{array} \]
Alternative 3
Error25.9
Cost1372
\[\begin{array}{l} t_1 := y \cdot \frac{z}{a - t}\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+252}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{+164}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-126}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-39}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+150}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+225}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 4
Error23.4
Cost1108
\[\begin{array}{l} t_1 := z \cdot \frac{y}{a - t}\\ \mathbf{if}\;t \leq -2.7 \cdot 10^{-215}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq -7.2 \cdot 10^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.5 \cdot 10^{-293}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{-223}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{elif}\;t \leq 3 \cdot 10^{-180}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 5
Error10.6
Cost973
\[\begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{+88}:\\ \;\;\;\;x + y \cdot \frac{t - z}{t}\\ \mathbf{elif}\;t \leq -1.22 \cdot 10^{-119} \lor \neg \left(t \leq 1.55 \cdot 10^{-166}\right):\\ \;\;\;\;x - y \cdot \frac{t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \end{array} \]
Alternative 6
Error2.0
Cost969
\[\begin{array}{l} \mathbf{if}\;t \leq -3.4 \cdot 10^{-105} \lor \neg \left(t \leq 4 \cdot 10^{+109}\right):\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a - t}\\ \end{array} \]
Alternative 7
Error25.9
Cost848
\[\begin{array}{l} \mathbf{if}\;z \leq 1.2 \cdot 10^{-126}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-39}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+150}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+224}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 8
Error15.2
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -580000000:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 2.55 \cdot 10^{-98}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 9
Error1.4
Cost704
\[x + y \cdot \frac{z - t}{a - t} \]
Alternative 10
Error23.4
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2.8 \cdot 10^{-299}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-182}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 11
Error23.3
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.86 \cdot 10^{-295}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-182}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 12
Error23.3
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -9.2 \cdot 10^{-299}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 8.8 \cdot 10^{-182}:\\ \;\;\;\;\frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 13
Error23.5
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.52 \cdot 10^{-294}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 7 \cdot 10^{-177}:\\ \;\;\;\;\frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 14
Error20.1
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -160000000:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{-119}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 15
Error27.4
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{-187}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-70}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error28.6
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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