I'm trying to numerically solve a equation like $$\exp(-A/x) + \exp(-B/x) = 1$$
there are two known lists of parameters $A=(A_1,A_2,...,A_n)$ and $B=(B_1,B_2,...,B_n)$,
I hope to find a list of $x=(x_1,x_2,...,x_n)$ for each $x_i$ relate to $(A_i,B_i)$, like this:
$$\exp(-A_i/x_i) + \exp(-B_i/x_i) = 1$$
I tried "vpasolve" which can not work with matrix parameters:
syms x;
eqn = exp(-pi$*$A/x) + exp(-pi$*$B/x) == 1;
sol = vpasolve(eqn,x)
syms x;
eqn = exp(-pi$*$A./x) + exp(-pi$*$B./x) == 1;
sol = vpasolve(eqn,x)
syms x;
x = zeros(size(A));
eqn = exp(-pi$*$A./x) + exp(-pi$*$B./x) == 1;
sol = vpasolve(eqn,x)
I've tried those ways, and all of them return an error.
although, the one-by-one for loop is working;
syms x;
for i=1:1:length(A)eqn = exp(-pi$*$A(i)/x) + exp(-pi$*$B(i)/x) == 1;
sol = vpasolve(eqn,x);end
and as Claude Leibovici suggested, by replace $y=1/x$ can make it 15~20% faster:
syms x;
S = zeros(length(A),1);
for i=1:1:length(A)eqn = exp(-pi$*$A(i)$*$x) + exp(-pi$*$B(i)$*$x) == 1;
sol = vpasolve(eqn,x);
S(i) = 1/sol(1);end
but it will take several hours to solve one group of parameters
Is there any method to solve it faster?
ps, like something solved as a matrix.
find this parallel for-loop, and it can run with 8/8 CPU cores at 100% occupation now. it saves a lot of time. still not sure if the "vpasolve" can work with lists A,B and x.
syms x;
S = zeros(length(A),1);
parfor i=1:length(A)eqn = exp(-pi$*$A(i)$*$x) + exp(-pi$*$B(i)$*$x) == 1;
sol = vpasolve(eqn,x);
S(i) = 1/sol(1);end

If the problem is to find the zero of function $$f(x)=e^{-\frac{A}{x}}+e^{-\frac{B}{x}}-1$$ more than likely vpasolve faces a problem of initial estimate.
Assuming that there is a solution (read @Lutz Lehmann's comment), first, let $x=\frac 1 y$ and now, try to solve $$g(y)=e^{-A y}+e^{-B y}-1$$ which is bounded by $\left(2e^{-A y}-1\right)$ and $\left(2e^{-B y}-1\right)$ which gives that the solution is somewhere between $a=\frac{\log (2)}{A}$ and $b=\frac{\log (2)}{B}$.
This means that the solution for $x$ is somewhere between $\frac A{\log (2)}$ and $\frac B{\log (2)}$
Just use the initial parameter somewhere in this range and no problem.
Edit
As I wrote in comments, solving for $y$ is probaly better. We have $$g(0)=1 \qquad\qquad g'(0)=-(A+B)\qquad\qquad g''(0)=A^2+B^2$$ So, by Darboux theorem, Newton method should converge without any overshoot of the solution.
Starting with $y_0=0$, the second iterate of Newton method is $$y_2=\frac{1}{A+B}+\frac{e \left(e^{-\frac{A}{A+B}}+e^{-\frac{B}{A+B}}-1\right)}{A e^{\frac{B}{A+B}}+B e^{\frac{A}{A+B}}}$$
Trying for $A=2$ and $B=3$, this gives $y_2=0.27336$ while the solution is $y=0.28120$.
Update (after @Lutz Lehmann's answer)
Suppose that we look instead for the zero of function $$h(y)=\log \left(e^{-A y}+e^{-B y}\right)$$ Using Newton method, we have $$y_0=0 \implies y_1=\frac{2 \log (2)}{A+B}\implies$$ $$ y_2=\frac{2 \log (2)}{A+B}+\frac{\left(2^{-\frac{2 A}{A+B}}+2^{-\frac{2 B}{A+B}}\right) \log \left(2^{-\frac{2 A}{A+B}}+2^{-\frac{2 B}{A+B}}\right)}{ 2^{-\frac{2 A}{A+B}}\, A+ 2^{-\frac{2 B}{A+B}}\,B}$$ Applied to the worked case $y_2=0.281199$ while the solution is $0.281200$.
Simpler, nicer and almost as accurate is the first iterate of Householder method $$y=\frac{ \log(2)}{A+B}\,\, \frac{2 k-\log (2)}{k-\log (2)}\qquad \text{where} \quad k=\left(\frac{A+B}{A-B}\right)^2$$ which, for the worked case, gives $0.281212$.
Another solution is the expand as a Taylor series $h(y)$ and use series reversion to obtain $$y=t+\frac{ (A-B)^2}{4 (A+B)}t^2+\frac{ (A-B)^4}{8 (A+B)^2}t^3+\frac{(A-B)^4 \left(13 A^2-34 A B+13 B^2\right)}{192 (A+B)^3}t^4+O\left(t^5\right)$$ where $t=\frac{2 \log(2)}{A+B}$.
For the worked example, this would give $y=0.2812004$ to be compared to the exact $y=0.2811996$.