Register to reply 
Numerical solution to equations with log? 
Share this thread: 
#1
Dec2409, 08:41 PM

P: 3

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 


#2
Dec2509, 01:53 AM

HW Helper
P: 925

I believe what you have is a system of nonlinear equations. Click tutorial #2 (Newton Raphson) in my footer and look at page 2.



#3
Dec2509, 02:55 AM

P: 86

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. 


#4
Jan310, 07:30 PM

P: 3

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... Followup 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~ 


#5
Jan410, 11:29 PM

HW Helper
P: 925

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. 


#6
Jan2610, 01:01 AM

HW Helper
P: 925

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 16digit doubles just aren't enough. I used a multiprecision addin 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(F1^{2} + F2^{2} + F3^{2}) 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.



#7
Jan2710, 07:19 PM

P: 3

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 allpositive 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. 


#8
Jan2810, 11:41 PM

HW Helper
P: 925

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 addin 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 very 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:



Register to reply 
Related Discussions  
Blasius numerical solution?  Differential Equations  3  
Laplace numerical solution  Calculus & Beyond Homework  0  
Numerical Solution to 2nd Order Eqn?  Differential Equations  6  
Numerical solution of 2nd order ODE  Calculus & Beyond Homework  3 