?

Average Error: 25.11% → 9.88%
Time: 13.4s
Precision: binary64
Cost: 1096

?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.11%
Target13.08%
Herbie9.88%
\[\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 54.39

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

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

      [Start]54.39

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

      +-rgt-identity [<=]54.39

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

      associate-+l+ [=>]54.39

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

      associate-+r- [<=]46.83

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

      +-rgt-identity [=>]46.83

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

      *-commutative [=>]46.83

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

      associate-/l* [=>]18.57

      \[ x + \left(y - \color{blue}{\frac{y}{\frac{a - t}{z - t}}}\right) \]
    3. Applied egg-rr18.76

      \[\leadsto x + \color{blue}{{\left(\sqrt[3]{y}\right)}^{2} \cdot \left(\sqrt[3]{y} - \sqrt[3]{y} \cdot \frac{z - t}{a - t}\right)} \]
    4. Simplified18.76

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

      [Start]18.76

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

      *-commutative [=>]18.76

      \[ x + {\left(\sqrt[3]{y}\right)}^{2} \cdot \left(\sqrt[3]{y} - \color{blue}{\frac{z - t}{a - t} \cdot \sqrt[3]{y}}\right) \]
    5. Taylor expanded in t around inf 20.44

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

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

      [Start]20.44

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

      pow-base-1 [=>]20.44

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

      associate-/l* [=>]6.01

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

      associate-*r/ [=>]6.01

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

      *-lft-identity [=>]6.01

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

      associate-*r/ [=>]6.01

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

      metadata-eval [<=]6.01

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

      distribute-lft-neg-in [<=]6.01

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

      *-lft-identity [=>]6.01

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

      sub-neg [=>]6.01

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

      mul-1-neg [=>]6.01

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

      distribute-neg-out [=>]6.01

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

      mul-1-neg [=>]6.01

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

      sub-neg [<=]6.01

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

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

    if -6.59999999999999969e206 < t < 3.3999999999999997e76

    1. Initial program 16

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

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

      [Start]16

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

      +-rgt-identity [<=]16

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

      associate-+l+ [=>]16

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

      associate-+r- [<=]13.69

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

      +-rgt-identity [=>]13.69

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

      *-commutative [=>]13.69

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

      associate-/l* [=>]8.33

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

    if 3.3999999999999997e76 < t

    1. Initial program 44.34

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

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

      [Start]44.34

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

      associate--l+ [=>]38.84

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

      sub-neg [=>]38.84

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

      +-commutative [=>]38.84

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

      distribute-neg-frac [=>]38.84

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

      distribute-rgt-neg-in [=>]38.84

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

      associate-*r/ [<=]22.55

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

      mul-1-neg [<=]22.55

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

      associate-*r/ [<=]22.55

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

      fma-def [=>]30.69

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

      \[\leadsto x + \color{blue}{\frac{y \cdot z}{t - a}} \]
    4. Simplified17.12

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

      [Start]26.71

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

      associate-/l* [=>]17.12

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

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

Alternatives

Alternative 1
Error23.24%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -2.8 \cdot 10^{-68} \lor \neg \left(t \leq 6 \cdot 10^{+22}\right):\\ \;\;\;\;x + \left(z - a\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 2
Error23.04%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -2.8 \cdot 10^{-68} \lor \neg \left(t \leq 2.2 \cdot 10^{+18}\right):\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 3
Error14.41%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -1.3 \cdot 10^{+33} \lor \neg \left(a \leq 4.4 \cdot 10^{+167}\right):\\ \;\;\;\;\left(x + y\right) - \frac{z}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \end{array} \]
Alternative 4
Error16.26%
Cost840
\[\begin{array}{l} \mathbf{if}\;a \leq -8 \cdot 10^{+33}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 4.4 \cdot 10^{+167}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 5
Error25.07%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -2.4 \cdot 10^{+66} \lor \neg \left(t \leq 6.2 \cdot 10^{+21}\right):\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 6
Error32.05%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -6.5 \cdot 10^{+206}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{+20}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error44.9%
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))))