Average Error: 2.8 → 1.0
Time: 7.6s
Precision: binary64
Cost: 968
\[\frac{x}{y - z \cdot t} \]
\[\begin{array}{l} t_1 := \frac{\frac{-x}{z}}{t}\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+304}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (/ (- x) z) t)))
   (if (<= (* z t) -2e+304)
     t_1
     (if (<= (* z t) 2e+129) (/ x (- y (* z t))) t_1))))
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 = (-x / z) / t;
	double tmp;
	if ((z * t) <= -2e+304) {
		tmp = t_1;
	} else if ((z * t) <= 2e+129) {
		tmp = x / (y - (z * t));
	} else {
		tmp = t_1;
	}
	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 = (-x / z) / t
    if ((z * t) <= (-2d+304)) then
        tmp = t_1
    else if ((z * t) <= 2d+129) then
        tmp = x / (y - (z * t))
    else
        tmp = t_1
    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 = (-x / z) / t;
	double tmp;
	if ((z * t) <= -2e+304) {
		tmp = t_1;
	} else if ((z * t) <= 2e+129) {
		tmp = x / (y - (z * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x / (y - (z * t))
def code(x, y, z, t):
	t_1 = (-x / z) / t
	tmp = 0
	if (z * t) <= -2e+304:
		tmp = t_1
	elif (z * t) <= 2e+129:
		tmp = x / (y - (z * t))
	else:
		tmp = t_1
	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(Float64(-x) / z) / t)
	tmp = 0.0
	if (Float64(z * t) <= -2e+304)
		tmp = t_1;
	elseif (Float64(z * t) <= 2e+129)
		tmp = Float64(x / Float64(y - Float64(z * t)));
	else
		tmp = t_1;
	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 = (-x / z) / t;
	tmp = 0.0;
	if ((z * t) <= -2e+304)
		tmp = t_1;
	elseif ((z * t) <= 2e+129)
		tmp = x / (y - (z * t));
	else
		tmp = t_1;
	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[((-x) / z), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e+304], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 2e+129], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
t_1 := \frac{\frac{-x}{z}}{t}\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+304}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.8
Target1.7
Herbie1.0
\[\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 2 regimes
  2. if (*.f64 z t) < -1.9999999999999999e304 or 2e129 < (*.f64 z t)

    1. Initial program 11.4

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

      \[\leadsto \color{blue}{\frac{1}{y - z \cdot t} \cdot x} \]
    3. Applied egg-rr11.7

      \[\leadsto \color{blue}{\frac{1}{\frac{y - z \cdot t}{x}}} \]
    4. Taylor expanded in y around 0 14.7

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

      \[\leadsto \color{blue}{\frac{\frac{-x}{z}}{t}} \]
      Proof
      (/.f64 (/.f64 (neg.f64 x) z) t): 0 points increase in error, 0 points decrease in error
      (/.f64 (/.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 x)) z) t): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-/l/_binary64 (/.f64 (*.f64 -1 x) (*.f64 t z))): 54 points increase in error, 34 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 -1 (/.f64 x (*.f64 t z)))): 0 points increase in error, 0 points decrease in error

    if -1.9999999999999999e304 < (*.f64 z t) < 2e129

    1. Initial program 0.1

      \[\frac{x}{y - z \cdot t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

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

Alternatives

Alternative 1
Error21.4
Cost912
\[\begin{array}{l} t_1 := \frac{\frac{-x}{z}}{t}\\ \mathbf{if}\;t \leq -1.2649896080357107 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.683584477241817 \cdot 10^{+92}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t \leq 9.72687571907555 \cdot 10^{+140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.234516731215059 \cdot 10^{+156}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error19.9
Cost648
\[\begin{array}{l} t_1 := \frac{\frac{-x}{t}}{z}\\ \mathbf{if}\;t \leq -1.2649896080357107 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.103813028568 \cdot 10^{+54}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error30.0
Cost192
\[\frac{x}{y} \]

Error

Reproduce

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