Average Error: 4.5 → 1.0
Time: 9.9s
Precision: binary64
Cost: 3408
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ t_2 := t_1 \cdot x\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+281}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;t_1 \leq -4 \cdot 10^{-212}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y + t}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+226}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}} - t \cdot \left(x + z \cdot x\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))) (t_2 (* t_1 x)))
   (if (<= t_1 -1e+281)
     (/ 1.0 (/ z (* y x)))
     (if (<= t_1 -4e-212)
       t_2
       (if (<= t_1 0.0)
         (/ 1.0 (/ (/ z x) (+ y t)))
         (if (<= t_1 2e+226) t_2 (- (/ y (/ z x)) (* t (+ x (* z x))))))))))
double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
double code(double x, double y, double z, double t) {
	double t_1 = (y / z) - (t / (1.0 - z));
	double t_2 = t_1 * x;
	double tmp;
	if (t_1 <= -1e+281) {
		tmp = 1.0 / (z / (y * x));
	} else if (t_1 <= -4e-212) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = 1.0 / ((z / x) / (y + t));
	} else if (t_1 <= 2e+226) {
		tmp = t_2;
	} else {
		tmp = (y / (z / x)) - (t * (x + (z * 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) - (t / (1.0d0 - z)))
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) :: t_2
    real(8) :: tmp
    t_1 = (y / z) - (t / (1.0d0 - z))
    t_2 = t_1 * x
    if (t_1 <= (-1d+281)) then
        tmp = 1.0d0 / (z / (y * x))
    else if (t_1 <= (-4d-212)) then
        tmp = t_2
    else if (t_1 <= 0.0d0) then
        tmp = 1.0d0 / ((z / x) / (y + t))
    else if (t_1 <= 2d+226) then
        tmp = t_2
    else
        tmp = (y / (z / x)) - (t * (x + (z * x)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (y / z) - (t / (1.0 - z));
	double t_2 = t_1 * x;
	double tmp;
	if (t_1 <= -1e+281) {
		tmp = 1.0 / (z / (y * x));
	} else if (t_1 <= -4e-212) {
		tmp = t_2;
	} else if (t_1 <= 0.0) {
		tmp = 1.0 / ((z / x) / (y + t));
	} else if (t_1 <= 2e+226) {
		tmp = t_2;
	} else {
		tmp = (y / (z / x)) - (t * (x + (z * x)));
	}
	return tmp;
}
def code(x, y, z, t):
	return x * ((y / z) - (t / (1.0 - z)))
def code(x, y, z, t):
	t_1 = (y / z) - (t / (1.0 - z))
	t_2 = t_1 * x
	tmp = 0
	if t_1 <= -1e+281:
		tmp = 1.0 / (z / (y * x))
	elif t_1 <= -4e-212:
		tmp = t_2
	elif t_1 <= 0.0:
		tmp = 1.0 / ((z / x) / (y + t))
	elif t_1 <= 2e+226:
		tmp = t_2
	else:
		tmp = (y / (z / x)) - (t * (x + (z * x)))
	return tmp
function code(x, y, z, t)
	return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))
	t_2 = Float64(t_1 * x)
	tmp = 0.0
	if (t_1 <= -1e+281)
		tmp = Float64(1.0 / Float64(z / Float64(y * x)));
	elseif (t_1 <= -4e-212)
		tmp = t_2;
	elseif (t_1 <= 0.0)
		tmp = Float64(1.0 / Float64(Float64(z / x) / Float64(y + t)));
	elseif (t_1 <= 2e+226)
		tmp = t_2;
	else
		tmp = Float64(Float64(y / Float64(z / x)) - Float64(t * Float64(x + Float64(z * x))));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x * ((y / z) - (t / (1.0 - z)));
end
function tmp_2 = code(x, y, z, t)
	t_1 = (y / z) - (t / (1.0 - z));
	t_2 = t_1 * x;
	tmp = 0.0;
	if (t_1 <= -1e+281)
		tmp = 1.0 / (z / (y * x));
	elseif (t_1 <= -4e-212)
		tmp = t_2;
	elseif (t_1 <= 0.0)
		tmp = 1.0 / ((z / x) / (y + t));
	elseif (t_1 <= 2e+226)
		tmp = t_2;
	else
		tmp = (y / (z / x)) - (t * (x + (z * x)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * x), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+281], N[(1.0 / N[(z / N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -4e-212], t$95$2, If[LessEqual[t$95$1, 0.0], N[(1.0 / N[(N[(z / x), $MachinePrecision] / N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+226], t$95$2, N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - N[(t * N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
t_2 := t_1 \cdot x\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\

\mathbf{elif}\;t_1 \leq -4 \cdot 10^{-212}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y + t}}\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+226}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}} - t \cdot \left(x + z \cdot x\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.5
Target4.2
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) < -7.623226303312042 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) < 1.4133944927702302 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \end{array} \]

Derivation

  1. Split input into 4 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -1e281

    1. Initial program 42.7

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Taylor expanded in y around inf 9.6

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Simplified52.0

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x} \]
      Proof
      (*.f64 (/.f64 y z) x): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y x) z)): 1 points increase in error, 1 points decrease in error
    4. Applied egg-rr9.7

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{y \cdot x}}} \]

    if -1e281 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -3.99999999999999982e-212 or -0.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 1.99999999999999992e226

    1. Initial program 0.3

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

    if -3.99999999999999982e-212 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -0.0

    1. Initial program 12.4

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Taylor expanded in z around inf 0.9

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y - \left(-t\right)}}} \]
      Proof
      (*.f64 (/.f64 y z) x): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y x) z)): 1 points increase in error, 1 points decrease in error
    4. Applied egg-rr0.8

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + t\right)} \]
    5. Applied egg-rr1.4

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

    if 1.99999999999999992e226 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 22.6

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Taylor expanded in z around 0 3.5

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

      \[\leadsto \color{blue}{\left(-t\right) \cdot \left(x + z \cdot x\right) + \frac{y}{\frac{z}{x}}} \]
      Proof
      (*.f64 (/.f64 y z) x): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y x) z)): 1 points increase in error, 1 points decrease in error
  3. Recombined 4 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -1 \cdot 10^{+281}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -4 \cdot 10^{-212}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y + t}}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 2 \cdot 10^{+226}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}} - t \cdot \left(x + z \cdot x\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.9
Cost3280
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ t_2 := t_1 \cdot x\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+281}:\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{elif}\;t_1 \leq -4 \cdot 10^{-212}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y + t}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+295}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]
Alternative 2
Error20.3
Cost1108
\[\begin{array}{l} t_1 := \frac{y}{z} \cdot x\\ t_2 := \frac{x}{\frac{z}{t}}\\ \mathbf{if}\;z \leq -1.12 \cdot 10^{+269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+177}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1350000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -0.26:\\ \;\;\;\;x \cdot \frac{t}{z + -1}\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+92}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error27.0
Cost981
\[\begin{array}{l} t_1 := \frac{y}{z} \cdot x\\ \mathbf{if}\;z \leq -3.4 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-150}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+92}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+137} \lor \neg \left(z \leq 6.8 \cdot 10^{+272}\right):\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error20.3
Cost976
\[\begin{array}{l} t_1 := \frac{y}{z} \cdot x\\ t_2 := \frac{x}{\frac{z}{t}}\\ \mathbf{if}\;z \leq -4.3 \cdot 10^{+262}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{+178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.72 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+92}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error5.2
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;x \cdot \frac{y + t}{z}\\ \mathbf{elif}\;z \leq 3.95:\\ \;\;\;\;\frac{y}{z} \cdot x - t \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + t}}\\ \end{array} \]
Alternative 6
Error27.4
Cost716
\[\begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{-193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-181}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{+166}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 7
Error24.3
Cost716
\[\begin{array}{l} \mathbf{if}\;t \leq -4.7 \cdot 10^{+208}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{-296}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;t \leq 4.4 \cdot 10^{+125}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \end{array} \]
Alternative 8
Error9.2
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.11 \lor \neg \left(z \leq 3.95\right):\\ \;\;\;\;\left(y + t\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \end{array} \]
Alternative 9
Error5.3
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.9 \lor \neg \left(z \leq 3.95\right):\\ \;\;\;\;\frac{x}{\frac{z}{y + t}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \end{array} \]
Alternative 10
Error5.2
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;x \cdot \frac{y + t}{z}\\ \mathbf{elif}\;z \leq 3.95:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + t}}\\ \end{array} \]
Alternative 11
Error27.3
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-193} \lor \neg \left(y \leq 2.8 \cdot 10^{-181}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \end{array} \]
Alternative 12
Error23.7
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.85 \cdot 10^{+177}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+123}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \end{array} \]
Alternative 13
Error50.6
Cost256
\[t \cdot \left(-x\right) \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

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