Bug moving on number line in random directions A bug at the origin moves on the number line either left or right $u$ units every second, where $u$ is am arbitrary real between -1 and 1. For example, the bug could go from 0 to -0.4 in one second, then -0.4 to 0.3 in the next second, etc.. How long (in seconds) do you expect the bug to take before it is more than or at least a distance 1 from the origin (i.e. its position is less than or equal -1 or greater than equal to 1)?
EDIT #1: I tried representing the expected value as a function of the position it is currently at, but couldn't get any further
EDIT #2: I ran a computer simulation for about 100 million trials and got an answer of around $5.36457$, similar to @DreiCleaner .
@Mike Earnest had a promising approach expanding on my [EDIT #1].
His appraoch:
Let $f(x)$ be the expected value of remaining steps if you are currently at position $x$. Then it can be shown that $f(x)=1+\frac12\int_{\max(x-1,-1)}^{\min(x+1,1)} f(t)\,dt$.
I do not see why this is true yet.
 A: OK, here is what I have so far; I think this leads to a solution, but there is just some messy algebra near the end that I cannot bring myself to attempt.
As I mentioned in my comment, and you stated in your post, letting $f(x)$ be the expected number of steps starting, then for $x>0$, we have
$$
f(x)=1+\frac12\int_{x-1}^1f(t)\,dt\tag{1}
$$
Differentiating both sides with respect to $x$, you get
$$
f'(x)=-\frac12f(x-1)=-\frac12 f(1-x)\tag2
$$
where the last step follows since $f$ is an even function. Differentiating $(2)$ again, you get $f''(x)=\frac12f'(1-x)$, which combined with $(2)$ shows that
$$
f''(x)=-\frac14 f(x),\qquad 0<x<1\tag3
$$
Now, $(3)$ implies that
$$
f(x)=A\cos(x/2)+B\sin(x/2),\qquad 0<x<1
$$
for some constants $A$ and $B$. Note that this expression is only valid on the positive half of the domain, $0<x<1$. To extend this to the entire domain, you would use the fact that $f$ is even to write
$$
f(x)=A\cos(x/2)+B\sin (|x|/2)\tag 4
$$
All that remains is to determine the constants $A$ and $B$. This should be doable by substituting $(4)$ into $(1)$.
A: I think Mike Earnest has already made a great answer, so I'll just finish up the tedious bits of finding the constants $A$ and $B$ of their answer, and I'll use their notation. I just plug in $f(x) = A\cos(x/2) + B\sin(|x|/2)$ into the integral equation
$$
f(x) = 1+\frac12 \int_{\max\{x-1, -1\}}^{\min\{x+1, 1\}} f(t) dt
$$
with my two favourite values of $x\in[-1,1]$, as long as they're not $\pm$ the same value because of the symmetry. Let's do $x=0$ and $x=1$ (or rather, we can take the limit as $x\to 1^-$). This gives the equations
$$
A = 1 + 2 A \sin(1/2) - 2B\cos(1/2) + 2B
$$
$$
A\cos(1/2) + B\sin(1/2) = 1 + B + A\sin(1/2) - B\cos(1/2)
$$
which are just linear equations in $A$ and $B$. The solution is:
$$
A = \frac{\sin(\frac12) - \cos(\frac12) + 1}{\sin(\frac12) + 3\cos(\frac12) - 3}
= 1 + \frac{4}{\cot(\frac14) - 3}
\approx 5.365299791
$$
$$
B = \frac{-\sin(\frac12) - \cos(\frac12) + 1}{\sin(\frac12) + 3\cos(\frac12) - 3}
= -1 - \frac{2}{\cot(\frac14) - 3}
\approx -3.182649895
$$
In particular,
$$
f(0) = A \approx 5.365300
$$
which matches the simulations :-)
For completion, below is the graph of $f$. I note the non-smoothness at the origin. Also the limit at $x\to \pm1$ might be of interest; it turns out to be
$$
A\cos(1/2) + B\sin(1/2) = 1+ \frac{2}{\cot(\frac14) - 3} \approx 3.182649894
$$
which apparently is just $-B$! I'm sure that makes sense somehow.

