Can you charge two devices with only one power socket? I am sitting in a library with a laptop and a phone, and only one power socket. I wondered if eventually one of the devices will necessarily run out of power. By doing some math I figured out an answer to this question, but I feel like there should be a simpler explanation for it.
Call $a_1$ the charge speed of device $1$, $b_1$ its energy consumption speed, and similarly $a_2, b_2$ for device $2$. Assume $a_i \geq b_i$. Charging a device corresponds to translating the battery level $(x_1, x_2)^T$ by a positive multiple of one of the charging vectors
$$c_1 = \begin{pmatrix} a_1 - b_1 \\ - b_2 \end{pmatrix}, \qquad c_2 = \begin{pmatrix} - b_1 \\ a_2 - b_2 \end{pmatrix}$$
Mathematically, the question is under what condition the positive cone spanned by these vectors contains a vector $(x_1, x_2)^T$ with $x_1, x_2 \geq 0$. This guarantees that none of the devices will run out of battery. If in addition $x_1, x_2 > 0$, I can assure they will be both fully charged over time.
                                 
With the angles $\theta_1, \theta_2$ defined as in the image, the question is equivalent to $\theta_1 + \theta_2 \leq \frac \pi 2$, or also $\cos(\theta_1 + \theta_2) \geq 0$. By using the sum formula for $\cos$ and computing some inner products, this gives an inequality in the $a_i$ and $b_i$, which simplifies tremendously to
$$\left( \frac{a_1}{b_1} - 1 \right) \left(\frac{a_2}{b_2} - 1 \right) \geq 1 \,.$$
Note that both factors in the left hand side are nonnegative, because $a_i \geq b_i$.
Is there a more intuitive explanation why this simple inequality is the answer? What happens if I bring a third device to the library?
 A: Others have addressed the electrical issues, I'm just commenting on the geometry. The question is, for $a_1$, $a_2$, $b_1$, $b_2$ positive, why is it true that the positive quadrant is in the positive span of $\begin{bmatrix} a_1 - b_1 \\ -b_2 \end{bmatrix}$, $\begin{bmatrix} - b_1 \\ a_2-b_2 \end{bmatrix}$ if and only if $(a_1/b_1 - 1) (a_2/b_2 - 1) \geq 1$.
Looking at the picture you have drawn, and assuming the vectors lie in the orthants shown, the positive quadrant is in the positive span of these vectors if and only if the angle from $\vec{c}_1$ to $\vec{c}_2$ is counterclockwise. You can compute this by computing the sign of the determinant
$$\det \begin{bmatrix} a_1 - b_1 & -b_1 \\ -b_2 & a_2 - b_2 \\ \end{bmatrix} = (a_1 - b_1)(a_2 - b_2) - b_1 b_2.$$
So you can charge your laptop if
$$(a_1 - b_1)(a_2 - b_2) - b_1 b_2 \geq 0,$$
which is equivalent to your condition.
A: Instead of speed, it may be simpler to consider time. Your devices will have working times $t_1$ and $t_2$ before going out of power, when you sit down in the library. And assume that a charging time $t$ will give them extra working times $k_1t$ and $k_2t$, where $k_1$, $k_2$ are some positive constants (it is not difficult to show that $k_i=a_i/b_i-1$, using your notations).
You then plug device $1$ to the power socket and charge it for a time $t_2$, until device $2$ goes out of power. At that point, device $1$ has working time $t_0=t_1+k_1t_2$ and device $2$ has working time $0$.
Now you can switch devices and plug device $2$ to the power socket, charging it for a time $t_0$, until device $1$ goes out of power. At that point, device $2$ has working time $k_2t_0$ and device $1$ has working time $0$.
Switch again for a time $k_2t_0$, until device $1$ has working time $k_1k_2t_0$ and device $1$ has working time $0$, and so on. Switching times form then a sequence:
$$
t_0,\ \ k_2t_0,\ \ (k_1k_2)t_0,\ \ (k_1k_2)k_2t_0,\ \ (k_1k_2)^2t_0, 
\ \ (k_1k_2)^2k_2t_0, \dots  
$$
It is clear that if $k_1k_2<1$ then the time between successive switchings quickly tends to $0$ and the situation becomes unmanageable. Hence the scheme works only if
$$
k_1k_2\ge1,
$$
which is exactly the equation you got.
For three or more devices one could argue in a similar way, with the added complication that low charge devices will need switching more frequently than the others.
EDIT.
Even the case of three devices seems to be quite difficult to analyse. I ran a simulation with Mathematica, assuming $k_1=k_2=k_3=1.5$ and initial values $t_1=0$, $t_2=1$, $t_3=2$; here's a plot of the resulting working times after each switch:

As you can see, even in this (apparently favourable) case working times eventually drop to $0$.
EDIT 2.
I ran some other simulations, with $n=3$ and $n=4$ devices having the same value of $k$. They confirm the result given by Andy Newton, which in these particular cases becomes $k\ge n-1$.
A: Any one device needs to be plugged into the charging point for some minimum proportion $P$ of any extended period of time $T$. The device is also unplugged for the proportion of time $(1-P)$. Total battery charge must not reduce over extended time periods of charging and discharging cycles.
An algebraic version of that statement is,
$PT(a-b)-(1-P)Tb$ must be greater than zero.
That expression simplifies to give
$$P\ge \dfrac{b}{a}\space\space\space\space(1)$$
The same requirement, for a share of time on the charging point, applies to each device. Index the devices with subscripts $1, 2, 3, ...$.
Rewrite $(1)$ as a sum over all devices.
The sum of $\dfrac{b_i}{a_i}$ over all $i$ must be less than or equal to the sum of $P_i$ over all $i$.
But time sharing is strictly limited! The sum of $P_i$ over all $i$ cannot be greater than $1$.
So
$$\sum_i\dfrac{b_i}{a_i}\le1\space\space\space(2)$$
In the special case of just two devices that condition can be written as
$\frac{b_1}{a_1} + \frac{b_2}{a_2}\le1$.
Algebraic manipulation will show that the condition above is equivalent to the alternative statement
$$\left(\dfrac{a_1}{b_1}-1\right)\left(\dfrac{a_2}{b_2}-1\right)\ge1$$
A: Isn’t it obvious that if each battery charges at a rate superior to its depletion then the inequality is sufficient to be $>0$?
Isn’t it obvious that if one battery receives charge under its depletion rate then the inequality becomes $<0$?
The inequality you propose:$$\prod_i{\frac{a_i}{b_i}-1}\ge1\Rightarrow a_i\ge2b_i$$ means that each device must charge at its discharge rate while some devices charge at double or more of discharge rate. This is not correct, since you only need each device to charge at its discharge rate in order to maintain charge forever.
If you want to solve a vector problem then please define it accordingly. Otherwise the word problem has nothing to do with the solution you proposed.
This is an electrical problem.
In short:

*

*Charging the phone via laptop would always ensure the phone charges first while the laptop only gets the leftovers. Considering the phone in standby and the laptop in use, the laptop battery would be depleted for the time the phone charges, unless the charger is sufficiently powerful to cover the phone charging and the laptop charging while in use. Get a battery charger large enough.

*Charging both devices in parallel from the same charger would give focus to the battery with lower state of charge in the first part then to the laptop battery-the largest absorption capacity further on. The phone is at risk of waiting too long for the laptop to fully charge before it gets its chance to charge.

Conclusion: charge the phone via the laptop. In this case the phone charges normally. Use a laptop charger able to provide for laptop charging while in use plus phone charging.
Note: using the regular laptop charger will keep the phone charged while extending the laptop uptime.
I have considered that each battery state of health is close to 100%. That is he only math needed in this answer.
A: Edit: the strategy below incorrectly uses the full charging speed $a_i$ instead of $a_i-b_i$. My bad...
I think we can do better. We assume 2 devices here, load level is $L_i$ which starts at 1 for both devices. Let both discharge until the fastest discharger, say $i=1$ is at $L_1=\frac{1}{2}$. We then have:
$$L_1=\frac{1}{2}\\
L_2=1-x, x<\frac{1}{2}$$
Then we start charging device 1 to $L_1=1$. That goes faster than decharging, so device 2 decharges further less than $x$ and we end up with
$$L_1=1\\
L_2>1-2x$$
Now we decharge device 1 again to $L_1=\frac{1}{2}$ and device 2 is charged. Because device 2 decharged by $x$ during the first cycle, we can assume that it now charges by more than $x$ during the same time. So we end up with
$$L_1=\frac{1}{2}\\
L_2>1-x$$
which is a better situation than after the first initial decharge period. Conclusion: you only need the fact that both devices individually charge faster than that they decharge, $(a_1-b_1)>0$ and $(a_2-b_2)>0$.
