Average Error: 7.1 → 3.2
Time: 18.5s
Precision: binary64
Cost: 1476
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -2.35 \cdot 10^{+124}:\\ \;\;\;\;\frac{\frac{y}{1 + x} - \frac{x}{z \cdot \left(1 + x\right)}}{t} + \frac{x}{1 + x}\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+73}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \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 (<= z -2.35e+124)
   (+ (/ (- (/ y (+ 1.0 x)) (/ x (* z (+ 1.0 x)))) t) (/ x (+ 1.0 x)))
   (if (<= z 1.05e+73)
     (/ (+ x (/ (- (* z y) x) (- (* z t) x))) (+ 1.0 x))
     (/ (+ x (/ y t)) (+ 1.0 x)))))
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 <= -2.35e+124) {
		tmp = (((y / (1.0 + x)) - (x / (z * (1.0 + x)))) / t) + (x / (1.0 + x));
	} else if (z <= 1.05e+73) {
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (1.0 + x);
	} else {
		tmp = (x + (y / t)) / (1.0 + x);
	}
	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 <= (-2.35d+124)) then
        tmp = (((y / (1.0d0 + x)) - (x / (z * (1.0d0 + x)))) / t) + (x / (1.0d0 + x))
    else if (z <= 1.05d+73) then
        tmp = (x + (((z * y) - x) / ((z * t) - x))) / (1.0d0 + x)
    else
        tmp = (x + (y / t)) / (1.0d0 + x)
    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 <= -2.35e+124) {
		tmp = (((y / (1.0 + x)) - (x / (z * (1.0 + x)))) / t) + (x / (1.0 + x));
	} else if (z <= 1.05e+73) {
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (1.0 + x);
	} else {
		tmp = (x + (y / t)) / (1.0 + x);
	}
	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 <= -2.35e+124:
		tmp = (((y / (1.0 + x)) - (x / (z * (1.0 + x)))) / t) + (x / (1.0 + x))
	elif z <= 1.05e+73:
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (1.0 + x)
	else:
		tmp = (x + (y / t)) / (1.0 + x)
	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 <= -2.35e+124)
		tmp = Float64(Float64(Float64(Float64(y / Float64(1.0 + x)) - Float64(x / Float64(z * Float64(1.0 + x)))) / t) + Float64(x / Float64(1.0 + x)));
	elseif (z <= 1.05e+73)
		tmp = Float64(Float64(x + Float64(Float64(Float64(z * y) - x) / Float64(Float64(z * t) - x))) / Float64(1.0 + x));
	else
		tmp = Float64(Float64(x + Float64(y / t)) / Float64(1.0 + x));
	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 <= -2.35e+124)
		tmp = (((y / (1.0 + x)) - (x / (z * (1.0 + x)))) / t) + (x / (1.0 + x));
	elseif (z <= 1.05e+73)
		tmp = (x + (((z * y) - x) / ((z * t) - x))) / (1.0 + x);
	else
		tmp = (x + (y / t)) / (1.0 + x);
	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[z, -2.35e+124], N[(N[(N[(N[(y / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] - N[(x / N[(z * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.05e+73], N[(N[(x + N[(N[(N[(z * y), $MachinePrecision] - x), $MachinePrecision] / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;z \leq -2.35 \cdot 10^{+124}:\\
\;\;\;\;\frac{\frac{y}{1 + x} - \frac{x}{z \cdot \left(1 + x\right)}}{t} + \frac{x}{1 + x}\\

\mathbf{elif}\;z \leq 1.05 \cdot 10^{+73}:\\
\;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target0.3
Herbie3.2
\[\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 z < -2.34999999999999995e124

    1. Initial program 21.5

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

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

      [Start]21.5

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

      *-commutative [=>]21.5

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

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

    if -2.34999999999999995e124 < z < 1.0500000000000001e73

    1. Initial program 1.2

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

    if 1.0500000000000001e73 < z

    1. Initial program 17.4

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

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

      [Start]17.4

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

      *-commutative [=>]17.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.35 \cdot 10^{+124}:\\ \;\;\;\;\frac{\frac{y}{1 + x} - \frac{x}{z \cdot \left(1 + x\right)}}{t} + \frac{x}{1 + x}\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+73}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \end{array} \]

Alternatives

Alternative 1
Error2.0
Cost3400
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x + \frac{z \cdot y - x}{t_1}}{1 + x}\\ \mathbf{if}\;t_2 \leq -2000000000:\\ \;\;\;\;\frac{y}{\frac{t_1 \cdot \left(1 + x\right)}{z}}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+284}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \end{array} \]
Alternative 2
Error3.3
Cost1604
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+147}:\\ \;\;\;\;\left(\frac{x}{1 + x} + \frac{y}{t \cdot \left(1 + x\right)}\right) - \frac{x}{\left(z \cdot t\right) \cdot \left(1 + x\right)}\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{+70}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{z \cdot t - x}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \end{array} \]
Alternative 3
Error13.9
Cost1489
\[\begin{array}{l} t_1 := z \cdot y - x\\ t_2 := \frac{x + \frac{y}{t}}{1 + x}\\ \mathbf{if}\;z \leq -4 \cdot 10^{-39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{-192}:\\ \;\;\;\;\frac{x + \frac{t_1}{-x}}{1 + x}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-112} \lor \neg \left(z \leq 9.5 \cdot 10^{-53}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + t_1 \cdot \frac{-1}{x}}{1 + x}\\ \end{array} \]
Alternative 4
Error13.7
Cost1426
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{-39} \lor \neg \left(z \leq 4.6 \cdot 10^{-192} \lor \neg \left(z \leq 5.2 \cdot 10^{-150}\right) \land z \leq 8.5 \cdot 10^{-42}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{-x}}{1 + x}\\ \end{array} \]
Alternative 5
Error13.5
Cost1362
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{-39} \lor \neg \left(z \leq 3.4 \cdot 10^{-192}\right) \land \left(z \leq 3 \cdot 10^{-151} \lor \neg \left(z \leq 1.3 \cdot 10^{-52}\right)\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{1 + x}\\ \end{array} \]
Alternative 6
Error13.7
Cost1361
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{1 + x}\\ \mathbf{if}\;z \leq -1.85 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-192}:\\ \;\;\;\;\frac{x + \frac{z \cdot y - x}{-x}}{1 + x}\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-149} \lor \neg \left(z \leq 3.25 \cdot 10^{-43}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + x\right) - \frac{z \cdot y}{x}}{1 + x}\\ \end{array} \]
Alternative 7
Error12.6
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -6000:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 21000000000000:\\ \;\;\;\;\frac{x + \frac{y - \frac{x}{z}}{t}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error16.1
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{-39} \lor \neg \left(z \leq 1.15 \cdot 10^{-192}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error30.6
Cost592
\[\begin{array}{l} \mathbf{if}\;t \leq -3.3 \cdot 10^{+236}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq -7 \cdot 10^{+153}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{+217}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+294}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error20.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.15 \cdot 10^{-50}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-120}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error20.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.7 \cdot 10^{-82}:\\ \;\;\;\;\frac{x}{1 + x}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-121}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 12
Error28.8
Cost64
\[1 \]

Error

Reproduce

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