?

Average Error: 7.5 → 1.1
Time: 15.3s
Precision: binary64
Cost: 1353

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{-8} \lor \neg \left(z \leq 7 \cdot 10^{+25}\right):\\ \;\;\;\;\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{x + 1}\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -1.4e-8) (not (<= z 7e+25)))
   (/ (+ x (/ y (- t (/ x z)))) (+ x 1.0))
   (/ (+ x (/ (- (* z y) x) (- (* z t) x))) (+ x 1.0))))
double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.4e-8) || !(z <= 7e+25)) {
		tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
	} else {
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0);
	}
	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) - x) / ((t * z) - x))) / (x + 1.0d0)
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) :: tmp
    if ((z <= (-1.4d-8)) .or. (.not. (z <= 7d+25))) then
        tmp = (x + (y / (t - (x / z)))) / (x + 1.0d0)
    else
        tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.4e-8) || !(z <= 7e+25)) {
		tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
	} else {
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0);
	}
	return tmp;
}
def code(x, y, z, t):
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
def code(x, y, z, t):
	tmp = 0
	if (z <= -1.4e-8) or not (z <= 7e+25):
		tmp = (x + (y / (t - (x / z)))) / (x + 1.0)
	else:
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0))
end
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -1.4e-8) || !(z <= 7e+25))
		tmp = Float64(Float64(x + Float64(y / Float64(t - Float64(x / z)))) / Float64(x + 1.0));
	else
		tmp = Float64(Float64(x + Float64(Float64(Float64(z * y) - x) / Float64(Float64(z * t) - x))) / Float64(x + 1.0));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -1.4e-8) || ~((z <= 7e+25)))
		tmp = (x + (y / (t - (x / z)))) / (x + 1.0);
	else
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (x + 1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.4e-8], N[Not[LessEqual[z, 7e+25]], $MachinePrecision]], N[(N[(x + N[(y / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(N[(z * y), $MachinePrecision] - x), $MachinePrecision] / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-8} \lor \neg \left(z \leq 7 \cdot 10^{+25}\right):\\
\;\;\;\;\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.5
Target0.4
Herbie1.1
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation?

  1. Split input into 2 regimes
  2. if z < -1.4e-8 or 6.99999999999999999e25 < z

    1. Initial program 15.6

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified15.6

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

      [Start]15.6

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

      *-commutative [=>]15.6

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Applied egg-rr15.6

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

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

      [Start]15.6

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

      unpow-1 [=>]15.6

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

      *-commutative [=>]15.6

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

      *-commutative [=>]15.6

      \[ \frac{x + \frac{1}{\frac{t \cdot z - x}{\color{blue}{z \cdot y} - x}}}{x + 1} \]
    5. Taylor expanded in y around inf 16.9

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

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

      [Start]16.9

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

      associate-/l* [=>]6.1

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

      *-commutative [=>]6.1

      \[ \frac{x + \frac{y}{\frac{\color{blue}{z \cdot t} - x}{z}}}{x + 1} \]
    7. Taylor expanded in z around 0 2.1

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

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

      [Start]2.1

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

      mul-1-neg [=>]2.1

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

      distribute-neg-frac [=>]2.1

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

    if -1.4e-8 < z < 6.99999999999999999e25

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{-8} \lor \neg \left(z \leq 7 \cdot 10^{+25}\right):\\ \;\;\;\;\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{x + 1}\\ \end{array} \]

Alternatives

Alternative 1
Error14.3
Cost1296
\[\begin{array}{l} t_1 := \frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{-158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-140}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+175}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{-x}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error5.8
Cost1097
\[\begin{array}{l} \mathbf{if}\;y \leq -1.45 \cdot 10^{-36} \lor \neg \left(y \leq 2.75 \cdot 10^{-100}\right):\\ \;\;\;\;\frac{x + \frac{y}{t - \frac{x}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \end{array} \]
Alternative 3
Error14.5
Cost1033
\[\begin{array}{l} \mathbf{if}\;t \leq -5.6 \cdot 10^{-71} \lor \neg \left(t \leq 2 \cdot 10^{-143}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{-x}{z}}}{x + 1}\\ \end{array} \]
Alternative 4
Error14.7
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+31} \lor \neg \left(x \leq 5 \cdot 10^{-19}\right):\\ \;\;\;\;1 - y \cdot \frac{z}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 5
Error14.9
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -4 \cdot 10^{-75} \lor \neg \left(t \leq 1.75 \cdot 10^{-63}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y}{x \cdot \frac{x}{z}}\\ \end{array} \]
Alternative 6
Error14.7
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-19}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error21.5
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.06 \cdot 10^{-157}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-58}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error21.0
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.62 \cdot 10^{-161}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-61}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error26.8
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error28.4
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023073 
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0))

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