?

Average Error: 16.7 → 5.7
Time: 13.0s
Precision: binary64
Cost: 1096

?

\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.9 \cdot 10^{+185}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - a}}\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{+183}:\\ \;\;\;\;x + \left(y - \frac{y}{\frac{a - t}{z - t}}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= t -2.9e+185)
   (+ x (/ y (/ t (- z a))))
   (if (<= t 1.25e+183)
     (+ x (- y (/ y (/ (- a t) (- z t)))))
     (+ x (* y (/ (- z a) t))))))
double code(double x, double y, double z, double t, double a) {
	return (x + y) - (((z - t) * y) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (t <= -2.9e+185) {
		tmp = x + (y / (t / (z - a)));
	} else if (t <= 1.25e+183) {
		tmp = x + (y - (y / ((a - t) / (z - t))));
	} else {
		tmp = x + (y * ((z - a) / t));
	}
	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) * y) / (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 <= (-2.9d+185)) then
        tmp = x + (y / (t / (z - a)))
    else if (t <= 1.25d+183) then
        tmp = x + (y - (y / ((a - t) / (z - t))))
    else
        tmp = x + (y * ((z - a) / t))
    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) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (t <= -2.9e+185) {
		tmp = x + (y / (t / (z - a)));
	} else if (t <= 1.25e+183) {
		tmp = x + (y - (y / ((a - t) / (z - t))));
	} else {
		tmp = x + (y * ((z - a) / t));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return (x + y) - (((z - t) * y) / (a - t))
def code(x, y, z, t, a):
	tmp = 0
	if t <= -2.9e+185:
		tmp = x + (y / (t / (z - a)))
	elif t <= 1.25e+183:
		tmp = x + (y - (y / ((a - t) / (z - t))))
	else:
		tmp = x + (y * ((z - a) / t))
	return tmp
function code(x, y, z, t, a)
	return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t)))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if (t <= -2.9e+185)
		tmp = Float64(x + Float64(y / Float64(t / Float64(z - a))));
	elseif (t <= 1.25e+183)
		tmp = Float64(x + Float64(y - Float64(y / Float64(Float64(a - t) / Float64(z - t)))));
	else
		tmp = Float64(x + Float64(y * Float64(Float64(z - a) / t)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = (x + y) - (((z - t) * y) / (a - t));
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if (t <= -2.9e+185)
		tmp = x + (y / (t / (z - a)));
	elseif (t <= 1.25e+183)
		tmp = x + (y - (y / ((a - t) / (z - t))));
	else
		tmp = x + (y * ((z - a) / t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -2.9e+185], N[(x + N[(y / N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.25e+183], N[(x + N[(y - N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(z - a), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{+185}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z - a}}\\

\mathbf{elif}\;t \leq 1.25 \cdot 10^{+183}:\\
\;\;\;\;x + \left(y - \frac{y}{\frac{a - t}{z - t}}\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.7
Target8.4
Herbie5.7
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < 1.4754293444577233 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if t < -2.89999999999999988e185

    1. Initial program 34.4

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
    2. Simplified13.4

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

      [Start]34.4

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

      +-rgt-identity [<=]34.4

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

      associate-+l+ [=>]34.4

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

      associate-+r- [<=]29.8

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

      +-rgt-identity [=>]29.8

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

      *-commutative [=>]29.8

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

      associate-/l* [=>]13.4

      \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right) \]
    3. Taylor expanded in t around inf 14.3

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

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

      [Start]14.3

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

      *-commutative [<=]14.3

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

      distribute-lft-out-- [=>]14.3

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

      distribute-lft-out-- [=>]14.3

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

      associate-*r* [=>]14.3

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

      neg-mul-1 [<=]14.3

      \[ x + \frac{\color{blue}{\left(-y\right)} \cdot \left(a - z\right)}{t} \]
    5. Taylor expanded in y around 0 14.3

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

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

      [Start]14.3

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

      associate-*r/ [=>]14.3

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

      associate-*l/ [<=]14.4

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

      *-commutative [=>]14.4

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

      associate-*l* [=>]4.7

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

      associate-*r/ [=>]4.7

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

      *-commutative [=>]4.7

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

      neg-mul-1 [<=]4.7

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

      neg-sub0 [=>]4.7

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

      sub-neg [=>]4.7

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

      +-commutative [<=]4.7

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

      associate--r+ [=>]4.7

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

      neg-sub0 [<=]4.7

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

      remove-double-neg [=>]4.7

      \[ x + y \cdot \frac{\color{blue}{z} - a}{t} \]
    7. Applied egg-rr4.8

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

    if -2.89999999999999988e185 < t < 1.25000000000000002e183

    1. Initial program 11.7

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
    2. Simplified5.9

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

      [Start]11.7

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

      +-rgt-identity [<=]11.7

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

      associate-+l+ [=>]11.7

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

      associate-+r- [<=]10.3

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

      +-rgt-identity [=>]10.3

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

      *-commutative [=>]10.3

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

      associate-/l* [=>]5.9

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

    if 1.25000000000000002e183 < t

    1. Initial program 34.7

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
    2. Simplified13.8

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

      [Start]34.7

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

      +-rgt-identity [<=]34.7

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

      associate-+l+ [=>]34.7

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

      associate-+r- [<=]30.0

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

      +-rgt-identity [=>]30.0

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

      *-commutative [=>]30.0

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

      associate-/l* [=>]13.8

      \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right) \]
    3. Taylor expanded in t around inf 14.5

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

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

      [Start]14.5

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

      *-commutative [<=]14.5

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

      distribute-lft-out-- [=>]14.5

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

      distribute-lft-out-- [=>]14.5

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

      associate-*r* [=>]14.5

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

      neg-mul-1 [<=]14.5

      \[ x + \frac{\color{blue}{\left(-y\right)} \cdot \left(a - z\right)}{t} \]
    5. Taylor expanded in y around 0 14.5

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

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

      [Start]14.5

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

      associate-*r/ [=>]14.5

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

      associate-*l/ [<=]14.5

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

      *-commutative [=>]14.5

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

      associate-*l* [=>]5.3

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

      associate-*r/ [=>]5.3

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

      *-commutative [=>]5.3

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

      neg-mul-1 [<=]5.3

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

      neg-sub0 [=>]5.3

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

      sub-neg [=>]5.3

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

      +-commutative [<=]5.3

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

      associate--r+ [=>]5.3

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

      neg-sub0 [<=]5.3

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

      remove-double-neg [=>]5.3

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

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

Alternatives

Alternative 1
Error14.1
Cost1104
\[\begin{array}{l} \mathbf{if}\;a \leq -6.6 \cdot 10^{+31}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq -0.115:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{elif}\;a \leq -4.2 \cdot 10^{-19}:\\ \;\;\;\;y - z \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{-37}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 2
Error11.5
Cost1104
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t - a}\\ \mathbf{if}\;a \leq -3 \cdot 10^{+121}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq -6.4 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.02 \cdot 10^{-136}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{elif}\;a \leq 2.7 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 3
Error9.2
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -1.05 \cdot 10^{+120} \lor \neg \left(a \leq 4.7 \cdot 10^{+48}\right):\\ \;\;\;\;\left(x + y\right) - \frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \end{array} \]
Alternative 4
Error10.5
Cost840
\[\begin{array}{l} \mathbf{if}\;a \leq -1.15 \cdot 10^{+120}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 4.4 \cdot 10^{+114}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 5
Error14.8
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.2 \cdot 10^{+31}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{-44}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 6
Error20.4
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq -4.4 \cdot 10^{+30}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 1.45 \cdot 10^{+47}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 7
Error29.0
Cost64
\[x \]

Error

Reproduce?

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

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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