Average Error: 7.2 → 14.8
Time: 8.6s
Precision: binary64
Cost: 1096
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.005719935295823 \cdot 10^{+98}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -4.1731864673707804 \cdot 10^{-13}:\\ \;\;\;\;\frac{x + \left(1 - \frac{y \cdot z}{x}\right)}{x + 1}\\ \mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;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 (<= x -1.005719935295823e+98)
   1.0
   (if (<= x -4.1731864673707804e-13)
     (/ (+ x (- 1.0 (/ (* y z) x))) (+ x 1.0))
     (if (<= x 1.0888255954359132e-32) (/ (+ x (/ y t)) (+ x 1.0)) 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 (x <= -1.005719935295823e+98) {
		tmp = 1.0;
	} else if (x <= -4.1731864673707804e-13) {
		tmp = (x + (1.0 - ((y * z) / x))) / (x + 1.0);
	} else if (x <= 1.0888255954359132e-32) {
		tmp = (x + (y / t)) / (x + 1.0);
	} else {
		tmp = 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 (x <= (-1.005719935295823d+98)) then
        tmp = 1.0d0
    else if (x <= (-4.1731864673707804d-13)) then
        tmp = (x + (1.0d0 - ((y * z) / x))) / (x + 1.0d0)
    else if (x <= 1.0888255954359132d-32) then
        tmp = (x + (y / t)) / (x + 1.0d0)
    else
        tmp = 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 (x <= -1.005719935295823e+98) {
		tmp = 1.0;
	} else if (x <= -4.1731864673707804e-13) {
		tmp = (x + (1.0 - ((y * z) / x))) / (x + 1.0);
	} else if (x <= 1.0888255954359132e-32) {
		tmp = (x + (y / t)) / (x + 1.0);
	} else {
		tmp = 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 x <= -1.005719935295823e+98:
		tmp = 1.0
	elif x <= -4.1731864673707804e-13:
		tmp = (x + (1.0 - ((y * z) / x))) / (x + 1.0)
	elif x <= 1.0888255954359132e-32:
		tmp = (x + (y / t)) / (x + 1.0)
	else:
		tmp = 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 (x <= -1.005719935295823e+98)
		tmp = 1.0;
	elseif (x <= -4.1731864673707804e-13)
		tmp = Float64(Float64(x + Float64(1.0 - Float64(Float64(y * z) / x))) / Float64(x + 1.0));
	elseif (x <= 1.0888255954359132e-32)
		tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0));
	else
		tmp = 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 (x <= -1.005719935295823e+98)
		tmp = 1.0;
	elseif (x <= -4.1731864673707804e-13)
		tmp = (x + (1.0 - ((y * z) / x))) / (x + 1.0);
	elseif (x <= 1.0888255954359132e-32)
		tmp = (x + (y / t)) / (x + 1.0);
	else
		tmp = 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[LessEqual[x, -1.005719935295823e+98], 1.0, If[LessEqual[x, -4.1731864673707804e-13], N[(N[(x + N[(1.0 - N[(N[(y * z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0888255954359132e-32], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 1.0]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;x \leq -1.005719935295823 \cdot 10^{+98}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -4.1731864673707804 \cdot 10^{-13}:\\
\;\;\;\;\frac{x + \left(1 - \frac{y \cdot z}{x}\right)}{x + 1}\\

\mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.2
Target0.3
Herbie14.8
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.00571993529582299e98 or 1.08882559543591e-32 < x

    1. Initial program 7.5

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

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

      \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
    4. Simplified7.6

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    5. Taylor expanded in x around inf 9.0

      \[\leadsto \color{blue}{1 - \frac{1}{x}} \]
    6. Taylor expanded in x around inf 7.3

      \[\leadsto \color{blue}{1} \]

    if -1.00571993529582299e98 < x < -4.1731864673707804e-13

    1. Initial program 7.0

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

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

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

      \[\leadsto \color{blue}{\frac{x + \left(1 - \frac{y}{x} \cdot z\right)}{x + 1}} \]
    5. Taylor expanded in y around 0 18.1

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

    if -4.1731864673707804e-13 < x < 1.08882559543591e-32

    1. Initial program 7.0

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{y}{t} + x}{1 + x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification14.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.005719935295823 \cdot 10^{+98}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -4.1731864673707804 \cdot 10^{-13}:\\ \;\;\;\;\frac{x + \left(1 - \frac{y \cdot z}{x}\right)}{x + 1}\\ \mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternatives

Alternative 1
Error14.7
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1762016.691851486:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error19.4
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1979952720222601 \cdot 10^{-19}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\ \;\;\;\;\frac{y - \frac{x}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error20.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.1731864673707804 \cdot 10^{-13}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error21.0
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1979952720222601 \cdot 10^{-19}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.0888255954359132 \cdot 10^{-32}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error26.3
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.1731864673707804 \cdot 10^{-13}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.2465588714838008 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error55.3
Cost64
\[x \]

Error

Reproduce

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