Main:z from

Percentage Accurate: 91.7% → 98.2%
Time: 39.2s
Alternatives: 20
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+
  (+
   (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y)))
   (- (sqrt (+ z 1.0)) (sqrt z)))
  (- (sqrt (+ t 1.0)) (sqrt t))))
double code(double x, double y, double z, double t) {
	return (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
}
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 = (((sqrt((x + 1.0d0)) - sqrt(x)) + (sqrt((y + 1.0d0)) - sqrt(y))) + (sqrt((z + 1.0d0)) - sqrt(z))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
	return (((Math.sqrt((x + 1.0)) - Math.sqrt(x)) + (Math.sqrt((y + 1.0)) - Math.sqrt(y))) + (Math.sqrt((z + 1.0)) - Math.sqrt(z))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
def code(x, y, z, t):
	return (((math.sqrt((x + 1.0)) - math.sqrt(x)) + (math.sqrt((y + 1.0)) - math.sqrt(y))) + (math.sqrt((z + 1.0)) - math.sqrt(z))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) + Float64(sqrt(Float64(y + 1.0)) - sqrt(y))) + Float64(sqrt(Float64(z + 1.0)) - sqrt(z))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t)))
end
function tmp = code(x, y, z, t)
	tmp = (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 20 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+
  (+
   (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y)))
   (- (sqrt (+ z 1.0)) (sqrt z)))
  (- (sqrt (+ t 1.0)) (sqrt t))))
double code(double x, double y, double z, double t) {
	return (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
}
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 = (((sqrt((x + 1.0d0)) - sqrt(x)) + (sqrt((y + 1.0d0)) - sqrt(y))) + (sqrt((z + 1.0d0)) - sqrt(z))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
	return (((Math.sqrt((x + 1.0)) - Math.sqrt(x)) + (Math.sqrt((y + 1.0)) - Math.sqrt(y))) + (Math.sqrt((z + 1.0)) - Math.sqrt(z))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
def code(x, y, z, t):
	return (((math.sqrt((x + 1.0)) - math.sqrt(x)) + (math.sqrt((y + 1.0)) - math.sqrt(y))) + (math.sqrt((z + 1.0)) - math.sqrt(z))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) + Float64(sqrt(Float64(y + 1.0)) - sqrt(y))) + Float64(sqrt(Float64(z + 1.0)) - sqrt(z))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t)))
end
function tmp = code(x, y, z, t)
	tmp = (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\end{array}

Alternative 1: 98.2% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \left(\frac{1}{\sqrt{1 + y} + \sqrt{y}} + \frac{1}{\sqrt{1 + x} + \sqrt{x}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (+
  (+
   (/ 1.0 (+ (sqrt (+ 1.0 y)) (sqrt y)))
   (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))
  (+ (- (sqrt (+ 1.0 z)) (sqrt z)) (- (sqrt (+ 1.0 t)) (sqrt t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return ((1.0 / (sqrt((1.0 + y)) + sqrt(y))) + (1.0 / (sqrt((1.0 + x)) + sqrt(x)))) + ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t)));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = ((1.0d0 / (sqrt((1.0d0 + y)) + sqrt(y))) + (1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x)))) + ((sqrt((1.0d0 + z)) - sqrt(z)) + (sqrt((1.0d0 + t)) - sqrt(t)))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return ((1.0 / (Math.sqrt((1.0 + y)) + Math.sqrt(y))) + (1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x)))) + ((Math.sqrt((1.0 + z)) - Math.sqrt(z)) + (Math.sqrt((1.0 + t)) - Math.sqrt(t)));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return ((1.0 / (math.sqrt((1.0 + y)) + math.sqrt(y))) + (1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x)))) + ((math.sqrt((1.0 + z)) - math.sqrt(z)) + (math.sqrt((1.0 + t)) - math.sqrt(t)))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(Float64(Float64(1.0 / Float64(sqrt(Float64(1.0 + y)) + sqrt(y))) + Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)))) + Float64(Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = ((1.0 / (sqrt((1.0 + y)) + sqrt(y))) + (1.0 / (sqrt((1.0 + x)) + sqrt(x)))) + ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t)));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(N[(N[(1.0 / N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\left(\frac{1}{\sqrt{1 + y} + \sqrt{y}} + \frac{1}{\sqrt{1 + x} + \sqrt{x}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)
\end{array}
Derivation
  1. Initial program 92.2%

    \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
  2. Step-by-step derivation
    1. associate-+l+92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    2. +-commutative92.2%

      \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
    3. +-commutative92.2%

      \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
    4. +-commutative92.2%

      \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
  3. Simplified92.2%

    \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. flip--92.5%

      \[\leadsto \left(\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    2. add-sqr-sqrt73.6%

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

      \[\leadsto \left(\frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    4. add-sqr-sqrt92.7%

      \[\leadsto \left(\frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{x + 1} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    5. +-commutative92.7%

      \[\leadsto \left(\frac{\left(1 + x\right) - x}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  6. Applied egg-rr92.7%

    \[\leadsto \left(\color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  7. Step-by-step derivation
    1. associate--l+94.1%

      \[\leadsto \left(\frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    2. +-inverses94.1%

      \[\leadsto \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    3. metadata-eval94.1%

      \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  8. Simplified94.1%

    \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  9. Step-by-step derivation
    1. flip--94.2%

      \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \color{blue}{\frac{\sqrt{1 + y} \cdot \sqrt{1 + y} - \sqrt{y} \cdot \sqrt{y}}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    2. add-sqr-sqrt79.4%

      \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{\left(1 + y\right)} - \sqrt{y} \cdot \sqrt{y}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    3. add-sqr-sqrt94.3%

      \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\left(1 + y\right) - \color{blue}{y}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  10. Applied egg-rr94.3%

    \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \color{blue}{\frac{\left(1 + y\right) - y}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  11. Step-by-step derivation
    1. associate--l+96.2%

      \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{1 + \left(y - y\right)}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    2. +-inverses96.2%

      \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{1 + \color{blue}{0}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    3. metadata-eval96.2%

      \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{1}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  12. Simplified96.2%

    \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \color{blue}{\frac{1}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  13. Final simplification96.2%

    \[\leadsto \left(\frac{1}{\sqrt{1 + y} + \sqrt{y}} + \frac{1}{\sqrt{1 + x} + \sqrt{x}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  14. Add Preprocessing

Alternative 2: 97.6% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := \sqrt{1 + x}\\ t_2 := \sqrt{1 + y}\\ \mathbf{if}\;\left(t_1 - \sqrt{x}\right) + \left(t_2 - \sqrt{y}\right) \leq 1:\\ \;\;\;\;\frac{1}{t_1 + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{t_2 + \sqrt{y}}\right) + \left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (sqrt (+ 1.0 x))) (t_2 (sqrt (+ 1.0 y))))
   (if (<= (+ (- t_1 (sqrt x)) (- t_2 (sqrt y))) 1.0)
     (/ 1.0 (+ t_1 (sqrt x)))
     (+
      (+ 1.0 (/ 1.0 (+ t_2 (sqrt y))))
      (+
       (- (sqrt (+ 1.0 t)) (sqrt t))
       (/ 1.0 (+ (sqrt (+ 1.0 z)) (sqrt z))))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = sqrt((1.0 + x));
	double t_2 = sqrt((1.0 + y));
	double tmp;
	if (((t_1 - sqrt(x)) + (t_2 - sqrt(y))) <= 1.0) {
		tmp = 1.0 / (t_1 + sqrt(x));
	} else {
		tmp = (1.0 + (1.0 / (t_2 + sqrt(y)))) + ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z))));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 = sqrt((1.0d0 + x))
    t_2 = sqrt((1.0d0 + y))
    if (((t_1 - sqrt(x)) + (t_2 - sqrt(y))) <= 1.0d0) then
        tmp = 1.0d0 / (t_1 + sqrt(x))
    else
        tmp = (1.0d0 + (1.0d0 / (t_2 + sqrt(y)))) + ((sqrt((1.0d0 + t)) - sqrt(t)) + (1.0d0 / (sqrt((1.0d0 + z)) + sqrt(z))))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.sqrt((1.0 + x));
	double t_2 = Math.sqrt((1.0 + y));
	double tmp;
	if (((t_1 - Math.sqrt(x)) + (t_2 - Math.sqrt(y))) <= 1.0) {
		tmp = 1.0 / (t_1 + Math.sqrt(x));
	} else {
		tmp = (1.0 + (1.0 / (t_2 + Math.sqrt(y)))) + ((Math.sqrt((1.0 + t)) - Math.sqrt(t)) + (1.0 / (Math.sqrt((1.0 + z)) + Math.sqrt(z))));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	t_1 = math.sqrt((1.0 + x))
	t_2 = math.sqrt((1.0 + y))
	tmp = 0
	if ((t_1 - math.sqrt(x)) + (t_2 - math.sqrt(y))) <= 1.0:
		tmp = 1.0 / (t_1 + math.sqrt(x))
	else:
		tmp = (1.0 + (1.0 / (t_2 + math.sqrt(y)))) + ((math.sqrt((1.0 + t)) - math.sqrt(t)) + (1.0 / (math.sqrt((1.0 + z)) + math.sqrt(z))))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = sqrt(Float64(1.0 + x))
	t_2 = sqrt(Float64(1.0 + y))
	tmp = 0.0
	if (Float64(Float64(t_1 - sqrt(x)) + Float64(t_2 - sqrt(y))) <= 1.0)
		tmp = Float64(1.0 / Float64(t_1 + sqrt(x)));
	else
		tmp = Float64(Float64(1.0 + Float64(1.0 / Float64(t_2 + sqrt(y)))) + Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(1.0 / Float64(sqrt(Float64(1.0 + z)) + sqrt(z)))));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	t_1 = sqrt((1.0 + x));
	t_2 = sqrt((1.0 + y));
	tmp = 0.0;
	if (((t_1 - sqrt(x)) + (t_2 - sqrt(y))) <= 1.0)
		tmp = 1.0 / (t_1 + sqrt(x));
	else
		tmp = (1.0 + (1.0 / (t_2 + sqrt(y)))) + ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z))));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0], N[(1.0 / N[(t$95$1 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(1.0 / N[(t$95$2 + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + x}\\
t_2 := \sqrt{1 + y}\\
\mathbf{if}\;\left(t_1 - \sqrt{x}\right) + \left(t_2 - \sqrt{y}\right) \leq 1:\\
\;\;\;\;\frac{1}{t_1 + \sqrt{x}}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{t_2 + \sqrt{y}}\right) + \left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y 1)) (sqrt.f64 y))) < 1

    1. Initial program 89.2%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative89.2%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+89.2%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-63.2%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-47.0%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-39.5%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified38.7%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.3%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+15.9%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative15.9%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative15.9%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified15.9%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 15.9%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative15.9%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified15.9%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 14.9%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--14.9%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt15.3%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt14.9%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr14.9%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+18.4%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses18.4%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval18.4%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative18.4%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified18.4%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]

    if 1 < (+.f64 (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y 1)) (sqrt.f64 y)))

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified98.4%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 93.8%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Step-by-step derivation
      1. flip--93.8%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\sqrt{1 + z} \cdot \sqrt{1 + z} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt71.1%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{\left(1 + z\right)} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt93.8%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\left(1 + z\right) - \color{blue}{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Applied egg-rr93.8%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\left(1 + z\right) - z}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Step-by-step derivation
      1. associate--l+94.1%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1 + \left(z - z\right)}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses94.1%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval94.1%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    9. Simplified94.1%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{1}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    10. Step-by-step derivation
      1. flip--99.3%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \color{blue}{\frac{\sqrt{1 + y} \cdot \sqrt{1 + y} - \sqrt{y} \cdot \sqrt{y}}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt99.5%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{\left(1 + y\right)} - \sqrt{y} \cdot \sqrt{y}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt99.5%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\left(1 + y\right) - \color{blue}{y}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    11. Applied egg-rr94.3%

      \[\leadsto \left(1 + \color{blue}{\frac{\left(1 + y\right) - y}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\frac{1}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    12. Step-by-step derivation
      1. associate--l+99.5%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{1 + \left(y - y\right)}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses99.5%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{1 + \color{blue}{0}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval99.5%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{1}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    13. Simplified94.3%

      \[\leadsto \left(1 + \color{blue}{\frac{1}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\frac{1}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\sqrt{1 + x} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right) \leq 1:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 96.2% accurate, 0.8× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := \sqrt{1 + t} - \sqrt{t}\\ t_2 := \sqrt{1 + x}\\ t_3 := \sqrt{1 + y}\\ t_4 := \sqrt{1 + z}\\ \mathbf{if}\;t_2 - \sqrt{x} \leq 1:\\ \;\;\;\;\left(\left(t_4 - \sqrt{z}\right) + t_1\right) + \left(\left(t_3 - \sqrt{y}\right) + \frac{1}{t_2 + \sqrt{x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{t_3 + \sqrt{y}}\right) + \left(t_1 + \frac{1}{t_4 + \sqrt{z}}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (sqrt (+ 1.0 t)) (sqrt t)))
        (t_2 (sqrt (+ 1.0 x)))
        (t_3 (sqrt (+ 1.0 y)))
        (t_4 (sqrt (+ 1.0 z))))
   (if (<= (- t_2 (sqrt x)) 1.0)
     (+ (+ (- t_4 (sqrt z)) t_1) (+ (- t_3 (sqrt y)) (/ 1.0 (+ t_2 (sqrt x)))))
     (+ (+ 1.0 (/ 1.0 (+ t_3 (sqrt y)))) (+ t_1 (/ 1.0 (+ t_4 (sqrt z))))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = sqrt((1.0 + t)) - sqrt(t);
	double t_2 = sqrt((1.0 + x));
	double t_3 = sqrt((1.0 + y));
	double t_4 = sqrt((1.0 + z));
	double tmp;
	if ((t_2 - sqrt(x)) <= 1.0) {
		tmp = ((t_4 - sqrt(z)) + t_1) + ((t_3 - sqrt(y)) + (1.0 / (t_2 + sqrt(x))));
	} else {
		tmp = (1.0 + (1.0 / (t_3 + sqrt(y)))) + (t_1 + (1.0 / (t_4 + sqrt(z))));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 = sqrt((1.0d0 + t)) - sqrt(t)
    t_2 = sqrt((1.0d0 + x))
    t_3 = sqrt((1.0d0 + y))
    t_4 = sqrt((1.0d0 + z))
    if ((t_2 - sqrt(x)) <= 1.0d0) then
        tmp = ((t_4 - sqrt(z)) + t_1) + ((t_3 - sqrt(y)) + (1.0d0 / (t_2 + sqrt(x))))
    else
        tmp = (1.0d0 + (1.0d0 / (t_3 + sqrt(y)))) + (t_1 + (1.0d0 / (t_4 + sqrt(z))))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.sqrt((1.0 + t)) - Math.sqrt(t);
	double t_2 = Math.sqrt((1.0 + x));
	double t_3 = Math.sqrt((1.0 + y));
	double t_4 = Math.sqrt((1.0 + z));
	double tmp;
	if ((t_2 - Math.sqrt(x)) <= 1.0) {
		tmp = ((t_4 - Math.sqrt(z)) + t_1) + ((t_3 - Math.sqrt(y)) + (1.0 / (t_2 + Math.sqrt(x))));
	} else {
		tmp = (1.0 + (1.0 / (t_3 + Math.sqrt(y)))) + (t_1 + (1.0 / (t_4 + Math.sqrt(z))));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	t_1 = math.sqrt((1.0 + t)) - math.sqrt(t)
	t_2 = math.sqrt((1.0 + x))
	t_3 = math.sqrt((1.0 + y))
	t_4 = math.sqrt((1.0 + z))
	tmp = 0
	if (t_2 - math.sqrt(x)) <= 1.0:
		tmp = ((t_4 - math.sqrt(z)) + t_1) + ((t_3 - math.sqrt(y)) + (1.0 / (t_2 + math.sqrt(x))))
	else:
		tmp = (1.0 + (1.0 / (t_3 + math.sqrt(y)))) + (t_1 + (1.0 / (t_4 + math.sqrt(z))))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t))
	t_2 = sqrt(Float64(1.0 + x))
	t_3 = sqrt(Float64(1.0 + y))
	t_4 = sqrt(Float64(1.0 + z))
	tmp = 0.0
	if (Float64(t_2 - sqrt(x)) <= 1.0)
		tmp = Float64(Float64(Float64(t_4 - sqrt(z)) + t_1) + Float64(Float64(t_3 - sqrt(y)) + Float64(1.0 / Float64(t_2 + sqrt(x)))));
	else
		tmp = Float64(Float64(1.0 + Float64(1.0 / Float64(t_3 + sqrt(y)))) + Float64(t_1 + Float64(1.0 / Float64(t_4 + sqrt(z)))));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	t_1 = sqrt((1.0 + t)) - sqrt(t);
	t_2 = sqrt((1.0 + x));
	t_3 = sqrt((1.0 + y));
	t_4 = sqrt((1.0 + z));
	tmp = 0.0;
	if ((t_2 - sqrt(x)) <= 1.0)
		tmp = ((t_4 - sqrt(z)) + t_1) + ((t_3 - sqrt(y)) + (1.0 / (t_2 + sqrt(x))));
	else
		tmp = (1.0 + (1.0 / (t_3 + sqrt(y)))) + (t_1 + (1.0 / (t_4 + sqrt(z))));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$2 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 1.0], N[(N[(N[(t$95$4 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] + N[(N[(t$95$3 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(t$95$2 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(1.0 / N[(t$95$3 + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 + N[(1.0 / N[(t$95$4 + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + t} - \sqrt{t}\\
t_2 := \sqrt{1 + x}\\
t_3 := \sqrt{1 + y}\\
t_4 := \sqrt{1 + z}\\
\mathbf{if}\;t_2 - \sqrt{x} \leq 1:\\
\;\;\;\;\left(\left(t_4 - \sqrt{z}\right) + t_1\right) + \left(\left(t_3 - \sqrt{y}\right) + \frac{1}{t_2 + \sqrt{x}}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{1}{t_3 + \sqrt{y}}\right) + \left(t_1 + \frac{1}{t_4 + \sqrt{z}}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x)) < 1

    1. Initial program 92.2%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+92.2%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative92.2%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative92.2%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative92.2%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--92.5%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt73.6%

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

        \[\leadsto \left(\frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      4. add-sqr-sqrt92.7%

        \[\leadsto \left(\frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{x + 1} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      5. +-commutative92.7%

        \[\leadsto \left(\frac{\left(1 + x\right) - x}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Applied egg-rr92.7%

      \[\leadsto \left(\color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Step-by-step derivation
      1. associate--l+94.1%

        \[\leadsto \left(\frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses94.1%

        \[\leadsto \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval94.1%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Simplified94.1%

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

    if 1 < (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x))

    1. Initial program 92.2%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+92.2%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative92.2%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative92.2%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative92.2%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 59.8%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Step-by-step derivation
      1. flip--59.9%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\sqrt{1 + z} \cdot \sqrt{1 + z} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt47.1%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{\left(1 + z\right)} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt59.9%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\left(1 + z\right) - \color{blue}{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Applied egg-rr59.9%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\left(1 + z\right) - z}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Step-by-step derivation
      1. associate--l+60.0%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1 + \left(z - z\right)}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses60.0%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval60.0%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    9. Simplified60.0%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{1}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    10. Step-by-step derivation
      1. flip--94.2%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \color{blue}{\frac{\sqrt{1 + y} \cdot \sqrt{1 + y} - \sqrt{y} \cdot \sqrt{y}}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt79.4%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{\left(1 + y\right)} - \sqrt{y} \cdot \sqrt{y}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt94.3%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\left(1 + y\right) - \color{blue}{y}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    11. Applied egg-rr60.0%

      \[\leadsto \left(1 + \color{blue}{\frac{\left(1 + y\right) - y}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\frac{1}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    12. Step-by-step derivation
      1. associate--l+96.2%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{1 + \left(y - y\right)}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses96.2%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{1 + \color{blue}{0}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval96.2%

        \[\leadsto \left(\frac{1}{\sqrt{1 + x} + \sqrt{x}} + \frac{\color{blue}{1}}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    13. Simplified60.3%

      \[\leadsto \left(1 + \color{blue}{\frac{1}{\sqrt{1 + y} + \sqrt{y}}}\right) + \left(\frac{1}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification94.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{1 + x} - \sqrt{x} \leq 1:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(\left(\sqrt{1 + y} - \sqrt{y}\right) + \frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{1}{\sqrt{1 + y} + \sqrt{y}}\right) + \left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 96.4% accurate, 1.3× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{1}{\sqrt{1 + t} + \sqrt{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.9e+26)
   (+
    (+ 1.0 (- (sqrt (+ 1.0 y)) (sqrt y)))
    (+ (- (sqrt (+ 1.0 z)) (sqrt z)) (/ 1.0 (+ (sqrt (+ 1.0 t)) (sqrt t)))))
   (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = (1.0 + (sqrt((1.0 + y)) - sqrt(y))) + ((sqrt((1.0 + z)) - sqrt(z)) + (1.0 / (sqrt((1.0 + t)) + sqrt(t))));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 (y <= 1.9d+26) then
        tmp = (1.0d0 + (sqrt((1.0d0 + y)) - sqrt(y))) + ((sqrt((1.0d0 + z)) - sqrt(z)) + (1.0d0 / (sqrt((1.0d0 + t)) + sqrt(t))))
    else
        tmp = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = (1.0 + (Math.sqrt((1.0 + y)) - Math.sqrt(y))) + ((Math.sqrt((1.0 + z)) - Math.sqrt(z)) + (1.0 / (Math.sqrt((1.0 + t)) + Math.sqrt(t))));
	} else {
		tmp = 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= 1.9e+26:
		tmp = (1.0 + (math.sqrt((1.0 + y)) - math.sqrt(y))) + ((math.sqrt((1.0 + z)) - math.sqrt(z)) + (1.0 / (math.sqrt((1.0 + t)) + math.sqrt(t))))
	else:
		tmp = 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.9e+26)
		tmp = Float64(Float64(1.0 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y))) + Float64(Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) + Float64(1.0 / Float64(sqrt(Float64(1.0 + t)) + sqrt(t)))));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.9e+26)
		tmp = (1.0 + (sqrt((1.0 + y)) - sqrt(y))) + ((sqrt((1.0 + z)) - sqrt(z)) + (1.0 / (sqrt((1.0 + t)) + sqrt(t))));
	else
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e+26], N[(N[(1.0 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\
\;\;\;\;\left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{1}{\sqrt{1 + t} + \sqrt{t}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.9000000000000001e26

    1. Initial program 97.7%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+97.7%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified97.7%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 62.4%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Step-by-step derivation
      1. flip--62.3%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \color{blue}{\frac{\sqrt{1 + t} \cdot \sqrt{1 + t} - \sqrt{t} \cdot \sqrt{t}}{\sqrt{1 + t} + \sqrt{t}}}\right) \]
      2. add-sqr-sqrt49.9%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\color{blue}{\left(1 + t\right)} - \sqrt{t} \cdot \sqrt{t}}{\sqrt{1 + t} + \sqrt{t}}\right) \]
      3. +-commutative49.9%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\color{blue}{\left(t + 1\right)} - \sqrt{t} \cdot \sqrt{t}}{\sqrt{1 + t} + \sqrt{t}}\right) \]
      4. add-sqr-sqrt62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\left(t + 1\right) - \color{blue}{t}}{\sqrt{1 + t} + \sqrt{t}}\right) \]
      5. +-commutative62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\left(t + 1\right) - t}{\sqrt{\color{blue}{t + 1}} + \sqrt{t}}\right) \]
    7. Applied egg-rr62.4%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \color{blue}{\frac{\left(t + 1\right) - t}{\sqrt{t + 1} + \sqrt{t}}}\right) \]
    8. Step-by-step derivation
      1. +-commutative62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\left(t + 1\right) - t}{\color{blue}{\sqrt{t} + \sqrt{t + 1}}}\right) \]
      2. +-commutative62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\color{blue}{\left(1 + t\right)} - t}{\sqrt{t} + \sqrt{t + 1}}\right) \]
      3. associate--l+62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\color{blue}{1 + \left(t - t\right)}}{\sqrt{t} + \sqrt{t + 1}}\right) \]
      4. +-inverses62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{1 + \color{blue}{0}}{\sqrt{t} + \sqrt{t + 1}}\right) \]
      5. metadata-eval62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{\color{blue}{1}}{\sqrt{t} + \sqrt{t + 1}}\right) \]
      6. +-commutative62.4%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{1}{\sqrt{t} + \sqrt{\color{blue}{1 + t}}}\right) \]
    9. Simplified62.4%

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

    if 1.9000000000000001e26 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \frac{1}{\sqrt{1 + t} + \sqrt{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 97.0% accurate, 1.3× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.9e+26)
   (+
    (+ (- (sqrt (+ 1.0 t)) (sqrt t)) (/ 1.0 (+ (sqrt (+ 1.0 z)) (sqrt z))))
    (+ 1.0 (- (sqrt (+ 1.0 y)) (sqrt y))))
   (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z)))) + (1.0 + (sqrt((1.0 + y)) - sqrt(y)));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 (y <= 1.9d+26) then
        tmp = ((sqrt((1.0d0 + t)) - sqrt(t)) + (1.0d0 / (sqrt((1.0d0 + z)) + sqrt(z)))) + (1.0d0 + (sqrt((1.0d0 + y)) - sqrt(y)))
    else
        tmp = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = ((Math.sqrt((1.0 + t)) - Math.sqrt(t)) + (1.0 / (Math.sqrt((1.0 + z)) + Math.sqrt(z)))) + (1.0 + (Math.sqrt((1.0 + y)) - Math.sqrt(y)));
	} else {
		tmp = 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= 1.9e+26:
		tmp = ((math.sqrt((1.0 + t)) - math.sqrt(t)) + (1.0 / (math.sqrt((1.0 + z)) + math.sqrt(z)))) + (1.0 + (math.sqrt((1.0 + y)) - math.sqrt(y)))
	else:
		tmp = 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.9e+26)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(1.0 / Float64(sqrt(Float64(1.0 + z)) + sqrt(z)))) + Float64(1.0 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y))));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.9e+26)
		tmp = ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z)))) + (1.0 + (sqrt((1.0 + y)) - sqrt(y)));
	else
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e+26], N[(N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\
\;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.9000000000000001e26

    1. Initial program 97.7%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+97.7%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified97.7%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 62.4%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Step-by-step derivation
      1. flip--62.3%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\sqrt{1 + z} \cdot \sqrt{1 + z} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt48.1%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{\left(1 + z\right)} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt62.3%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\left(1 + z\right) - \color{blue}{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Applied egg-rr62.3%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\left(1 + z\right) - z}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Step-by-step derivation
      1. associate--l+62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1 + \left(z - z\right)}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    9. Simplified62.5%

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

    if 1.9000000000000001e26 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 95.9% accurate, 1.3× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.9e+26)
   (+
    (+ (- (sqrt (+ 1.0 z)) (sqrt z)) (- (sqrt (+ 1.0 t)) (sqrt t)))
    (+ 1.0 (- (sqrt (+ 1.0 y)) (sqrt y))))
   (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t))) + (1.0 + (sqrt((1.0 + y)) - sqrt(y)));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 (y <= 1.9d+26) then
        tmp = ((sqrt((1.0d0 + z)) - sqrt(z)) + (sqrt((1.0d0 + t)) - sqrt(t))) + (1.0d0 + (sqrt((1.0d0 + y)) - sqrt(y)))
    else
        tmp = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = ((Math.sqrt((1.0 + z)) - Math.sqrt(z)) + (Math.sqrt((1.0 + t)) - Math.sqrt(t))) + (1.0 + (Math.sqrt((1.0 + y)) - Math.sqrt(y)));
	} else {
		tmp = 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= 1.9e+26:
		tmp = ((math.sqrt((1.0 + z)) - math.sqrt(z)) + (math.sqrt((1.0 + t)) - math.sqrt(t))) + (1.0 + (math.sqrt((1.0 + y)) - math.sqrt(y)))
	else:
		tmp = 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.9e+26)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) + Float64(1.0 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y))));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.9e+26)
		tmp = ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t))) + (1.0 + (sqrt((1.0 + y)) - sqrt(y)));
	else
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e+26], N[(N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\
\;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.9000000000000001e26

    1. Initial program 97.7%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+97.7%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified97.7%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 62.4%

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

    if 1.9000000000000001e26 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 95.9% accurate, 1.3× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(\left(1 + \sqrt{1 + y}\right) - \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 1.9e+26)
   (+
    (+ (- (sqrt (+ 1.0 z)) (sqrt z)) (- (sqrt (+ 1.0 t)) (sqrt t)))
    (- (+ 1.0 (sqrt (+ 1.0 y))) (sqrt y)))
   (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t))) + ((1.0 + sqrt((1.0 + y))) - sqrt(y));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 (y <= 1.9d+26) then
        tmp = ((sqrt((1.0d0 + z)) - sqrt(z)) + (sqrt((1.0d0 + t)) - sqrt(t))) + ((1.0d0 + sqrt((1.0d0 + y))) - sqrt(y))
    else
        tmp = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 1.9e+26) {
		tmp = ((Math.sqrt((1.0 + z)) - Math.sqrt(z)) + (Math.sqrt((1.0 + t)) - Math.sqrt(t))) + ((1.0 + Math.sqrt((1.0 + y))) - Math.sqrt(y));
	} else {
		tmp = 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= 1.9e+26:
		tmp = ((math.sqrt((1.0 + z)) - math.sqrt(z)) + (math.sqrt((1.0 + t)) - math.sqrt(t))) + ((1.0 + math.sqrt((1.0 + y))) - math.sqrt(y))
	else:
		tmp = 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 1.9e+26)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) + Float64(Float64(1.0 + sqrt(Float64(1.0 + y))) - sqrt(y)));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 1.9e+26)
		tmp = ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t))) + ((1.0 + sqrt((1.0 + y))) - sqrt(y));
	else
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 1.9e+26], N[(N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\
\;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(\left(1 + \sqrt{1 + y}\right) - \sqrt{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.9000000000000001e26

    1. Initial program 97.7%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+97.7%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative97.7%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified97.7%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip--98.0%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt80.3%

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

        \[\leadsto \left(\frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      4. add-sqr-sqrt98.2%

        \[\leadsto \left(\frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{x + 1} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      5. +-commutative98.2%

        \[\leadsto \left(\frac{\left(1 + x\right) - x}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Applied egg-rr98.2%

      \[\leadsto \left(\color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Step-by-step derivation
      1. associate--l+98.6%

        \[\leadsto \left(\frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses98.6%

        \[\leadsto \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval98.6%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Simplified98.6%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    9. Taylor expanded in x around 0 62.4%

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

    if 1.9000000000000001e26 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification46.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+26}:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(\left(1 + \sqrt{1 + y}\right) - \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 96.2% accurate, 1.9× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := \sqrt{1 + x}\\ \mathbf{if}\;y \leq 9.2 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + 2\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+21}:\\ \;\;\;\;t_1 + \left(\sqrt{1 + y} + \left(1 + \left(-1 - \left(\sqrt{x} + \sqrt{y}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t_1 + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (sqrt (+ 1.0 x))))
   (if (<= y 9.2e-21)
     (+
      (+ (- (sqrt (+ 1.0 t)) (sqrt t)) (/ 1.0 (+ (sqrt (+ 1.0 z)) (sqrt z))))
      2.0)
     (if (<= y 1.55e+21)
       (+ t_1 (+ (sqrt (+ 1.0 y)) (+ 1.0 (- -1.0 (+ (sqrt x) (sqrt y))))))
       (/ 1.0 (+ t_1 (sqrt x)))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = sqrt((1.0 + x));
	double tmp;
	if (y <= 9.2e-21) {
		tmp = ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z)))) + 2.0;
	} else if (y <= 1.55e+21) {
		tmp = t_1 + (sqrt((1.0 + y)) + (1.0 + (-1.0 - (sqrt(x) + sqrt(y)))));
	} else {
		tmp = 1.0 / (t_1 + sqrt(x));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 = sqrt((1.0d0 + x))
    if (y <= 9.2d-21) then
        tmp = ((sqrt((1.0d0 + t)) - sqrt(t)) + (1.0d0 / (sqrt((1.0d0 + z)) + sqrt(z)))) + 2.0d0
    else if (y <= 1.55d+21) then
        tmp = t_1 + (sqrt((1.0d0 + y)) + (1.0d0 + ((-1.0d0) - (sqrt(x) + sqrt(y)))))
    else
        tmp = 1.0d0 / (t_1 + sqrt(x))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.sqrt((1.0 + x));
	double tmp;
	if (y <= 9.2e-21) {
		tmp = ((Math.sqrt((1.0 + t)) - Math.sqrt(t)) + (1.0 / (Math.sqrt((1.0 + z)) + Math.sqrt(z)))) + 2.0;
	} else if (y <= 1.55e+21) {
		tmp = t_1 + (Math.sqrt((1.0 + y)) + (1.0 + (-1.0 - (Math.sqrt(x) + Math.sqrt(y)))));
	} else {
		tmp = 1.0 / (t_1 + Math.sqrt(x));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	t_1 = math.sqrt((1.0 + x))
	tmp = 0
	if y <= 9.2e-21:
		tmp = ((math.sqrt((1.0 + t)) - math.sqrt(t)) + (1.0 / (math.sqrt((1.0 + z)) + math.sqrt(z)))) + 2.0
	elif y <= 1.55e+21:
		tmp = t_1 + (math.sqrt((1.0 + y)) + (1.0 + (-1.0 - (math.sqrt(x) + math.sqrt(y)))))
	else:
		tmp = 1.0 / (t_1 + math.sqrt(x))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = sqrt(Float64(1.0 + x))
	tmp = 0.0
	if (y <= 9.2e-21)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(1.0 / Float64(sqrt(Float64(1.0 + z)) + sqrt(z)))) + 2.0);
	elseif (y <= 1.55e+21)
		tmp = Float64(t_1 + Float64(sqrt(Float64(1.0 + y)) + Float64(1.0 + Float64(-1.0 - Float64(sqrt(x) + sqrt(y))))));
	else
		tmp = Float64(1.0 / Float64(t_1 + sqrt(x)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	t_1 = sqrt((1.0 + x));
	tmp = 0.0;
	if (y <= 9.2e-21)
		tmp = ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z)))) + 2.0;
	elseif (y <= 1.55e+21)
		tmp = t_1 + (sqrt((1.0 + y)) + (1.0 + (-1.0 - (sqrt(x) + sqrt(y)))));
	else
		tmp = 1.0 / (t_1 + sqrt(x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 9.2e-21], N[(N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision], If[LessEqual[y, 1.55e+21], N[(t$95$1 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] + N[(1.0 + N[(-1.0 - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + x}\\
\mathbf{if}\;y \leq 9.2 \cdot 10^{-21}:\\
\;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + 2\\

\mathbf{elif}\;y \leq 1.55 \cdot 10^{+21}:\\
\;\;\;\;t_1 + \left(\sqrt{1 + y} + \left(1 + \left(-1 - \left(\sqrt{x} + \sqrt{y}\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{t_1 + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 9.19999999999999998e-21

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified98.4%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 62.5%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Step-by-step derivation
      1. flip--62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\sqrt{1 + z} \cdot \sqrt{1 + z} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt49.6%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{\left(1 + z\right)} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\left(1 + z\right) - \color{blue}{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Applied egg-rr62.5%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\left(1 + z\right) - z}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Step-by-step derivation
      1. associate--l+62.7%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1 + \left(z - z\right)}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses62.7%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval62.7%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    9. Simplified62.7%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{1}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    10. Taylor expanded in y around 0 62.6%

      \[\leadsto \color{blue}{2} + \left(\frac{1}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]

    if 9.19999999999999998e-21 < y < 1.55e21

    1. Initial program 91.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative91.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+91.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-91.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-91.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-91.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.7%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 6.8%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+17.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified17.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative27.6%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u26.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{y} + \sqrt{x}\right)\right)}\right) \]
    12. Applied egg-rr26.0%

      \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{y} + \sqrt{x}\right)\right)}\right) \]
    13. Step-by-step derivation
      1. expm1-udef26.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{y} + \sqrt{x}\right)} - 1\right)}\right) \]
      2. log1p-udef26.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \left(e^{\color{blue}{\log \left(1 + \left(\sqrt{y} + \sqrt{x}\right)\right)}} - 1\right)\right) \]
      3. rem-exp-log27.7%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \left(\color{blue}{\left(1 + \left(\sqrt{y} + \sqrt{x}\right)\right)} - 1\right)\right) \]
    14. Applied egg-rr27.7%

      \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\left(1 + \left(\sqrt{y} + \sqrt{x}\right)\right) - 1\right)}\right) \]

    if 1.55e21 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9.2 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + 2\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+21}:\\ \;\;\;\;\sqrt{1 + x} + \left(\sqrt{1 + y} + \left(1 + \left(-1 - \left(\sqrt{x} + \sqrt{y}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 90.1% accurate, 2.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} t_1 := \sqrt{1 + y}\\ \mathbf{if}\;y \leq 1.02 \cdot 10^{-20}:\\ \;\;\;\;1 + \left(t_1 + \left(\sqrt{1 + z} - \left(\sqrt{y} + \sqrt{z}\right)\right)\right)\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\ \;\;\;\;\left(t_1 + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (sqrt (+ 1.0 y))))
   (if (<= y 1.02e-20)
     (+ 1.0 (+ t_1 (- (sqrt (+ 1.0 z)) (+ (sqrt y) (sqrt z)))))
     (if (<= y 2e+21)
       (- (+ t_1 (fma x 0.5 1.0)) (+ (sqrt x) (sqrt y)))
       (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x)))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double t_1 = sqrt((1.0 + y));
	double tmp;
	if (y <= 1.02e-20) {
		tmp = 1.0 + (t_1 + (sqrt((1.0 + z)) - (sqrt(y) + sqrt(z))));
	} else if (y <= 2e+21) {
		tmp = (t_1 + fma(x, 0.5, 1.0)) - (sqrt(x) + sqrt(y));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	t_1 = sqrt(Float64(1.0 + y))
	tmp = 0.0
	if (y <= 1.02e-20)
		tmp = Float64(1.0 + Float64(t_1 + Float64(sqrt(Float64(1.0 + z)) - Float64(sqrt(y) + sqrt(z)))));
	elseif (y <= 2e+21)
		tmp = Float64(Float64(t_1 + fma(x, 0.5, 1.0)) - Float64(sqrt(x) + sqrt(y)));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 1.02e-20], N[(1.0 + N[(t$95$1 + N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e+21], N[(N[(t$95$1 + N[(x * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + y}\\
\mathbf{if}\;y \leq 1.02 \cdot 10^{-20}:\\
\;\;\;\;1 + \left(t_1 + \left(\sqrt{1 + z} - \left(\sqrt{y} + \sqrt{z}\right)\right)\right)\\

\mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\
\;\;\;\;\left(t_1 + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 1.02000000000000001e-20

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+98.4%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-98.4%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-98.4%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified74.7%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 17.0%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.0%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.0%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in x around 0 32.2%

      \[\leadsto \color{blue}{\left(1 + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{y} + \sqrt{z}\right)} \]
    9. Step-by-step derivation
      1. associate--l+43.7%

        \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
      2. associate--l+54.6%

        \[\leadsto 1 + \color{blue}{\left(\sqrt{1 + y} + \left(\sqrt{1 + z} - \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
    10. Simplified54.6%

      \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} + \left(\sqrt{1 + z} - \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]

    if 1.02000000000000001e-20 < y < 2e21

    1. Initial program 91.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative91.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+91.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-91.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-91.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-91.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.7%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 6.8%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+17.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified17.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative27.6%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 28.7%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative28.7%

        \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    13. Simplified28.7%

      \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    14. Step-by-step derivation
      1. associate-+r-28.7%

        \[\leadsto \color{blue}{\left(\left(1 + x \cdot 0.5\right) + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right)} \]
      2. +-commutative28.7%

        \[\leadsto \left(\color{blue}{\left(x \cdot 0.5 + 1\right)} + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right) \]
      3. fma-def28.7%

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)} + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right) \]
    15. Applied egg-rr28.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, 0.5, 1\right) + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right)} \]

    if 2e21 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification40.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.02 \cdot 10^{-20}:\\ \;\;\;\;1 + \left(\sqrt{1 + y} + \left(\sqrt{1 + z} - \left(\sqrt{y} + \sqrt{z}\right)\right)\right)\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\ \;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 95.3% accurate, 2.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 8 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + 2\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\ \;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 8e-21)
   (+ (+ (- (sqrt (+ 1.0 z)) (sqrt z)) (- (sqrt (+ 1.0 t)) (sqrt t))) 2.0)
   (if (<= y 2e+21)
     (- (+ (sqrt (+ 1.0 y)) (fma x 0.5 1.0)) (+ (sqrt x) (sqrt y)))
     (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 8e-21) {
		tmp = ((sqrt((1.0 + z)) - sqrt(z)) + (sqrt((1.0 + t)) - sqrt(t))) + 2.0;
	} else if (y <= 2e+21) {
		tmp = (sqrt((1.0 + y)) + fma(x, 0.5, 1.0)) - (sqrt(x) + sqrt(y));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 8e-21)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) + 2.0);
	elseif (y <= 2e+21)
		tmp = Float64(Float64(sqrt(Float64(1.0 + y)) + fma(x, 0.5, 1.0)) - Float64(sqrt(x) + sqrt(y)));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 8e-21], N[(N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision], If[LessEqual[y, 2e+21], N[(N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] + N[(x * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-21}:\\
\;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + 2\\

\mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\
\;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 7.99999999999999926e-21

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified98.4%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 62.5%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Taylor expanded in y around 0 62.5%

      \[\leadsto \color{blue}{2} + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]

    if 7.99999999999999926e-21 < y < 2e21

    1. Initial program 91.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative91.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+91.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-91.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-91.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-91.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.7%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 6.8%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+17.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified17.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative27.6%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 28.7%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative28.7%

        \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    13. Simplified28.7%

      \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    14. Step-by-step derivation
      1. associate-+r-28.7%

        \[\leadsto \color{blue}{\left(\left(1 + x \cdot 0.5\right) + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right)} \]
      2. +-commutative28.7%

        \[\leadsto \left(\color{blue}{\left(x \cdot 0.5 + 1\right)} + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right) \]
      3. fma-def28.7%

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)} + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right) \]
    15. Applied egg-rr28.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, 0.5, 1\right) + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right)} \]

    if 2e21 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification44.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + 2\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\ \;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 96.1% accurate, 2.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 4.6 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + 2\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\ \;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 4.6e-21)
   (+
    (+ (- (sqrt (+ 1.0 t)) (sqrt t)) (/ 1.0 (+ (sqrt (+ 1.0 z)) (sqrt z))))
    2.0)
   (if (<= y 2e+21)
     (- (+ (sqrt (+ 1.0 y)) (fma x 0.5 1.0)) (+ (sqrt x) (sqrt y)))
     (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.6e-21) {
		tmp = ((sqrt((1.0 + t)) - sqrt(t)) + (1.0 / (sqrt((1.0 + z)) + sqrt(z)))) + 2.0;
	} else if (y <= 2e+21) {
		tmp = (sqrt((1.0 + y)) + fma(x, 0.5, 1.0)) - (sqrt(x) + sqrt(y));
	} else {
		tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
	}
	return tmp;
}
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 4.6e-21)
		tmp = Float64(Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(1.0 / Float64(sqrt(Float64(1.0 + z)) + sqrt(z)))) + 2.0);
	elseif (y <= 2e+21)
		tmp = Float64(Float64(sqrt(Float64(1.0 + y)) + fma(x, 0.5, 1.0)) - Float64(sqrt(x) + sqrt(y)));
	else
		tmp = Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
	end
	return tmp
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 4.6e-21], N[(N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision], If[LessEqual[y, 2e+21], N[(N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] + N[(x * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{-21}:\\
\;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + 2\\

\mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\
\;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 4.59999999999999999e-21

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. associate-+l+98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      2. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{\color{blue}{1 + y}} - \sqrt{y}\right)\right) + \left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      3. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{\color{blue}{1 + z}} - \sqrt{z}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. +-commutative98.4%

        \[\leadsto \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{\color{blue}{1 + t}} - \sqrt{t}\right)\right) \]
    3. Simplified98.4%

      \[\leadsto \color{blue}{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 62.5%

      \[\leadsto \left(\color{blue}{1} + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\left(\sqrt{1 + z} - \sqrt{z}\right) + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    6. Step-by-step derivation
      1. flip--62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\sqrt{1 + z} \cdot \sqrt{1 + z} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. add-sqr-sqrt49.6%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{\left(1 + z\right)} - \sqrt{z} \cdot \sqrt{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. add-sqr-sqrt62.5%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\left(1 + z\right) - \color{blue}{z}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    7. Applied egg-rr62.5%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{\left(1 + z\right) - z}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    8. Step-by-step derivation
      1. associate--l+62.7%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1 + \left(z - z\right)}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      2. +-inverses62.7%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{1 + \color{blue}{0}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
      3. metadata-eval62.7%

        \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\frac{\color{blue}{1}}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    9. Simplified62.7%

      \[\leadsto \left(1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\color{blue}{\frac{1}{\sqrt{1 + z} + \sqrt{z}}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]
    10. Taylor expanded in y around 0 62.6%

      \[\leadsto \color{blue}{2} + \left(\frac{1}{\sqrt{1 + z} + \sqrt{z}} + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) \]

    if 4.59999999999999999e-21 < y < 2e21

    1. Initial program 91.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative91.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+91.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-91.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-91.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-91.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.7%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 6.8%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+17.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative17.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified17.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative27.6%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified27.6%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 28.7%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative28.7%

        \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    13. Simplified28.7%

      \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    14. Step-by-step derivation
      1. associate-+r-28.7%

        \[\leadsto \color{blue}{\left(\left(1 + x \cdot 0.5\right) + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right)} \]
      2. +-commutative28.7%

        \[\leadsto \left(\color{blue}{\left(x \cdot 0.5 + 1\right)} + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right) \]
      3. fma-def28.7%

        \[\leadsto \left(\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)} + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right) \]
    15. Applied egg-rr28.7%

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, 0.5, 1\right) + \sqrt{1 + y}\right) - \left(\sqrt{y} + \sqrt{x}\right)} \]

    if 2e21 < y

    1. Initial program 84.6%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.6%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.6%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-42.7%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-16.8%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-4.7%

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

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.2%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.1%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.1%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.0%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.0%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Step-by-step derivation
      1. flip--21.2%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}} \]
      2. add-sqr-sqrt21.6%

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. add-sqr-sqrt21.2%

        \[\leadsto \frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{1 + x} + \sqrt{x}} \]
    13. Applied egg-rr21.2%

      \[\leadsto \color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}} \]
    14. Step-by-step derivation
      1. associate--l+24.8%

        \[\leadsto \frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{1 + x} + \sqrt{x}} \]
      2. +-inverses24.8%

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{1 + x} + \sqrt{x}} \]
      3. metadata-eval24.8%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}} \]
      4. +-commutative24.8%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{x} + \sqrt{1 + x}}} \]
    15. Simplified24.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification45.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4.6 \cdot 10^{-21}:\\ \;\;\;\;\left(\left(\sqrt{1 + t} - \sqrt{t}\right) + \frac{1}{\sqrt{1 + z} + \sqrt{z}}\right) + 2\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+21}:\\ \;\;\;\;\left(\sqrt{1 + y} + \mathsf{fma}\left(x, 0.5, 1\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 86.0% accurate, 2.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 11200000000000:\\ \;\;\;\;\left(\sqrt{1 + z} + 2\right) - \sqrt{z}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} + \left(\left(\sqrt{1 + y} - \sqrt{y}\right) - \sqrt{x}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= z 11200000000000.0)
   (- (+ (sqrt (+ 1.0 z)) 2.0) (sqrt z))
   (+ (sqrt (+ 1.0 x)) (- (- (sqrt (+ 1.0 y)) (sqrt y)) (sqrt x)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 11200000000000.0) {
		tmp = (sqrt((1.0 + z)) + 2.0) - sqrt(z);
	} else {
		tmp = sqrt((1.0 + x)) + ((sqrt((1.0 + y)) - sqrt(y)) - sqrt(x));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 <= 11200000000000.0d0) then
        tmp = (sqrt((1.0d0 + z)) + 2.0d0) - sqrt(z)
    else
        tmp = sqrt((1.0d0 + x)) + ((sqrt((1.0d0 + y)) - sqrt(y)) - sqrt(x))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 11200000000000.0) {
		tmp = (Math.sqrt((1.0 + z)) + 2.0) - Math.sqrt(z);
	} else {
		tmp = Math.sqrt((1.0 + x)) + ((Math.sqrt((1.0 + y)) - Math.sqrt(y)) - Math.sqrt(x));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if z <= 11200000000000.0:
		tmp = (math.sqrt((1.0 + z)) + 2.0) - math.sqrt(z)
	else:
		tmp = math.sqrt((1.0 + x)) + ((math.sqrt((1.0 + y)) - math.sqrt(y)) - math.sqrt(x))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= 11200000000000.0)
		tmp = Float64(Float64(sqrt(Float64(1.0 + z)) + 2.0) - sqrt(z));
	else
		tmp = Float64(sqrt(Float64(1.0 + x)) + Float64(Float64(sqrt(Float64(1.0 + y)) - sqrt(y)) - sqrt(x)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= 11200000000000.0)
		tmp = (sqrt((1.0 + z)) + 2.0) - sqrt(z);
	else
		tmp = sqrt((1.0 + x)) + ((sqrt((1.0 + y)) - sqrt(y)) - sqrt(x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[z, 11200000000000.0], N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + 2.0), $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 11200000000000:\\
\;\;\;\;\left(\sqrt{1 + z} + 2\right) - \sqrt{z}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{1 + x} + \left(\left(\sqrt{1 + y} - \sqrt{y}\right) - \sqrt{x}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.12e13

    1. Initial program 97.9%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative97.9%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+97.9%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-83.2%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-75.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-64.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 18.4%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.8%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in y around 0 27.3%

      \[\leadsto \color{blue}{\left(1 + \left(\sqrt{1 + x} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \sqrt{z}\right)} \]
    9. Step-by-step derivation
      1. associate--l+39.4%

        \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + x} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \sqrt{z}\right)\right)} \]
      2. associate--r+39.3%

        \[\leadsto 1 + \color{blue}{\left(\left(\left(\sqrt{1 + x} + \sqrt{1 + z}\right) - \sqrt{x}\right) - \sqrt{z}\right)} \]
      3. +-commutative39.3%

        \[\leadsto 1 + \left(\left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + x}\right)} - \sqrt{x}\right) - \sqrt{z}\right) \]
      4. associate--l+52.9%

        \[\leadsto 1 + \left(\color{blue}{\left(\sqrt{1 + z} + \left(\sqrt{1 + x} - \sqrt{x}\right)\right)} - \sqrt{z}\right) \]
    10. Simplified52.9%

      \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + z} + \left(\sqrt{1 + x} - \sqrt{x}\right)\right) - \sqrt{z}\right)} \]
    11. Taylor expanded in x around 0 46.4%

      \[\leadsto \color{blue}{\left(2 + \sqrt{1 + z}\right) - \sqrt{z}} \]

    if 1.12e13 < z

    1. Initial program 87.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative87.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+87.4%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-67.5%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-53.9%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-53.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified27.3%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 4.0%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.8%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 33.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative33.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
      2. associate--r+32.8%

        \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\left(\sqrt{1 + y} - \sqrt{y}\right) - \sqrt{x}\right)} \]
    10. Simplified32.8%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\left(\sqrt{1 + y} - \sqrt{y}\right) - \sqrt{x}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 11200000000000:\\ \;\;\;\;\left(\sqrt{1 + z} + 2\right) - \sqrt{z}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} + \left(\left(\sqrt{1 + y} - \sqrt{y}\right) - \sqrt{x}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 84.6% accurate, 3.9× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 24000000000000:\\ \;\;\;\;\sqrt{1 + z} + \left(2 - \sqrt{z}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= z 24000000000000.0)
   (+ (sqrt (+ 1.0 z)) (- 2.0 (sqrt z)))
   (+ 1.0 (- (sqrt (+ 1.0 y)) (sqrt y)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 24000000000000.0) {
		tmp = sqrt((1.0 + z)) + (2.0 - sqrt(z));
	} else {
		tmp = 1.0 + (sqrt((1.0 + y)) - sqrt(y));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 <= 24000000000000.0d0) then
        tmp = sqrt((1.0d0 + z)) + (2.0d0 - sqrt(z))
    else
        tmp = 1.0d0 + (sqrt((1.0d0 + y)) - sqrt(y))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 24000000000000.0) {
		tmp = Math.sqrt((1.0 + z)) + (2.0 - Math.sqrt(z));
	} else {
		tmp = 1.0 + (Math.sqrt((1.0 + y)) - Math.sqrt(y));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if z <= 24000000000000.0:
		tmp = math.sqrt((1.0 + z)) + (2.0 - math.sqrt(z))
	else:
		tmp = 1.0 + (math.sqrt((1.0 + y)) - math.sqrt(y))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= 24000000000000.0)
		tmp = Float64(sqrt(Float64(1.0 + z)) + Float64(2.0 - sqrt(z)));
	else
		tmp = Float64(1.0 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= 24000000000000.0)
		tmp = sqrt((1.0 + z)) + (2.0 - sqrt(z));
	else
		tmp = 1.0 + (sqrt((1.0 + y)) - sqrt(y));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[z, 24000000000000.0], N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + N[(2.0 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 24000000000000:\\
\;\;\;\;\sqrt{1 + z} + \left(2 - \sqrt{z}\right)\\

\mathbf{else}:\\
\;\;\;\;1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.4e13

    1. Initial program 97.9%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative97.9%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+97.9%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-83.2%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-75.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-64.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 18.4%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.8%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in y around 0 27.3%

      \[\leadsto \color{blue}{\left(1 + \left(\sqrt{1 + x} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \sqrt{z}\right)} \]
    9. Step-by-step derivation
      1. associate--l+39.4%

        \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + x} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \sqrt{z}\right)\right)} \]
      2. associate--r+39.3%

        \[\leadsto 1 + \color{blue}{\left(\left(\left(\sqrt{1 + x} + \sqrt{1 + z}\right) - \sqrt{x}\right) - \sqrt{z}\right)} \]
      3. +-commutative39.3%

        \[\leadsto 1 + \left(\left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + x}\right)} - \sqrt{x}\right) - \sqrt{z}\right) \]
      4. associate--l+52.9%

        \[\leadsto 1 + \left(\color{blue}{\left(\sqrt{1 + z} + \left(\sqrt{1 + x} - \sqrt{x}\right)\right)} - \sqrt{z}\right) \]
    10. Simplified52.9%

      \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + z} + \left(\sqrt{1 + x} - \sqrt{x}\right)\right) - \sqrt{z}\right)} \]
    11. Taylor expanded in x around 0 46.4%

      \[\leadsto \color{blue}{\left(2 + \sqrt{1 + z}\right) - \sqrt{z}} \]
    12. Step-by-step derivation
      1. +-commutative46.4%

        \[\leadsto \color{blue}{\left(\sqrt{1 + z} + 2\right)} - \sqrt{z} \]
      2. associate--l+46.4%

        \[\leadsto \color{blue}{\sqrt{1 + z} + \left(2 - \sqrt{z}\right)} \]
    13. Simplified46.4%

      \[\leadsto \color{blue}{\sqrt{1 + z} + \left(2 - \sqrt{z}\right)} \]

    if 2.4e13 < z

    1. Initial program 87.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative87.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+87.4%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-67.5%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-53.9%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-53.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified27.3%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 4.0%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.8%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 33.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative33.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified33.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 31.1%

      \[\leadsto \color{blue}{\left(1 + \sqrt{1 + y}\right) - \sqrt{y}} \]
    12. Step-by-step derivation
      1. associate--l+53.8%

        \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} - \sqrt{y}\right)} \]
    13. Simplified53.8%

      \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} - \sqrt{y}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification50.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 24000000000000:\\ \;\;\;\;\sqrt{1 + z} + \left(2 - \sqrt{z}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 84.7% accurate, 3.9× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 26500000000000:\\ \;\;\;\;\left(\sqrt{1 + z} + 2\right) - \sqrt{z}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= z 26500000000000.0)
   (- (+ (sqrt (+ 1.0 z)) 2.0) (sqrt z))
   (+ 1.0 (- (sqrt (+ 1.0 y)) (sqrt y)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 26500000000000.0) {
		tmp = (sqrt((1.0 + z)) + 2.0) - sqrt(z);
	} else {
		tmp = 1.0 + (sqrt((1.0 + y)) - sqrt(y));
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 <= 26500000000000.0d0) then
        tmp = (sqrt((1.0d0 + z)) + 2.0d0) - sqrt(z)
    else
        tmp = 1.0d0 + (sqrt((1.0d0 + y)) - sqrt(y))
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= 26500000000000.0) {
		tmp = (Math.sqrt((1.0 + z)) + 2.0) - Math.sqrt(z);
	} else {
		tmp = 1.0 + (Math.sqrt((1.0 + y)) - Math.sqrt(y));
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if z <= 26500000000000.0:
		tmp = (math.sqrt((1.0 + z)) + 2.0) - math.sqrt(z)
	else:
		tmp = 1.0 + (math.sqrt((1.0 + y)) - math.sqrt(y))
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (z <= 26500000000000.0)
		tmp = Float64(Float64(sqrt(Float64(1.0 + z)) + 2.0) - sqrt(z));
	else
		tmp = Float64(1.0 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y)));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= 26500000000000.0)
		tmp = (sqrt((1.0 + z)) + 2.0) - sqrt(z);
	else
		tmp = 1.0 + (sqrt((1.0 + y)) - sqrt(y));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[z, 26500000000000.0], N[(N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] + 2.0), $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 26500000000000:\\
\;\;\;\;\left(\sqrt{1 + z} + 2\right) - \sqrt{z}\\

\mathbf{else}:\\
\;\;\;\;1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.65e13

    1. Initial program 97.9%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative97.9%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+97.9%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-83.2%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-75.6%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-64.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 18.4%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.8%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in y around 0 27.3%

      \[\leadsto \color{blue}{\left(1 + \left(\sqrt{1 + x} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \sqrt{z}\right)} \]
    9. Step-by-step derivation
      1. associate--l+39.4%

        \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + x} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \sqrt{z}\right)\right)} \]
      2. associate--r+39.3%

        \[\leadsto 1 + \color{blue}{\left(\left(\left(\sqrt{1 + x} + \sqrt{1 + z}\right) - \sqrt{x}\right) - \sqrt{z}\right)} \]
      3. +-commutative39.3%

        \[\leadsto 1 + \left(\left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + x}\right)} - \sqrt{x}\right) - \sqrt{z}\right) \]
      4. associate--l+52.9%

        \[\leadsto 1 + \left(\color{blue}{\left(\sqrt{1 + z} + \left(\sqrt{1 + x} - \sqrt{x}\right)\right)} - \sqrt{z}\right) \]
    10. Simplified52.9%

      \[\leadsto \color{blue}{1 + \left(\left(\sqrt{1 + z} + \left(\sqrt{1 + x} - \sqrt{x}\right)\right) - \sqrt{z}\right)} \]
    11. Taylor expanded in x around 0 46.4%

      \[\leadsto \color{blue}{\left(2 + \sqrt{1 + z}\right) - \sqrt{z}} \]

    if 2.65e13 < z

    1. Initial program 87.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative87.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+87.4%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-67.5%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-53.9%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-53.8%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified27.3%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 4.0%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.8%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.8%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 33.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative33.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified33.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 31.1%

      \[\leadsto \color{blue}{\left(1 + \sqrt{1 + y}\right) - \sqrt{y}} \]
    12. Step-by-step derivation
      1. associate--l+53.8%

        \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} - \sqrt{y}\right)} \]
    13. Simplified53.8%

      \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} - \sqrt{y}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification50.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 26500000000000:\\ \;\;\;\;\left(\sqrt{1 + z} + 2\right) - \sqrt{z}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 62.1% accurate, 3.9× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 2.2:\\ \;\;\;\;\left(2 + x \cdot 0.5\right) - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 2.2) (- (+ 2.0 (* x 0.5)) (sqrt x)) (- (sqrt (+ 1.0 x)) (sqrt x))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.2) {
		tmp = (2.0 + (x * 0.5)) - sqrt(x);
	} else {
		tmp = sqrt((1.0 + x)) - sqrt(x);
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 (y <= 2.2d0) then
        tmp = (2.0d0 + (x * 0.5d0)) - sqrt(x)
    else
        tmp = sqrt((1.0d0 + x)) - sqrt(x)
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.2) {
		tmp = (2.0 + (x * 0.5)) - Math.sqrt(x);
	} else {
		tmp = Math.sqrt((1.0 + x)) - Math.sqrt(x);
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= 2.2:
		tmp = (2.0 + (x * 0.5)) - math.sqrt(x)
	else:
		tmp = math.sqrt((1.0 + x)) - math.sqrt(x)
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 2.2)
		tmp = Float64(Float64(2.0 + Float64(x * 0.5)) - sqrt(x));
	else
		tmp = Float64(sqrt(Float64(1.0 + x)) - sqrt(x));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 2.2)
		tmp = (2.0 + (x * 0.5)) - sqrt(x);
	else
		tmp = sqrt((1.0 + x)) - sqrt(x);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 2.2], N[(N[(2.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2:\\
\;\;\;\;\left(2 + x \cdot 0.5\right) - \sqrt{x}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{1 + x} - \sqrt{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.2000000000000002

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+98.4%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-98.4%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-98.4%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified74.5%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 16.4%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.5%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.5%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.5%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.5%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 24.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative24.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified24.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 23.4%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative23.4%

        \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    13. Simplified23.4%

      \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    14. Taylor expanded in y around 0 22.5%

      \[\leadsto \color{blue}{\left(2 + 0.5 \cdot x\right) - \sqrt{x}} \]

    if 2.2000000000000002 < y

    1. Initial program 84.2%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.2%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.2%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-44.3%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-19.5%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-8.0%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified6.1%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.3%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.2%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.2%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.2%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.3%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.2:\\ \;\;\;\;\left(2 + x \cdot 0.5\right) - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 64.6% accurate, 4.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 + \left(\sqrt{1 + y} - \sqrt{y}\right) \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (+ 1.0 (- (sqrt (+ 1.0 y)) (sqrt y))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 + (sqrt((1.0 + y)) - sqrt(y));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = 1.0d0 + (sqrt((1.0d0 + y)) - sqrt(y))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 + (Math.sqrt((1.0 + y)) - Math.sqrt(y));
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 + (math.sqrt((1.0 + y)) - math.sqrt(y))
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y)))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 + (sqrt((1.0 + y)) - sqrt(y));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(1.0 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 + \left(\sqrt{1 + y} - \sqrt{y}\right)
\end{array}
Derivation
  1. Initial program 92.2%

    \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
  2. Step-by-step derivation
    1. +-commutative92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. associate-+r+92.2%

      \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. associate-+r-74.7%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
    4. associate-+l-63.9%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
    5. associate-+r-58.9%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
  3. Simplified44.6%

    \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in t around inf 10.7%

    \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
  6. Step-by-step derivation
    1. associate--l+21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
    2. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
    3. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
  7. Simplified21.8%

    \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
  8. Taylor expanded in z around inf 23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
  9. Step-by-step derivation
    1. +-commutative23.2%

      \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
  10. Simplified23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
  11. Taylor expanded in x around 0 29.1%

    \[\leadsto \color{blue}{\left(1 + \sqrt{1 + y}\right) - \sqrt{y}} \]
  12. Step-by-step derivation
    1. associate--l+46.1%

      \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} - \sqrt{y}\right)} \]
  13. Simplified46.1%

    \[\leadsto \color{blue}{1 + \left(\sqrt{1 + y} - \sqrt{y}\right)} \]
  14. Final simplification46.1%

    \[\leadsto 1 + \left(\sqrt{1 + y} - \sqrt{y}\right) \]
  15. Add Preprocessing

Alternative 17: 61.5% accurate, 7.3× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 2:\\ \;\;\;\;\left(2 + x \cdot 0.5\right) - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + x \cdot 0.5\right) - \sqrt{x}\\ \end{array} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
 :precision binary64
 (if (<= y 2.0) (- (+ 2.0 (* x 0.5)) (sqrt x)) (- (+ 1.0 (* x 0.5)) (sqrt x))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.0) {
		tmp = (2.0 + (x * 0.5)) - sqrt(x);
	} else {
		tmp = (1.0 + (x * 0.5)) - sqrt(x);
	}
	return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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 (y <= 2.0d0) then
        tmp = (2.0d0 + (x * 0.5d0)) - sqrt(x)
    else
        tmp = (1.0d0 + (x * 0.5d0)) - sqrt(x)
    end if
    code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.0) {
		tmp = (2.0 + (x * 0.5)) - Math.sqrt(x);
	} else {
		tmp = (1.0 + (x * 0.5)) - Math.sqrt(x);
	}
	return tmp;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	tmp = 0
	if y <= 2.0:
		tmp = (2.0 + (x * 0.5)) - math.sqrt(x)
	else:
		tmp = (1.0 + (x * 0.5)) - math.sqrt(x)
	return tmp
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 2.0)
		tmp = Float64(Float64(2.0 + Float64(x * 0.5)) - sqrt(x));
	else
		tmp = Float64(Float64(1.0 + Float64(x * 0.5)) - sqrt(x));
	end
	return tmp
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 2.0)
		tmp = (2.0 + (x * 0.5)) - sqrt(x);
	else
		tmp = (1.0 + (x * 0.5)) - sqrt(x);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := If[LessEqual[y, 2.0], N[(N[(2.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2:\\
\;\;\;\;\left(2 + x \cdot 0.5\right) - \sqrt{x}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot 0.5\right) - \sqrt{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2

    1. Initial program 98.4%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+98.4%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-98.4%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-98.4%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-98.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified74.5%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 16.4%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+21.5%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative21.5%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative21.5%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified21.5%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 24.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative24.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified24.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in x around 0 23.4%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutative23.4%

        \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    13. Simplified23.4%

      \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    14. Taylor expanded in y around 0 22.5%

      \[\leadsto \color{blue}{\left(2 + 0.5 \cdot x\right) - \sqrt{x}} \]

    if 2 < y

    1. Initial program 84.2%

      \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. Step-by-step derivation
      1. +-commutative84.2%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
      2. associate-+r+84.2%

        \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
      3. associate-+r-44.3%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
      4. associate-+l-19.5%

        \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
      5. associate-+r-8.0%

        \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. Simplified6.1%

      \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 3.3%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--l+22.2%

        \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
      2. +-commutative22.2%

        \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
      3. +-commutative22.2%

        \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
    7. Simplified22.2%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
    8. Taylor expanded in z around inf 22.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
    9. Step-by-step derivation
      1. +-commutative22.1%

        \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
    10. Simplified22.1%

      \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
    11. Taylor expanded in y around inf 21.3%

      \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
    12. Taylor expanded in x around 0 22.1%

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} - \sqrt{x} \]
    13. Step-by-step derivation
      1. *-commutative22.1%

        \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
    14. Simplified22.1%

      \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} - \sqrt{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2:\\ \;\;\;\;\left(2 + x \cdot 0.5\right) - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + x \cdot 0.5\right) - \sqrt{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 35.4% accurate, 7.7× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ \left(1 + x \cdot 0.5\right) - \sqrt{x} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (- (+ 1.0 (* x 0.5)) (sqrt x)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return (1.0 + (x * 0.5)) - sqrt(x);
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = (1.0d0 + (x * 0.5d0)) - sqrt(x)
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return (1.0 + (x * 0.5)) - Math.sqrt(x);
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return (1.0 + (x * 0.5)) - math.sqrt(x)
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(Float64(1.0 + Float64(x * 0.5)) - sqrt(x))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = (1.0 + (x * 0.5)) - sqrt(x);
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\left(1 + x \cdot 0.5\right) - \sqrt{x}
\end{array}
Derivation
  1. Initial program 92.2%

    \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
  2. Step-by-step derivation
    1. +-commutative92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. associate-+r+92.2%

      \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. associate-+r-74.7%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
    4. associate-+l-63.9%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
    5. associate-+r-58.9%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
  3. Simplified44.6%

    \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in t around inf 10.7%

    \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
  6. Step-by-step derivation
    1. associate--l+21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
    2. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
    3. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
  7. Simplified21.8%

    \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
  8. Taylor expanded in z around inf 23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
  9. Step-by-step derivation
    1. +-commutative23.2%

      \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
  10. Simplified23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
  11. Taylor expanded in y around inf 15.8%

    \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
  12. Taylor expanded in x around 0 16.6%

    \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} - \sqrt{x} \]
  13. Step-by-step derivation
    1. *-commutative22.8%

      \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
  14. Simplified16.6%

    \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} - \sqrt{x} \]
  15. Final simplification16.6%

    \[\leadsto \left(1 + x \cdot 0.5\right) - \sqrt{x} \]
  16. Add Preprocessing

Alternative 19: 34.8% accurate, 8.0× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ 1 - \sqrt{x} \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (- 1.0 (sqrt x)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return 1.0 - sqrt(x);
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = 1.0d0 - sqrt(x)
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return 1.0 - Math.sqrt(x);
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return 1.0 - math.sqrt(x)
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(1.0 - sqrt(x))
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = 1.0 - sqrt(x);
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(1.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \sqrt{x}
\end{array}
Derivation
  1. Initial program 92.2%

    \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
  2. Step-by-step derivation
    1. +-commutative92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. associate-+r+92.2%

      \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. associate-+r-74.7%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
    4. associate-+l-63.9%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
    5. associate-+r-58.9%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
  3. Simplified44.6%

    \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in t around inf 10.7%

    \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
  6. Step-by-step derivation
    1. associate--l+21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
    2. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
    3. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
  7. Simplified21.8%

    \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
  8. Taylor expanded in z around inf 23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
  9. Step-by-step derivation
    1. +-commutative23.2%

      \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
  10. Simplified23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
  11. Taylor expanded in y around inf 15.8%

    \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}} \]
  12. Taylor expanded in x around 0 14.8%

    \[\leadsto \color{blue}{1} - \sqrt{x} \]
  13. Final simplification14.8%

    \[\leadsto 1 - \sqrt{x} \]
  14. Add Preprocessing

Alternative 20: 4.6% accurate, 274.3× speedup?

\[\begin{array}{l} [x, y, z, t] = \mathsf{sort}([x, y, z, t])\\ \\ x \cdot 0.5 \end{array} \]
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t) :precision binary64 (* x 0.5))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
	return x * 0.5;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this 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
    code = x * 0.5d0
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
	return x * 0.5;
}
[x, y, z, t] = sort([x, y, z, t])
def code(x, y, z, t):
	return x * 0.5
x, y, z, t = sort([x, y, z, t])
function code(x, y, z, t)
	return Float64(x * 0.5)
end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
	tmp = x * 0.5;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
x \cdot 0.5
\end{array}
Derivation
  1. Initial program 92.2%

    \[\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
  2. Step-by-step derivation
    1. +-commutative92.2%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right)\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right) \]
    2. associate-+r+92.2%

      \[\leadsto \color{blue}{\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
    3. associate-+r-74.7%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \sqrt{y}\right)} + \left(\sqrt{t + 1} - \sqrt{t}\right)\right) \]
    4. associate-+l-63.9%

      \[\leadsto \left(\sqrt{z + 1} - \sqrt{z}\right) + \color{blue}{\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)\right)} \]
    5. associate-+r-58.9%

      \[\leadsto \color{blue}{\left(\left(\sqrt{z + 1} - \sqrt{z}\right) + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \sqrt{y + 1}\right)\right) - \left(\sqrt{y} - \left(\sqrt{t + 1} - \sqrt{t}\right)\right)} \]
  3. Simplified44.6%

    \[\leadsto \color{blue}{\sqrt{1 + y} + \left(\left(\sqrt{1 + z} + \left(\left(\sqrt{x + 1} - \sqrt{x}\right) - \sqrt{z}\right)\right) - \left(\sqrt{y} + \left(\sqrt{t} - \sqrt{1 + t}\right)\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in t around inf 10.7%

    \[\leadsto \color{blue}{\left(\sqrt{1 + x} + \left(\sqrt{1 + y} + \sqrt{1 + z}\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)} \]
  6. Step-by-step derivation
    1. associate--l+21.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + y} + \sqrt{1 + z}\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)} \]
    2. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\color{blue}{\left(\sqrt{1 + z} + \sqrt{1 + y}\right)} - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right) \]
    3. +-commutative21.8%

      \[\leadsto \sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \color{blue}{\left(\sqrt{z} + \sqrt{y}\right)}\right)\right) \]
  7. Simplified21.8%

    \[\leadsto \color{blue}{\sqrt{1 + x} + \left(\left(\sqrt{1 + z} + \sqrt{1 + y}\right) - \left(\sqrt{x} + \left(\sqrt{z} + \sqrt{y}\right)\right)\right)} \]
  8. Taylor expanded in z around inf 23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{x} + \sqrt{y}\right)\right)} \]
  9. Step-by-step derivation
    1. +-commutative23.2%

      \[\leadsto \sqrt{1 + x} + \left(\sqrt{1 + y} - \color{blue}{\left(\sqrt{y} + \sqrt{x}\right)}\right) \]
  10. Simplified23.2%

    \[\leadsto \sqrt{1 + x} + \color{blue}{\left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right)} \]
  11. Taylor expanded in x around 0 22.8%

    \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
  12. Step-by-step derivation
    1. *-commutative22.8%

      \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
  13. Simplified22.8%

    \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} + \left(\sqrt{1 + y} - \left(\sqrt{y} + \sqrt{x}\right)\right) \]
  14. Taylor expanded in x around inf 5.2%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  15. Step-by-step derivation
    1. *-commutative5.2%

      \[\leadsto \color{blue}{x \cdot 0.5} \]
  16. Simplified5.2%

    \[\leadsto \color{blue}{x \cdot 0.5} \]
  17. Final simplification5.2%

    \[\leadsto x \cdot 0.5 \]
  18. Add Preprocessing

Developer target: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}} + \frac{1}{\sqrt{y + 1} + \sqrt{y}}\right) + \frac{1}{\sqrt{z + 1} + \sqrt{z}}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+
  (+
   (+
    (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))
    (/ 1.0 (+ (sqrt (+ y 1.0)) (sqrt y))))
   (/ 1.0 (+ (sqrt (+ z 1.0)) (sqrt z))))
  (- (sqrt (+ t 1.0)) (sqrt t))))
double code(double x, double y, double z, double t) {
	return (((1.0 / (sqrt((x + 1.0)) + sqrt(x))) + (1.0 / (sqrt((y + 1.0)) + sqrt(y)))) + (1.0 / (sqrt((z + 1.0)) + sqrt(z)))) + (sqrt((t + 1.0)) - sqrt(t));
}
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 = (((1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))) + (1.0d0 / (sqrt((y + 1.0d0)) + sqrt(y)))) + (1.0d0 / (sqrt((z + 1.0d0)) + sqrt(z)))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
	return (((1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x))) + (1.0 / (Math.sqrt((y + 1.0)) + Math.sqrt(y)))) + (1.0 / (Math.sqrt((z + 1.0)) + Math.sqrt(z)))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
def code(x, y, z, t):
	return (((1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))) + (1.0 / (math.sqrt((y + 1.0)) + math.sqrt(y)))) + (1.0 / (math.sqrt((z + 1.0)) + math.sqrt(z)))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) + Float64(1.0 / Float64(sqrt(Float64(y + 1.0)) + sqrt(y)))) + Float64(1.0 / Float64(sqrt(Float64(z + 1.0)) + sqrt(z)))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t)))
end
function tmp = code(x, y, z, t)
	tmp = (((1.0 / (sqrt((x + 1.0)) + sqrt(x))) + (1.0 / (sqrt((y + 1.0)) + sqrt(y)))) + (1.0 / (sqrt((z + 1.0)) + sqrt(z)))) + (sqrt((t + 1.0)) - sqrt(t));
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}} + \frac{1}{\sqrt{y + 1} + \sqrt{y}}\right) + \frac{1}{\sqrt{z + 1} + \sqrt{z}}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\end{array}

Reproduce

?
herbie shell --seed 2024020 
(FPCore (x y z t)
  :name "Main:z from "
  :precision binary64

  :herbie-target
  (+ (+ (+ (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))) (/ 1.0 (+ (sqrt (+ y 1.0)) (sqrt y)))) (/ 1.0 (+ (sqrt (+ z 1.0)) (sqrt z)))) (- (sqrt (+ t 1.0)) (sqrt t)))

  (+ (+ (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y))) (- (sqrt (+ z 1.0)) (sqrt z))) (- (sqrt (+ t 1.0)) (sqrt t))))