?

Average Error: 40.6 → 0.3
Time: 4.8s
Precision: binary64
Cost: 20164

?

\[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -0.00095:\\ \;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 \cdot {x}^{2} + \left(2 + \left(x + 0.16666666666666666 \cdot {x}^{3}\right)\right)}\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))
(FPCore (x)
 :precision binary64
 (if (<= x -0.00095)
   (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0)))
   (sqrt
    (+
     (* 0.5 (pow x 2.0))
     (+ 2.0 (+ x (* 0.16666666666666666 (pow x 3.0))))))))
double code(double x) {
	return sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
}
double code(double x) {
	double tmp;
	if (x <= -0.00095) {
		tmp = sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
	} else {
		tmp = sqrt(((0.5 * pow(x, 2.0)) + (2.0 + (x + (0.16666666666666666 * pow(x, 3.0))))));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt(((exp((2.0d0 * x)) - 1.0d0) / (exp(x) - 1.0d0)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-0.00095d0)) then
        tmp = sqrt(((exp((2.0d0 * x)) - 1.0d0) / (exp(x) - 1.0d0)))
    else
        tmp = sqrt(((0.5d0 * (x ** 2.0d0)) + (2.0d0 + (x + (0.16666666666666666d0 * (x ** 3.0d0))))))
    end if
    code = tmp
end function
public static double code(double x) {
	return Math.sqrt(((Math.exp((2.0 * x)) - 1.0) / (Math.exp(x) - 1.0)));
}
public static double code(double x) {
	double tmp;
	if (x <= -0.00095) {
		tmp = Math.sqrt(((Math.exp((2.0 * x)) - 1.0) / (Math.exp(x) - 1.0)));
	} else {
		tmp = Math.sqrt(((0.5 * Math.pow(x, 2.0)) + (2.0 + (x + (0.16666666666666666 * Math.pow(x, 3.0))))));
	}
	return tmp;
}
def code(x):
	return math.sqrt(((math.exp((2.0 * x)) - 1.0) / (math.exp(x) - 1.0)))
def code(x):
	tmp = 0
	if x <= -0.00095:
		tmp = math.sqrt(((math.exp((2.0 * x)) - 1.0) / (math.exp(x) - 1.0)))
	else:
		tmp = math.sqrt(((0.5 * math.pow(x, 2.0)) + (2.0 + (x + (0.16666666666666666 * math.pow(x, 3.0))))))
	return tmp
function code(x)
	return sqrt(Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)))
end
function code(x)
	tmp = 0.0
	if (x <= -0.00095)
		tmp = sqrt(Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)));
	else
		tmp = sqrt(Float64(Float64(0.5 * (x ^ 2.0)) + Float64(2.0 + Float64(x + Float64(0.16666666666666666 * (x ^ 3.0))))));
	end
	return tmp
end
function tmp = code(x)
	tmp = sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -0.00095)
		tmp = sqrt(((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)));
	else
		tmp = sqrt(((0.5 * (x ^ 2.0)) + (2.0 + (x + (0.16666666666666666 * (x ^ 3.0))))));
	end
	tmp_2 = tmp;
end
code[x_] := N[Sqrt[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := If[LessEqual[x, -0.00095], N[Sqrt[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[(N[(0.5 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 + N[(x + N[(0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\begin{array}{l}
\mathbf{if}\;x \leq -0.00095:\\
\;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{0.5 \cdot {x}^{2} + \left(2 + \left(x + 0.16666666666666666 \cdot {x}^{3}\right)\right)}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if x < -9.49999999999999998e-4

    1. Initial program 0.0

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]

    if -9.49999999999999998e-4 < x

    1. Initial program 61.6

      \[\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}} \]
    2. Taylor expanded in x around 0 0.4

      \[\leadsto \sqrt{\color{blue}{0.16666666666666666 \cdot {x}^{3} + \left(2 + \left(0.5 \cdot {x}^{2} + x\right)\right)}} \]
    3. Simplified0.4

      \[\leadsto \sqrt{\color{blue}{0.5 \cdot {x}^{2} + \left(2 + \left(x + 0.16666666666666666 \cdot {x}^{3}\right)\right)}} \]
      Proof

      [Start]0.4

      \[ \sqrt{0.16666666666666666 \cdot {x}^{3} + \left(2 + \left(0.5 \cdot {x}^{2} + x\right)\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4

      \[ \sqrt{\color{blue}{2 + \left(0.16666666666666666 \cdot {x}^{3} + \left(0.5 \cdot {x}^{2} + x\right)\right)}} \]

      rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4

      \[ \sqrt{2 + \color{blue}{\left(0.5 \cdot {x}^{2} + \left(0.16666666666666666 \cdot {x}^{3} + x\right)\right)}} \]

      rational_best_oopsla_all_46_json_45_simplify-82 [=>]0.4

      \[ \sqrt{\color{blue}{0.5 \cdot {x}^{2} + \left(2 + \left(0.16666666666666666 \cdot {x}^{3} + x\right)\right)}} \]

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.4

      \[ \sqrt{0.5 \cdot {x}^{2} + \left(2 + \color{blue}{\left(x + 0.16666666666666666 \cdot {x}^{3}\right)}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.00095:\\ \;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 \cdot {x}^{2} + \left(2 + \left(x + 0.16666666666666666 \cdot {x}^{3}\right)\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error0.3
Cost19908
\[\begin{array}{l} \mathbf{if}\;x \leq -0.000102:\\ \;\;\;\;\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{0.5 \cdot {x}^{2} + \left(x + 2\right)}\\ \end{array} \]
Alternative 2
Error18.1
Cost6464
\[\sqrt{2} \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x)
  :name "sqrtexp (problem 3.4.4)"
  :precision binary64
  (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))