MATLAB: Am I getting unexpected values

numerical unexpected value

Hi, I'm using r2014a to try to solve the following for N:
syms N
for n = 1:5
Nt1= vpasolve(log(((2*n*(2*N+2*n-1))^n)*8.149e27) - N == 0)
end
It returns values far lower than expected (-0.49999 for n=1). However, if I make this small modification:
syms N
for n = 1:5
Nt1= vpasolve(log(((2*n*(2*N+2*n))^n)*8.149e27) - N == 0)
end
The I retrieve values that I would expect, eg 70 for n=1. Clearly the -1 is doing something I'm missing, but I don't know why it's changing the output or how to fix it. I'm sure the answer is very simple.
Thanks.

Best Answer

syms N
for n = 1:5
Nt1= vpasolve(log(((2*n*(2*N+2*n-1))^n)*8.149e27) - N == 0, N, [0 inf]);
end
There are two solutions in the reals. The general solution is
-LambertW(k, -(1/4)*exp(-(1/2)*(2*ln(8149000000000000000000000000)+2*n-1)/n)/n^2)*n-n+1/2
where k is the branch. The two branches with real solutions are k = -1 (which gives the value range you are expecting) and k = 0 (which gives the range in the small negative values).
Related Question