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

\mathbf{elif}\;t \leq 2.224956389148705 \cdot 10^{+134}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original1.4
Target0.4
Herbie9.9
\[\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 < -2.8796304047865109e44 or 2.22495638914870484e134 < t

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z - t\right), \frac{1}{a - t}, x\right)} \]
    3. Taylor expanded in a around 0 24.6

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

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

    if -2.8796304047865109e44 < t < 2.22495638914870484e134

    1. Initial program 2.3

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Taylor expanded in z around inf 12.0

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{a - t}} \]
    3. Simplified9.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.879630404786511 \cdot 10^{+44}:\\ \;\;\;\;x - \frac{y}{t} \cdot \left(z - t\right)\\ \mathbf{elif}\;t \leq 2.224956389148705 \cdot 10^{+134}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{t} \cdot \left(z - t\right)\\ \end{array} \]

Alternatives

Alternative 1
Error13.3
Cost840
\[\begin{array}{l} t_1 := x - \frac{y}{t} \cdot \left(z - t\right)\\ \mathbf{if}\;t \leq -3.915764407337899 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.113627883376141 \cdot 10^{-100}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error11.7
Cost840
\[\begin{array}{l} t_1 := x - \frac{y}{t} \cdot \left(z - t\right)\\ \mathbf{if}\;t \leq -2871975491.741219:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.6895308225257804 \cdot 10^{-44}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error20.8
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -1.6027710243514267 \cdot 10^{-9}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq -5.5015329556195954 \cdot 10^{-96}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{elif}\;t \leq 1.350961328727771 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 4
Error20.9
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1118295751400003 \cdot 10^{-9}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq -5.5015329556195954 \cdot 10^{-96}:\\ \;\;\;\;y \cdot \frac{z}{a - t}\\ \mathbf{elif}\;t \leq 1.350961328727771 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 5
Error15.0
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1118295751400003 \cdot 10^{-9}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 1.350961328727771 \cdot 10^{-110}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 6
Error20.3
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -4.6 \cdot 10^{-205}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 1.350961328727771 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 7
Error27.0
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8539974233843804 \cdot 10^{-155}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.2440187247609083 \cdot 10^{-209}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error28.6
Cost64
\[x \]

Error

Reproduce

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