?

Average Error: 4.9 → 0.5
Time: 13.3s
Precision: binary64
Cost: 3280

?

\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ t_2 := \frac{y}{z} - \frac{t}{1 - z}\\ t_3 := x \cdot t_2\\ t_4 := \left(-t \cdot x\right) + t_1\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{+264}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_2 \leq -1 \cdot 10^{-175}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-300}:\\ \;\;\;\;\left(-\left(-\frac{t \cdot x}{z}\right)\right) + t_1\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+262}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \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 (/ x z)))
        (t_2 (- (/ y z) (/ t (- 1.0 z))))
        (t_3 (* x t_2))
        (t_4 (+ (- (* t x)) t_1)))
   (if (<= t_2 -2e+264)
     t_4
     (if (<= t_2 -1e-175)
       t_3
       (if (<= t_2 2e-300)
         (+ (- (- (/ (* t x) z))) t_1)
         (if (<= t_2 5e+262) t_3 t_4))))))
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 * (x / z);
	double t_2 = (y / z) - (t / (1.0 - z));
	double t_3 = x * t_2;
	double t_4 = -(t * x) + t_1;
	double tmp;
	if (t_2 <= -2e+264) {
		tmp = t_4;
	} else if (t_2 <= -1e-175) {
		tmp = t_3;
	} else if (t_2 <= 2e-300) {
		tmp = -(-((t * x) / z)) + t_1;
	} else if (t_2 <= 5e+262) {
		tmp = t_3;
	} else {
		tmp = t_4;
	}
	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) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_1 = y * (x / z)
    t_2 = (y / z) - (t / (1.0d0 - z))
    t_3 = x * t_2
    t_4 = -(t * x) + t_1
    if (t_2 <= (-2d+264)) then
        tmp = t_4
    else if (t_2 <= (-1d-175)) then
        tmp = t_3
    else if (t_2 <= 2d-300) then
        tmp = -(-((t * x) / z)) + t_1
    else if (t_2 <= 5d+262) then
        tmp = t_3
    else
        tmp = t_4
    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 * (x / z);
	double t_2 = (y / z) - (t / (1.0 - z));
	double t_3 = x * t_2;
	double t_4 = -(t * x) + t_1;
	double tmp;
	if (t_2 <= -2e+264) {
		tmp = t_4;
	} else if (t_2 <= -1e-175) {
		tmp = t_3;
	} else if (t_2 <= 2e-300) {
		tmp = -(-((t * x) / z)) + t_1;
	} else if (t_2 <= 5e+262) {
		tmp = t_3;
	} else {
		tmp = t_4;
	}
	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 * (x / z)
	t_2 = (y / z) - (t / (1.0 - z))
	t_3 = x * t_2
	t_4 = -(t * x) + t_1
	tmp = 0
	if t_2 <= -2e+264:
		tmp = t_4
	elif t_2 <= -1e-175:
		tmp = t_3
	elif t_2 <= 2e-300:
		tmp = -(-((t * x) / z)) + t_1
	elif t_2 <= 5e+262:
		tmp = t_3
	else:
		tmp = t_4
	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(y * Float64(x / z))
	t_2 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))
	t_3 = Float64(x * t_2)
	t_4 = Float64(Float64(-Float64(t * x)) + t_1)
	tmp = 0.0
	if (t_2 <= -2e+264)
		tmp = t_4;
	elseif (t_2 <= -1e-175)
		tmp = t_3;
	elseif (t_2 <= 2e-300)
		tmp = Float64(Float64(-Float64(-Float64(Float64(t * x) / z))) + t_1);
	elseif (t_2 <= 5e+262)
		tmp = t_3;
	else
		tmp = t_4;
	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 * (x / z);
	t_2 = (y / z) - (t / (1.0 - z));
	t_3 = x * t_2;
	t_4 = -(t * x) + t_1;
	tmp = 0.0;
	if (t_2 <= -2e+264)
		tmp = t_4;
	elseif (t_2 <= -1e-175)
		tmp = t_3;
	elseif (t_2 <= 2e-300)
		tmp = -(-((t * x) / z)) + t_1;
	elseif (t_2 <= 5e+262)
		tmp = t_3;
	else
		tmp = t_4;
	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[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[((-N[(t * x), $MachinePrecision]) + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+264], t$95$4, If[LessEqual[t$95$2, -1e-175], t$95$3, If[LessEqual[t$95$2, 2e-300], N[((-(-N[(N[(t * x), $MachinePrecision] / z), $MachinePrecision])) + t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 5e+262], t$95$3, t$95$4]]]]]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := y \cdot \frac{x}{z}\\
t_2 := \frac{y}{z} - \frac{t}{1 - z}\\
t_3 := x \cdot t_2\\
t_4 := \left(-t \cdot x\right) + t_1\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+264}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;t_2 \leq -1 \cdot 10^{-175}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{-300}:\\
\;\;\;\;\left(-\left(-\frac{t \cdot x}{z}\right)\right) + t_1\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;t_4\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.9
Target4.5
Herbie0.5
\[\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 (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -2.00000000000000009e264 or 5.00000000000000008e262 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 34.9

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied egg-rr64.0

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

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

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

      [Start]0.6

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

      rational_best.json-simplify-1 [=>]0.6

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

      rational_best.json-simplify-2 [=>]0.6

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

      rational_best.json-simplify-12 [=>]0.6

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

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

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

    if -2.00000000000000009e264 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -1e-175 or 2.00000000000000005e-300 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 5.00000000000000008e262

    1. Initial program 0.2

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

    if -1e-175 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 2.00000000000000005e-300

    1. Initial program 11.0

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied egg-rr51.6

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

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

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

      [Start]0.5

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

      rational_best.json-simplify-1 [=>]0.5

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

      rational_best.json-simplify-2 [=>]0.5

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

      rational_best.json-simplify-12 [=>]0.5

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

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

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

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

      [Start]1.3

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

      rational_best.json-simplify-2 [=>]1.3

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

      rational_best.json-simplify-12 [=>]1.3

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

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

Alternatives

Alternative 1
Error0.4
Cost3280
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ t_2 := x \cdot t_1\\ t_3 := \left(-t \cdot x\right) + y \cdot \frac{x}{z}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+264}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{-198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-300}:\\ \;\;\;\;\frac{x \cdot \left(y + t\right)}{z}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+262}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error4.5
Cost904
\[\begin{array}{l} t_1 := x \cdot \frac{y + t}{z}\\ \mathbf{if}\;z \leq -29000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-5}:\\ \;\;\;\;\left(-t \cdot x\right) + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error25.0
Cost848
\[\begin{array}{l} t_1 := \frac{t \cdot x}{z}\\ \mathbf{if}\;t \leq -3.2 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+121}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;t \leq 8 \cdot 10^{+232}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{+301}:\\ \;\;\;\;x \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error26.7
Cost848
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := \frac{t \cdot x}{z}\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{-172}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-130}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-46}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error21.8
Cost848
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := \frac{t \cdot x}{z}\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+115}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{+190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+288}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error5.7
Cost712
\[\begin{array}{l} t_1 := x \cdot \frac{y + t}{z}\\ \mathbf{if}\;z \leq -29000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error26.4
Cost584
\[\begin{array}{l} t_1 := x \cdot \left(-t\right)\\ \mathbf{if}\;t \leq -2.2 \cdot 10^{+192}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.9 \cdot 10^{+200}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error50.5
Cost256
\[x \cdot \left(-t\right) \]

Error

Reproduce?

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