?

Average Error: 16.1 → 6.5
Time: 13.5s
Precision: binary64
Cost: 1160

?

\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -6.6 \cdot 10^{+206}:\\ \;\;\;\;x + y \cdot \left(-\frac{a - z}{t}\right)\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+76}:\\ \;\;\;\;x + y \cdot \left(1 + \left(-\frac{z - t}{a - t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(-\frac{z}{a - t}\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 (<= t -6.6e+206)
   (+ x (* y (- (/ (- a z) t))))
   (if (<= t 3.4e+76)
     (+ x (* y (+ 1.0 (- (/ (- z t) (- a 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 <= -6.6e+206) {
		tmp = x + (y * -((a - z) / t));
	} else if (t <= 3.4e+76) {
		tmp = x + (y * (1.0 + -((z - t) / (a - 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 <= (-6.6d+206)) then
        tmp = x + (y * -((a - z) / t))
    else if (t <= 3.4d+76) then
        tmp = x + (y * (1.0d0 + -((z - t) / (a - 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 <= -6.6e+206) {
		tmp = x + (y * -((a - z) / t));
	} else if (t <= 3.4e+76) {
		tmp = x + (y * (1.0 + -((z - t) / (a - 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 <= -6.6e+206:
		tmp = x + (y * -((a - z) / t))
	elif t <= 3.4e+76:
		tmp = x + (y * (1.0 + -((z - t) / (a - 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 <= -6.6e+206)
		tmp = Float64(x + Float64(y * Float64(-Float64(Float64(a - z) / t))));
	elseif (t <= 3.4e+76)
		tmp = Float64(x + Float64(y * Float64(1.0 + Float64(-Float64(Float64(z - t) / Float64(a - t))))));
	else
		tmp = Float64(x + Float64(y * Float64(-Float64(z / Float64(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 <= -6.6e+206)
		tmp = x + (y * -((a - z) / t));
	elseif (t <= 3.4e+76)
		tmp = x + (y * (1.0 + -((z - t) / (a - 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, -6.6e+206], N[(x + N[(y * (-N[(N[(a - z), $MachinePrecision] / t), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.4e+76], N[(x + N[(y * N[(1.0 + (-N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * (-N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -6.6 \cdot 10^{+206}:\\
\;\;\;\;x + y \cdot \left(-\frac{a - z}{t}\right)\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.1
Target8.4
Herbie6.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 3 regimes
  2. if t < -6.59999999999999969e206

    1. Initial program 34.8

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

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

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

      [Start]11.9

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

      rational_best.json-simplify-1 [=>]11.9

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

      rational_best.json-simplify-2 [=>]11.9

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

      rational_best.json-simplify-12 [=>]11.9

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

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

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

      [Start]3.7

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

      rational_best.json-simplify-2 [=>]3.7

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

      rational_best.json-simplify-12 [=>]3.7

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

    if -6.59999999999999969e206 < t < 3.3999999999999997e76

    1. Initial program 10.2

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

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

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

      [Start]5.6

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

      rational_best.json-simplify-1 [=>]5.6

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

      rational_best.json-simplify-2 [=>]5.6

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

      rational_best.json-simplify-12 [=>]5.6

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

    if 3.3999999999999997e76 < t

    1. Initial program 28.4

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

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

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

      [Start]11.2

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

      rational_best.json-simplify-1 [=>]11.2

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

      rational_best.json-simplify-2 [=>]11.2

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

      rational_best.json-simplify-12 [=>]11.2

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

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

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

      [Start]10.9

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

      rational_best.json-simplify-2 [=>]10.9

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

      rational_best.json-simplify-12 [=>]10.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -6.6 \cdot 10^{+206}:\\ \;\;\;\;x + y \cdot \left(-\frac{a - z}{t}\right)\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{+76}:\\ \;\;\;\;x + y \cdot \left(1 + \left(-\frac{z - t}{a - t}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(-\frac{z}{a - t}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error4.6
Cost4432
\[\begin{array}{l} t_1 := x + y \cdot \left(-\frac{a - z}{t}\right)\\ t_2 := \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-232}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+306}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(-\frac{z}{a - t}\right)\\ \end{array} \]
Alternative 2
Error14.0
Cost904
\[\begin{array}{l} \mathbf{if}\;t \leq -1.12 \cdot 10^{-49}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{elif}\;t \leq 0.125:\\ \;\;\;\;\left(1 - \frac{z}{a}\right) \cdot y + x\\ \mathbf{else}:\\ \;\;\;\;x + \left(-\frac{y \cdot \left(a - z\right)}{t}\right)\\ \end{array} \]
Alternative 3
Error8.4
Cost904
\[\begin{array}{l} t_1 := \left(1 - \frac{z}{a}\right) \cdot y + x\\ \mathbf{if}\;a \leq -6.4 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 6 \cdot 10^{+30}:\\ \;\;\;\;x + y \cdot \left(-\frac{z}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error11.8
Cost904
\[\begin{array}{l} \mathbf{if}\;t \leq -3.5 \cdot 10^{-46}:\\ \;\;\;\;x + y \cdot \left(-\frac{a - z}{t}\right)\\ \mathbf{elif}\;t \leq 0.0055:\\ \;\;\;\;\left(1 - \frac{z}{a}\right) \cdot y + x\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(-\frac{z}{a - t}\right)\\ \end{array} \]
Alternative 5
Error13.1
Cost840
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -3.4 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.42:\\ \;\;\;\;\left(1 - \frac{z}{a}\right) \cdot y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error16.0
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -8.5 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.12 \cdot 10^{+23}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error20.5
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -6.3 \cdot 10^{+206}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+25}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error27.2
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+95}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+128}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 9
Error28.7
Cost64
\[x \]

Error

Reproduce?

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