?

Average Error: 0.1 → 0.1
Time: 8.1s
Precision: binary64
Cost: 13312

?

\[0 \leq x \land x \leq 1.79 \cdot 10^{+308}\]
\[\mathsf{log1p}\left(x \cdot \left(1 + \frac{1}{1 + \mathsf{hypot}\left(x, 1\right)}\right)\right) \]
\[\mathsf{log1p}\left(x + \frac{x}{1 + \mathsf{hypot}\left(x, 1\right)}\right) \]
(FPCore (x)
 :precision binary64
 (log1p (* x (+ 1.0 (/ 1.0 (+ 1.0 (hypot x 1.0)))))))
(FPCore (x) :precision binary64 (log1p (+ x (/ x (+ 1.0 (hypot x 1.0))))))
double code(double x) {
	return log1p((x * (1.0 + (1.0 / (1.0 + hypot(x, 1.0))))));
}
double code(double x) {
	return log1p((x + (x / (1.0 + hypot(x, 1.0)))));
}
public static double code(double x) {
	return Math.log1p((x * (1.0 + (1.0 / (1.0 + Math.hypot(x, 1.0))))));
}
public static double code(double x) {
	return Math.log1p((x + (x / (1.0 + Math.hypot(x, 1.0)))));
}
def code(x):
	return math.log1p((x * (1.0 + (1.0 / (1.0 + math.hypot(x, 1.0))))))
def code(x):
	return math.log1p((x + (x / (1.0 + math.hypot(x, 1.0)))))
function code(x)
	return log1p(Float64(x * Float64(1.0 + Float64(1.0 / Float64(1.0 + hypot(x, 1.0))))))
end
function code(x)
	return log1p(Float64(x + Float64(x / Float64(1.0 + hypot(x, 1.0)))))
end
code[x_] := N[Log[1 + N[(x * N[(1.0 + N[(1.0 / N[(1.0 + N[Sqrt[x ^ 2 + 1.0 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Log[1 + N[(x + N[(x / N[(1.0 + N[Sqrt[x ^ 2 + 1.0 ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\mathsf{log1p}\left(x \cdot \left(1 + \frac{1}{1 + \mathsf{hypot}\left(x, 1\right)}\right)\right)
\mathsf{log1p}\left(x + \frac{x}{1 + \mathsf{hypot}\left(x, 1\right)}\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.1

    \[\mathsf{log1p}\left(x \cdot \left(1 + \frac{1}{1 + \mathsf{hypot}\left(x, 1\right)}\right)\right) \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{log1p}\left(x + \frac{x}{1 + \mathsf{hypot}\left(x, 1\right)}\right)} \]
    Proof

    [Start]0.1

    \[ \mathsf{log1p}\left(x \cdot \left(1 + \frac{1}{1 + \mathsf{hypot}\left(x, 1\right)}\right)\right) \]

    distribute-lft-in [=>]0.1

    \[ \mathsf{log1p}\left(\color{blue}{x \cdot 1 + x \cdot \frac{1}{1 + \mathsf{hypot}\left(x, 1\right)}}\right) \]

    *-rgt-identity [=>]0.1

    \[ \mathsf{log1p}\left(\color{blue}{x} + x \cdot \frac{1}{1 + \mathsf{hypot}\left(x, 1\right)}\right) \]

    associate-*r/ [=>]0.1

    \[ \mathsf{log1p}\left(x + \color{blue}{\frac{x \cdot 1}{1 + \mathsf{hypot}\left(x, 1\right)}}\right) \]

    *-rgt-identity [=>]0.1

    \[ \mathsf{log1p}\left(x + \frac{\color{blue}{x}}{1 + \mathsf{hypot}\left(x, 1\right)}\right) \]
  3. Final simplification0.1

    \[\leadsto \mathsf{log1p}\left(x + \frac{x}{1 + \mathsf{hypot}\left(x, 1\right)}\right) \]

Alternatives

Alternative 1
Error0.7
Cost7104
\[\mathsf{log1p}\left(x + \frac{x}{2 + 0.5 \cdot \left(x \cdot x\right)}\right) \]
Alternative 2
Error0.5
Cost6980
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\mathsf{log1p}\left(x \cdot 1.5\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(x + \frac{x}{x + 1}\right)\\ \end{array} \]
Alternative 3
Error0.5
Cost6980
\[\begin{array}{l} \mathbf{if}\;x \leq 0.4:\\ \;\;\;\;\mathsf{fma}\left(1.5, x, x \cdot \left(x \cdot -1.125\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(x + \frac{x}{x + 1}\right)\\ \end{array} \]
Alternative 4
Error0.9
Cost6724
\[\begin{array}{l} \mathbf{if}\;x \leq 3.2:\\ \;\;\;\;\mathsf{log1p}\left(x \cdot 1.5\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(x\right)\\ \end{array} \]
Alternative 5
Error0.6
Cost6724
\[\begin{array}{l} \mathbf{if}\;x \leq 2:\\ \;\;\;\;\mathsf{log1p}\left(x \cdot 1.5\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(x + 1\right)\\ \end{array} \]
Alternative 6
Error0.9
Cost6596
\[\begin{array}{l} \mathbf{if}\;x \leq 1.2:\\ \;\;\;\;x \cdot \left(1.5 + x \cdot -1.125\right)\\ \mathbf{else}:\\ \;\;\;\;\log x\\ \end{array} \]
Alternative 7
Error0.9
Cost6596
\[\begin{array}{l} \mathbf{if}\;x \leq 0.65:\\ \;\;\;\;x \cdot \left(1.5 + x \cdot -1.125\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(x\right)\\ \end{array} \]
Alternative 8
Error31.1
Cost192
\[x \cdot 1.5 \]

Error

Reproduce?

herbie shell --seed 1 
(FPCore (x)
  :name "log1p(x * (1 + 1/(1 + hypot(x, 1))))"
  :precision binary64
  :pre (and (<= 0.0 x) (<= x 1.79e+308))
  (log1p (* x (+ 1.0 (/ 1.0 (+ 1.0 (hypot x 1.0)))))))