Average Error: 4.6 → 9.7
Time: 7.6s
Precision: binary64
Cost: 844
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{\left(y + t\right) \cdot x}{z}\\ \mathbf{if}\;z \leq -6.085483990096874 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;\left(y + t\right) \cdot \frac{1}{\frac{z}{x}}\\ \mathbf{elif}\;z \leq 10^{-10}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 t) x) z)))
   (if (<= z -6.085483990096874e+189)
     t_1
     (if (<= z -1.0)
       (* (+ y t) (/ 1.0 (/ z x)))
       (if (<= z 1e-10) (* x (- (/ y z) t)) t_1)))))
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 + t) * x) / z;
	double tmp;
	if (z <= -6.085483990096874e+189) {
		tmp = t_1;
	} else if (z <= -1.0) {
		tmp = (y + t) * (1.0 / (z / x));
	} else if (z <= 1e-10) {
		tmp = x * ((y / z) - t);
	} else {
		tmp = t_1;
	}
	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) :: tmp
    t_1 = ((y + t) * x) / z
    if (z <= (-6.085483990096874d+189)) then
        tmp = t_1
    else if (z <= (-1.0d0)) then
        tmp = (y + t) * (1.0d0 / (z / x))
    else if (z <= 1d-10) then
        tmp = x * ((y / z) - t)
    else
        tmp = t_1
    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 + t) * x) / z;
	double tmp;
	if (z <= -6.085483990096874e+189) {
		tmp = t_1;
	} else if (z <= -1.0) {
		tmp = (y + t) * (1.0 / (z / x));
	} else if (z <= 1e-10) {
		tmp = x * ((y / z) - t);
	} else {
		tmp = t_1;
	}
	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 + t) * x) / z
	tmp = 0
	if z <= -6.085483990096874e+189:
		tmp = t_1
	elif z <= -1.0:
		tmp = (y + t) * (1.0 / (z / x))
	elif z <= 1e-10:
		tmp = x * ((y / z) - t)
	else:
		tmp = t_1
	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(Float64(y + t) * x) / z)
	tmp = 0.0
	if (z <= -6.085483990096874e+189)
		tmp = t_1;
	elseif (z <= -1.0)
		tmp = Float64(Float64(y + t) * Float64(1.0 / Float64(z / x)));
	elseif (z <= 1e-10)
		tmp = Float64(x * Float64(Float64(y / z) - t));
	else
		tmp = t_1;
	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 + t) * x) / z;
	tmp = 0.0;
	if (z <= -6.085483990096874e+189)
		tmp = t_1;
	elseif (z <= -1.0)
		tmp = (y + t) * (1.0 / (z / x));
	elseif (z <= 1e-10)
		tmp = x * ((y / z) - t);
	else
		tmp = t_1;
	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[(N[(y + t), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -6.085483990096874e+189], t$95$1, If[LessEqual[z, -1.0], N[(N[(y + t), $MachinePrecision] * N[(1.0 / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e-10], N[(x * N[(N[(y / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{\left(y + t\right) \cdot x}{z}\\
\mathbf{if}\;z \leq -6.085483990096874 \cdot 10^{+189}:\\
\;\;\;\;t_1\\

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

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.6
Target4.3
Herbie9.7
\[\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 3 regimes
  2. if z < -6.0854839900968742e189 or 1.00000000000000004e-10 < z

    1. Initial program 2.2

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

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

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

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

    if -6.0854839900968742e189 < z < -1

    1. Initial program 1.2

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

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

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

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

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

    if -1 < z < 1.00000000000000004e-10

    1. Initial program 8.5

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} - t\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.7

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

Alternatives

Alternative 1
Error16.6
Cost976
\[\begin{array}{l} t_1 := \frac{\left(y + t\right) \cdot x}{z}\\ \mathbf{if}\;z \leq -8.925841885674815 \cdot 10^{+184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.829140886533226 \cdot 10^{+150}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;z \leq -9.8 \cdot 10^{-15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error10.4
Cost976
\[\begin{array}{l} t_1 := \frac{\left(y + t\right) \cdot x}{z}\\ \mathbf{if}\;z \leq -8.925841885674815 \cdot 10^{+184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.829140886533226 \cdot 10^{+150}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 10^{-10}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error28.1
Cost584
\[\begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -8.347802355557856 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.034239938808351 \cdot 10^{-89}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error28.7
Cost584
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ \mathbf{if}\;y \leq -8.347802355557856 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.668854309629972 \cdot 10^{-105}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error28.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -8.347802355557856 \cdot 10^{-164}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;y \leq 7.668854309629972 \cdot 10^{-105}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \end{array} \]
Alternative 6
Error28.3
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -8.347802355557856 \cdot 10^{-164}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;y \leq 7.668854309629972 \cdot 10^{-105}:\\ \;\;\;\;t \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \end{array} \]
Alternative 7
Error21.4
Cost584
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z}\\ \mathbf{if}\;t \leq -1.6695132529084463 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.523892171090162 \cdot 10^{+83}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error21.4
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.6695132529084463 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;t \leq 8.523892171090162 \cdot 10^{+83}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \end{array} \]
Alternative 9
Error50.6
Cost256
\[t \cdot \left(-x\right) \]

Error

Reproduce

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