Lots of positive exponentials leading to huge exponents

In summary, the conversation discusses issues with coding an equation for a scattering rate in Fortran 95. The equation involves exponentials with large values, causing overflow errors due to the limited range of double precision numbers. Attempts to simplify the equation by taking logarithms and scaling the numbers have not been successful. A solution is proposed to approximate the terms with large exponentials to prevent overflow errors. The conversation also touches on the use of "deca-nanometers" as a term for dimensions in the range of tens of nanometers.
  • #1
ewant
8
0
Hello there,

This is my first post on this forum so bear with me if I don't know the rules or I am posting in the wrong area.

I am coding up an of equation for a scattering rate which involve quite a few positive (and a couple of negative) exponentials which often have terms that go into hundreds leading to results that have huge exponents. I originally wrote up this scattering rate in Mathematica and it didn't complain, but when I looked in detail at the equation some terms were reaching exponents of over a 1000!

I am writing the scattering rate in Fortran 95 for a simulator and this is where my problems occur. In Fortan95 I can use double precision numbers which have a max. exponent range of 10^+/-308 and I am overflowing. I am currently using the atomic unit system which should help as it normalizes a lot of the units to 1. The equation itself should produce a value between 0 and 1.

I have tried splitting up the equation into components, then taking the natural logarithm to try and simplify the problem but this has not helped. I started to think about trying to scale the numbers I am using in a manner similar to changing unit system, but I don't have any notes/references on where to start.

Any help/ideas on this would be a great help, thanks.
 
Mathematics news on Phys.org
  • #2
What does the equation look like?
 
  • #3
Have not had much experience with Latex typesetting but here goes:

[tex]
\begin{multline*}
f_{dbl}(\Theta)= \frac{ \exp^{-2(L_c+Z_i)A_Q(\Theta)} } { (\exp^{ 2L_c A_Q(\Theta) } - 1)^2 } \\
\{
E_C(\Theta)^2 + E_D(\Theta)^2 +E_S(\Theta)^2 \\
+ 2 E_C(\Theta) ( E_D(\Theta) \cos{ (Q_Z(\Theta) L_c) } - E_S(\Theta) \cos{ (Q_Z(\Theta) Z_i) } ) \\
- 2 E_D(\Theta) E_S(\Theta) \cos{ ( Q_Z(\Theta) (L_c - Z_i) ) }
\}
\end{multline*}
[/tex]

where
[tex]
E_C(\Theta)= \exp^{(L_c + 2Z_i) A_Q(\Theta)} ( \exp^{2(L_c - Z_i) A_Q(\Theta)} - 1)
[/tex]
[tex]
E_D(\Theta)= \exp^{2 L_c A_Q(\Theta)} ( \exp^{2 Z_i A_Q(\Theta)} - 1)
[/tex]
[tex]
E_S(\Theta)= \exp^{(L_c + Z_i) A_Q(\Theta)} ( \exp^{2 L_c A_Q(\Theta)} - 1)
[/tex]
[tex]
A_Q(\Theta)= \sqrt{k^2 \sin^2(\theta) + k_c^2}
[/tex]
[tex]
Q_Z(\Theta)= k(1-\cos(\Theta))
[/tex]

- The function [itex]f_{dbl}[/itex] should return a value between 0 and 1.
- [itex]Z_i[/itex] and [itex]L_c[/itex] are in metres and roughly within deca-nanometre dimension.
- [itex]k , k_c[/itex] are in inverse metre dimensions and can vary from [itex]10^6[/itex] to [itex]10^9[/itex]

I am guessing that whoever asked me to give this equation may be regretting it now! Still I have a had a thorough crash course in latex! I seem to be having a problem with getting the linebreaks to work, but I guess you can copy the code from the pop-up window!

edit:: I have tried to fix the latex src for the main equation, but I can't seem to find the error. Worked OK in the preview message window, so I am at a loss.
 
Last edited:
  • #4
Ha harr, got it to work after all! :)
 
  • #5
What's a deca-nanometer? Do you mean they vary in range from decameters to nanometers (i.e., 10^1 down to 10^-9)? Or did you mean decimeters (10^-1 to 10^-9)? Or did you mean tens of nanometers (10^-8 to 10^-9)?

One thing that might help is this: For very large x,

[tex](e^x - 1) \approx e^x[/tex]

So, first find some x that that puts this approximation within the acceptable bounds of error. For example,

[tex]\frac{e^{10} - (e^{10} - 1)}{e^{10} - 1} = 0.0000454[/tex]

So that's already quite accurate. If you chose x = 100, the error is less than 10^-43. It seems some cutoff between 10 and 100 is good.

Once you choose a cutoff, do this: For all values of x less than the cutoff, calculate the formula as written. For x greater, simplify the formula by substituting e^x for (e^x - 1). Then you can simplify the exponents in the numerator and denominator to get them within an acceptable range, before actually calculating exp(*).

That ought to do it.
 
  • #6
Yeah, I am not surprised you haven't heard of the 'deca-nanometre' term, it is one of these fancy buzz words used to make a particular dimension sound more interesting than it actually is! It is used to denote dimensions of tens of nanometres, so the 10^-8 to 10^-9 range.

Thanks for the suggestion of approximating the (e^x - 1) terms, that might really do the trick. I will give it a try and get back to you.
 
  • #7
Ben Niehoff said:
So, first find some x that that puts this approximation within the acceptable bounds of error. For example,

[tex]\frac{e^{10} - (e^{10} - 1)}{e^{10} - 1} = 0.0000454[/tex]

So that's already quite accurate. If you chose x = 100, the error is less than 10^-43. It seems some cutoff between 10 and 100 is good.

If you're working in IEEE double-precision (as evidenced by the "10^+/-308" in the original post), e^x - 1 = e^x for x greater than roughly [itex]53\ln2\approx36.7.[/itex]
 
  • #8
Thanks for the help, that has solved the problem. I am now able to calculate the function without it overflowing and under-flowing all over the place!
 

FAQ: Lots of positive exponentials leading to huge exponents

What is a positive exponential?

A positive exponential is a mathematical function in which the variable is in the exponent and the base is a positive number. It is written in the form of ax, where a is the base and x is the exponent.

How does a positive exponential function behave?

A positive exponential function increases rapidly as the value of the exponent increases. This means that even small changes in the exponent can result in large changes in the overall value of the function.

What are some real-life examples of positive exponentials leading to huge exponents?

Some examples include population growth, compound interest, and exponential decay in radioactive substances. These situations involve a base number that is continuously multiplying, leading to a rapid increase in the exponent over time.

How do positive exponentials with huge exponents impact calculations and predictions?

Positive exponentials with huge exponents can greatly affect calculations and predictions, as they can lead to extremely large or small numbers. This can make it difficult to accurately predict outcomes or make precise calculations without advanced mathematical tools.

Are there any limitations to using positive exponentials with huge exponents?

Yes, there are limitations to using positive exponentials with huge exponents. For example, in real-world situations, there may be external factors that prevent the exponential growth from continuing indefinitely, leading to a more realistic and gradual increase rather than a sudden and infinite one.

Similar threads

Replies
1
Views
3K
Replies
9
Views
482
Replies
5
Views
11K
Replies
4
Views
8K
Replies
17
Views
1K
Replies
4
Views
1K
Back
Top