Numerical solution to equations with log?

• jinfur008
In summary, the person is trying to solve a set of static laser rate equations but with log in the expression. They are having trouble with the problem and need help. They have tried different methods and found that Newton-Raphson is still suitable for a system with multiple solutions. Based on different starting points, they were able to obtain two different solutions.
jinfur008

Homework Statement

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 really appreciate your help since I've been stuck with it for almost a week...Many thanks!

Homework 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

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.

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.

Last edited:
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~

jinfur008 said:
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.

Last edited:
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

Last edited:
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.

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):

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.

Last edited:

1. What is a numerical solution to equations with log?

A numerical solution to equations with log is a method of finding the approximate value of a solution to an equation that involves logarithms. It involves using numerical techniques to solve the equation, rather than solving it algebraically.

2. Why is a numerical solution sometimes necessary for equations with log?

Equations with log can often be complex and difficult to solve algebraically, especially when they involve multiple variables. In these cases, a numerical solution may be the only feasible way to find an approximate solution.

3. What are some common numerical methods for solving equations with log?

Some common numerical methods for solving equations with log include the bisection method, Newton's method, and the secant method. These methods involve iterative processes of guessing a solution and then refining it until a satisfactory level of accuracy is achieved.

4. How accurate are numerical solutions to equations with log?

The accuracy of a numerical solution to an equation with log depends on the chosen method and the number of iterations used. In general, these solutions are accurate to a certain level, but may not be exact due to the iterative nature of the process.

5. Are there any limitations to using numerical solutions for equations with log?

One limitation of numerical solutions for equations with log is that they may not always converge to a solution. This can happen if the initial guess is too far from the actual solution or if the equation has multiple solutions. Additionally, these methods may be computationally intensive and time-consuming for complex equations.

• Differential Equations
Replies
5
Views
2K
• Calculus and Beyond Homework Help
Replies
24
Views
2K
• Cosmology
Replies
2
Views
450
• Programming and Computer Science
Replies
4
Views
4K
• Other Physics Topics
Replies
1
Views
2K
• Engineering and Comp Sci Homework Help
Replies
7
Views
924
• Calculus and Beyond Homework Help
Replies
1
Views
1K
• Calculus and Beyond Homework Help
Replies
2
Views
3K
• Differential Equations
Replies
5
Views
1K
• Calculus and Beyond Homework Help
Replies
7
Views
2K