?

Average Accuracy: 74.8% → 89.5%
Time: 12.9s
Precision: binary64
Cost: 1097

?

\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.3 \cdot 10^{+59} \lor \neg \left(t \leq 6.5 \cdot 10^{+40}\right):\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y + \frac{t - z}{\frac{a - t}{y}}\right)\\ \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 (or (<= t -2.3e+59) (not (<= t 6.5e+40)))
   (+ x (* (/ y t) (- z a)))
   (+ x (+ y (/ (- t z) (/ (- a t) y))))))
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.3e+59) || !(t <= 6.5e+40)) {
		tmp = x + ((y / t) * (z - a));
	} else {
		tmp = x + (y + ((t - z) / ((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) * 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.3d+59)) .or. (.not. (t <= 6.5d+40))) then
        tmp = x + ((y / t) * (z - a))
    else
        tmp = x + (y + ((t - z) / ((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) * y) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -2.3e+59) || !(t <= 6.5e+40)) {
		tmp = x + ((y / t) * (z - a));
	} else {
		tmp = x + (y + ((t - z) / ((a - t) / y)));
	}
	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.3e+59) or not (t <= 6.5e+40):
		tmp = x + ((y / t) * (z - a))
	else:
		tmp = x + (y + ((t - z) / ((a - t) / y)))
	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.3e+59) || !(t <= 6.5e+40))
		tmp = Float64(x + Float64(Float64(y / t) * Float64(z - a)));
	else
		tmp = Float64(x + Float64(y + Float64(Float64(t - z) / Float64(Float64(a - t) / y))));
	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.3e+59) || ~((t <= 6.5e+40)))
		tmp = x + ((y / t) * (z - a));
	else
		tmp = x + (y + ((t - z) / ((a - t) / y)));
	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[Or[LessEqual[t, -2.3e+59], N[Not[LessEqual[t, 6.5e+40]], $MachinePrecision]], N[(x + N[(N[(y / t), $MachinePrecision] * N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y + N[(N[(t - z), $MachinePrecision] / N[(N[(a - t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -2.3 \cdot 10^{+59} \lor \neg \left(t \leq 6.5 \cdot 10^{+40}\right):\\
\;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(y + \frac{t - z}{\frac{a - t}{y}}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original74.8%
Target86.9%
Herbie89.5%
\[\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 2 regimes
  2. if t < -2.30000000000000008e59 or 6.5000000000000001e40 < t

    1. Initial program 56.6%

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

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

      [Start]56.6

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

      associate--l+ [=>]62.5

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

      sub-neg [=>]62.5

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

      +-commutative [=>]62.5

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

      associate-/l* [=>]79.1

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

      distribute-neg-frac [=>]79.1

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

      associate-/r/ [=>]84.2

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

      fma-def [=>]84.2

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

      sub-neg [=>]84.2

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

      +-commutative [=>]84.2

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

      distribute-neg-in [=>]84.2

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

      unsub-neg [=>]84.2

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

      remove-double-neg [=>]84.2

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

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

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

      [Start]63.2

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

      +-commutative [=>]63.2

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

      associate-+r+ [=>]73.9

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

      distribute-rgt1-in [=>]73.9

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

      metadata-eval [=>]73.9

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

      mul0-lft [=>]73.9

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

      +-lft-identity [=>]73.9

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

      associate-/l* [=>]85.4

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

      associate-/r/ [=>]85.5

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

    if -2.30000000000000008e59 < t < 6.5000000000000001e40

    1. Initial program 88.9%

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

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

      [Start]88.9

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

      associate--l+ [=>]89.9

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

      associate-/l* [=>]92.5

      \[ x + \left(y - \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.5%

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

Alternatives

Alternative 1
Accuracy89.4%
Cost1229
\[\begin{array}{l} \mathbf{if}\;t \leq -1.6 \cdot 10^{+66} \lor \neg \left(t \leq 1.7 \cdot 10^{+146}\right) \land t \leq 7.6 \cdot 10^{+218}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(\frac{t - z}{a - t} + 1\right)\\ \end{array} \]
Alternative 2
Accuracy75.2%
Cost1108
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{t}\\ \mathbf{if}\;a \leq -1.25 \cdot 10^{-15}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq -7.8 \cdot 10^{-47}:\\ \;\;\;\;y \cdot \frac{z}{t - a}\\ \mathbf{elif}\;a \leq -1.65 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -7.5 \cdot 10^{-171}:\\ \;\;\;\;x - y \cdot \frac{a}{t}\\ \mathbf{elif}\;a \leq 3.5 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 3
Accuracy75.1%
Cost1108
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{t}\\ \mathbf{if}\;a \leq -1.25 \cdot 10^{-15}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq -1.7 \cdot 10^{-48}:\\ \;\;\;\;\frac{y \cdot \left(-z\right)}{a - t}\\ \mathbf{elif}\;a \leq -1.6 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.15 \cdot 10^{-172}:\\ \;\;\;\;x - y \cdot \frac{a}{t}\\ \mathbf{elif}\;a \leq 2.05 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 4
Accuracy76.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -3.6 \cdot 10^{-49} \lor \neg \left(t \leq 1.4 \cdot 10^{+38}\right):\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 5
Accuracy81.2%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -3.5 \cdot 10^{-49} \lor \neg \left(t \leq 2.1 \cdot 10^{+35}\right):\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - \frac{z}{\frac{a}{y}}\right)\\ \end{array} \]
Alternative 6
Accuracy68.0%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.25 \cdot 10^{-15}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq -4.4 \cdot 10^{-60}:\\ \;\;\;\;y \cdot \frac{z}{t - a}\\ \mathbf{elif}\;a \leq 2.75 \cdot 10^{-45}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 7
Accuracy76.6%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -2.2 \cdot 10^{+31}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 1.5 \cdot 10^{-45}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 8
Accuracy69.2%
Cost457
\[\begin{array}{l} \mathbf{if}\;a \leq -3.9 \cdot 10^{-102} \lor \neg \left(a \leq 2.1 \cdot 10^{-43}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Accuracy55.5%
Cost64
\[x \]

Error

Reproduce?

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