?

Average Error: 7.4 → 3.2
Time: 27.0s
Precision: binary64
Cost: 2244

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\ \mathbf{if}\;t_1 \leq 10^{+295}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{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
 (let* ((t_1 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
   (if (<= t_1 1e+295) t_1 (/ (+ (/ y t) x) (+ 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 t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
	double tmp;
	if (t_1 <= 1e+295) {
		tmp = t_1;
	} else {
		tmp = ((y / t) + x) / (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) :: t_1
    real(8) :: tmp
    t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
    if (t_1 <= 1d+295) then
        tmp = t_1
    else
        tmp = ((y / t) + x) / (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 t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
	double tmp;
	if (t_1 <= 1e+295) {
		tmp = t_1;
	} else {
		tmp = ((y / t) + x) / (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):
	t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
	tmp = 0
	if t_1 <= 1e+295:
		tmp = t_1
	else:
		tmp = ((y / t) + x) / (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)
	t_1 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0))
	tmp = 0.0
	if (t_1 <= 1e+295)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(y / t) + x) / 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)
	t_1 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
	tmp = 0.0;
	if (t_1 <= 1e+295)
		tmp = t_1;
	else
		tmp = ((y / t) + x) / (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_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, 1e+295], t$95$1, N[(N[(N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t_1 \leq 10^{+295}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.4
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 2 regimes
  2. if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 9.9999999999999998e294

    1. Initial program 2.8

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

    if 9.9999999999999998e294 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 63.2

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

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

      [Start]63.2

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

      rational.json-simplify-2 [=>]63.2

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

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

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

Alternatives

Alternative 1
Error15.1
Cost1036
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{+19}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-27}:\\ \;\;\;\;y \cdot \frac{-z}{x - z \cdot t}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error14.9
Cost972
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{+21}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-63}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-22}:\\ \;\;\;\;1 + z \cdot \left(y - \frac{y}{x}\right)\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error10.9
Cost968
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{if}\;t \leq -9.2 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{-26}:\\ \;\;\;\;1 - y \cdot \frac{z}{x \cdot \left(x + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error20.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-33}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-64}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error20.6
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-69}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-64}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error27.1
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{-6}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-74}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error28.6
Cost64
\[1 \]

Error

Reproduce?

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