Average Error: 3.0 → 0.2
Time: 9.6s
Precision: binary64
Cost: 1736
\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[\frac{x}{y - z \cdot t} \]
\[\begin{array}{l} t_1 := z \cdot t + y\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+272}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+217}:\\ \;\;\;\;\frac{x}{\frac{t_1}{\frac{t_1}{y - z \cdot t}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{z}}{t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ (* z t) y)))
   (if (<= (* z t) -2e+272)
     (/ (/ (- x) t) z)
     (if (<= (* z t) 2e+217)
       (/ x (/ t_1 (/ t_1 (- y (* z t)))))
       (/ (/ (- x) z) t)))))
double code(double x, double y, double z, double t) {
	return x / (y - (z * t));
}
double code(double x, double y, double z, double t) {
	double t_1 = (z * t) + y;
	double tmp;
	if ((z * t) <= -2e+272) {
		tmp = (-x / t) / z;
	} else if ((z * t) <= 2e+217) {
		tmp = x / (t_1 / (t_1 / (y - (z * t))));
	} else {
		tmp = (-x / z) / t;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x / (y - (z * t))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (z * t) + y
    if ((z * t) <= (-2d+272)) then
        tmp = (-x / t) / z
    else if ((z * t) <= 2d+217) then
        tmp = x / (t_1 / (t_1 / (y - (z * t))))
    else
        tmp = (-x / z) / t
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return x / (y - (z * t));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (z * t) + y;
	double tmp;
	if ((z * t) <= -2e+272) {
		tmp = (-x / t) / z;
	} else if ((z * t) <= 2e+217) {
		tmp = x / (t_1 / (t_1 / (y - (z * t))));
	} else {
		tmp = (-x / z) / t;
	}
	return tmp;
}
def code(x, y, z, t):
	return x / (y - (z * t))
def code(x, y, z, t):
	t_1 = (z * t) + y
	tmp = 0
	if (z * t) <= -2e+272:
		tmp = (-x / t) / z
	elif (z * t) <= 2e+217:
		tmp = x / (t_1 / (t_1 / (y - (z * t))))
	else:
		tmp = (-x / z) / t
	return tmp
function code(x, y, z, t)
	return Float64(x / Float64(y - Float64(z * t)))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(z * t) + y)
	tmp = 0.0
	if (Float64(z * t) <= -2e+272)
		tmp = Float64(Float64(Float64(-x) / t) / z);
	elseif (Float64(z * t) <= 2e+217)
		tmp = Float64(x / Float64(t_1 / Float64(t_1 / Float64(y - Float64(z * t)))));
	else
		tmp = Float64(Float64(Float64(-x) / z) / t);
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x / (y - (z * t));
end
function tmp_2 = code(x, y, z, t)
	t_1 = (z * t) + y;
	tmp = 0.0;
	if ((z * t) <= -2e+272)
		tmp = (-x / t) / z;
	elseif ((z * t) <= 2e+217)
		tmp = x / (t_1 / (t_1 / (y - (z * t))));
	else
		tmp = (-x / z) / t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * t), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+272], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+217], N[(x / N[(t$95$1 / N[(t$95$1 / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]]]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
t_1 := z \cdot t + y\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+272}:\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+217}:\\
\;\;\;\;\frac{x}{\frac{t_1}{\frac{t_1}{y - z \cdot t}}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.0
Target1.8
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \mathbf{elif}\;x < 2.1378306434876444 \cdot 10^{+131}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 z t) < -2.0000000000000001e272

    1. Initial program 18.0

      \[\frac{x}{y - z \cdot t} \]
    2. Applied egg-rr18.1

      \[\leadsto \color{blue}{{\left(\frac{y - z \cdot t}{x}\right)}^{-1}} \]
    3. Taylor expanded in y around 0 18.0

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    4. Simplified0.1

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

      [Start]18.0

      \[ -1 \cdot \frac{x}{t \cdot z} \]

      *-commutative [<=]18.0

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

      associate-*r/ [=>]18.0

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

      neg-mul-1 [<=]18.0

      \[ \frac{\color{blue}{-x}}{z \cdot t} \]

      *-commutative [=>]18.0

      \[ \frac{-x}{\color{blue}{t \cdot z}} \]

      associate-/r* [=>]0.1

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

    if -2.0000000000000001e272 < (*.f64 z t) < 1.99999999999999992e217

    1. Initial program 0.1

      \[\frac{x}{y - z \cdot t} \]
    2. Applied egg-rr0.1

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

    if 1.99999999999999992e217 < (*.f64 z t)

    1. Initial program 13.1

      \[\frac{x}{y - z \cdot t} \]
    2. Applied egg-rr13.4

      \[\leadsto \color{blue}{{\left(\frac{y - z \cdot t}{x}\right)}^{-1}} \]
    3. Taylor expanded in y around 0 13.9

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    4. Simplified1.0

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

      [Start]13.9

      \[ -1 \cdot \frac{x}{t \cdot z} \]

      *-commutative [<=]13.9

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

      associate-*r/ [=>]13.9

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

      neg-mul-1 [<=]13.9

      \[ \frac{\color{blue}{-x}}{z \cdot t} \]

      *-commutative [=>]13.9

      \[ \frac{-x}{\color{blue}{t \cdot z}} \]

      associate-/r* [=>]1.0

      \[ \color{blue}{\frac{\frac{-x}{t}}{z}} \]
    5. Taylor expanded in x around 0 13.9

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{t \cdot z}} \]
    6. Simplified1.1

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

      [Start]13.9

      \[ -1 \cdot \frac{x}{t \cdot z} \]

      associate-*r/ [=>]13.9

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

      associate-/l/ [<=]1.1

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

      mul-1-neg [=>]1.1

      \[ \frac{\frac{\color{blue}{-x}}{z}}{t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+272}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+217}:\\ \;\;\;\;\frac{x}{\frac{z \cdot t + y}{\frac{z \cdot t + y}{y - z \cdot t}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{z}}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error0.2
Cost968
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+272}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z}\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+217}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{z}}{t}\\ \end{array} \]
Alternative 2
Error19.5
Cost914
\[\begin{array}{l} \mathbf{if}\;t \leq -4 \cdot 10^{-98} \lor \neg \left(t \leq 2.7 \cdot 10^{-13} \lor \neg \left(t \leq 8000000000\right) \land t \leq 1.1 \cdot 10^{+43}\right):\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
Alternative 3
Error17.3
Cost912
\[\begin{array}{l} t_1 := \frac{\frac{-x}{t}}{z}\\ \mathbf{if}\;t \leq -3.8 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t \leq 1750000000:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{+43}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error17.3
Cost912
\[\begin{array}{l} \mathbf{if}\;t \leq -1.55 \cdot 10^{-98}:\\ \;\;\;\;\frac{\frac{-x}{z}}{t}\\ \mathbf{elif}\;t \leq 4.4 \cdot 10^{-14}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t \leq 480000000:\\ \;\;\;\;\frac{-x}{z \cdot t}\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+43}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z}\\ \end{array} \]
Alternative 5
Error18.1
Cost912
\[\begin{array}{l} \mathbf{if}\;t \leq -1.9 \cdot 10^{-100}:\\ \;\;\;\;\frac{\frac{-x}{z}}{t}\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t \leq 3800000000:\\ \;\;\;\;\frac{-1}{t \cdot \frac{z}{x}}\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{+43}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-x}{t}}{z}\\ \end{array} \]
Alternative 6
Error28.7
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 1.05 \cdot 10^{+155}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z \cdot t}\\ \end{array} \]
Alternative 7
Error28.4
Cost452
\[\begin{array}{l} \mathbf{if}\;t \leq 3.8 \cdot 10^{+153}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{t}}{z}\\ \end{array} \]
Alternative 8
Error30.2
Cost192
\[\frac{x}{y} \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z t)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))

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