## Numerical solution to equations with log?

1. The problem statement, all variables and given/known data
Merry Xmas~ I hope there's still someone online during the holiday season.

I'm trying to solve a set of static laser rate equations but with log in the expression. I think, there's no analytic solution but I don't really know how solve the problem numerically with Matlab. I'd realy appreciate your help since I've been stuck with it for almost a week...Many thanks!!

2. Relevant equations
Variables: Nq1, Nq2, Np (others are known constants)

a1*Nq1 + a2*log(Nq1/No)*Np/(1 + eps*Np) + a3 = 0
b1*Nq2 + b2*log(Nq2/No)*Np/(1 + eps*Np) + b3 = 0
(c1*log(Nq1/No) + c2*log(Nq2/No))*Np/(1 + eps*Np) + c3*Nq1 + c4*Nq2 + c5*Np = 0

3. The attempt at a solution
I have the Symbolic Math Toolbox in Matlab but don't know if it helps at all to this problem.
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

 PhysOrg.com science news on PhysOrg.com >> Hong Kong launches first electric taxis>> Morocco to harness the wind in energy hunt>> Galaxy's Ring of Fire
 Recognitions: Homework Help I believe what you have is a system of nonlinear equations. Click tutorial #2 (Newton Raphson) in my footer and look at page 2.
 Hi Jinfur008 would you please identify the 'eps' operator/function/constant. And I'll have a peek at it. Also, where did you get that user name? It's like, outa star wars.

## Numerical solution to equations with log?

hotvette: Thanks so much for sharing!! I think it is what I'm looking for. :)
arithmetix: eps is a constant. I've never watched star war though...

Follow-up questions:
- I've tried to solve my question with the Newton Raphson method, but I don't know what is the best way to estimate the initial guess. Matlab just got freezed...
(The solution of this problem can vary several orders depends on the constants assigned.)

- Is this Newton Raphson method still suitable for a system with multiple solutions?

Thank you!
and Happy New Year~

Recognitions:
Homework Help
 Quote by jinfur008 Is this Newton Raphson method still suitable for a system with multiple solutions?
The short answer is yes. Different initial guesses can converge on different solutions. However, Newton-Raphson isn't guaranteed to find a solution - it can have problems if the initial guess is too far from a solution or the derivative is zero at the solution. There is no universal trick I know of to get a good initial guess.

If you care to post the values of the constants and your initial guesses, I might be able to figure out where the difficulty is.

 Recognitions: Homework Help Based on the Matlab code sent in your PM, I played around and have the following comments: 1. My guess is that the Matlab code freezes because Nqw1 or Nqw2 become negative, which is illegal because of the log function. You might want to put a check in your code for that. 2. To compensate for (1), try different starting values 3. I was able to solve the problem but it required extra precision to get decent results. Because of the very large numbers involved (1e18 or larger), standard 16-digit doubles just aren't enough. I used a multi-precision add-in for Excel and got nice results with 35 significant digits. 4. Based on different starting points, I was able to obtain two different solutions, one with a negative value for Np, and another with positive values for all three variables. 5. This problem is a great example illustrating the power of Newton's method. Below are 15 iterations using sqrt(F12 + F22 + F32) as an error monitor. The first 6 iterations showed a 2 order of magnitude reduction, the next iteration a 2 order, next a 4 order, next a 7 order, then a whopping 15 order change in a single step before converging. This is typical of Newton's method. It starts out slow when the initial guess is relatively far from the solution, then rapidly converges once it gets close. It's almost like magic. Code:  1 5.977E+29 2 2.004E+29 3 1.118E+29 4 4.862E+28 5 1.334E+28 6 1.411E+27 7 1.855E+25 8 3.281E+21 9 1.030E+14 10 1.037E-1 11 1.640E-6 12 3.662E-6 13 3.662E-6 14 3.662E-6 15 3.662E-6
 This is definitely amazing! Thanks so much for the efforts and pointing out my blind spot! I've actually used some "cheating" method to solve this problem and got similar results (at least on the same order :p) as you did (the all-positive one) at the given conditions. But I really need to build a reliable model in order for future uses. At the point that I'm almost giving up on this route, your reply gives me a lot of confidence. :) I guess it'll take me some time to fix the code and to make some extension in matlab. It really needs some good senses to guess a proper initial value though... Thank you again.
 Recognitions: Homework Help Actually, I believe the Matlab code you already have is perfectly reliable if you add a check for Nqw1 and Nqw2 becoming negative (for example to abort the loop). You should be able to converge on valid solutions. The only trouble is that with standard precision variables, the functions F1, F2, F3 won't get close to zero which could leave doubt that you have a correct solution. The value of using extra precision is to see F1, F2, F3 actually go to zero (within the precision you are using), thereby providing confidence that you have a valid solution. If you really want the extra precision, you can either use the Multi Precison toolbox of Matlab, or the free Excel add-in I used (called XNUMBERS): http://digilander.libero.it/foxes/SoftwareDownload.htm Regarding starting values, I did a number of experiments and found that with this problem, you can converge on the solution you want using almost any starting value between 1 and 1E18. If you don't get the solution you want, try again with different starting values. The problem is v-e-r-y forgiving from the standpoint of initial guesses. It almost doesn't matter what you use. To illustrate the difference between standard precision and extended precision, below are values I obtained for one of the variables: Code: 1132942825983176453.2730013071224621 <== extended precision 1132942825983180000 <== standard precision It is pretty clear the value obtained using standard precision is correct. Overall, this problem isn't nearly as difficult as it first appears to be.

 Tags coupled equations, laser, log, matlab, numerical