Troubleshooting Mathematica Eigen Problem: Analytical vs. Numerical Results"

  • Mathematica
  • Thread starter guidob
  • Start date
  • Tags
    Mathematica
In summary, the problem you are experiencing is due to the fact that you are trying to calculate the exact value of an exponential function using approximate math. You should try to fix the problem by reformingulating the equation so that you are calculating approximate values instead.
  • #1
guidob
4
0
Hi! I'm having some trouble with this. In the code I define two matrices, then calculate its eigenvalues/eigenvectors, and finally I plot the absolute values of the components of the eigenvectors. The results are consistent with (I'm quite sure) the analytical ones but only below "t approx 30". Above this value, (only) the first plot corresponding to one of the vectors shows some strange behaviour.

Any idea? I've tried to solve it changing the precision options, but I couldn't.

Thanks!
 

Attachments

  • PB.nb
    6.9 KB · Views: 602
Physics news on Phys.org
  • #2
You should avoid to letting Mathematica works with lots of symbols. Just absorb exponential factor in constant b and redefine it later.

Code:
Clear[a,b,w,g,t]
ρt={{a,b},{b*,1-a}};
{e1,e2}=Eigenvalues[ρt]; 
{v1,v2}=Eigenvectors[ρt];

Here you return exponential factor since it is conugated just like constant b.

Code:
a=0.6`1000; 
w=1`1000; 
g=1`1000;
b=(1`1000+2`1000*I) Exp[-I*w*t-g*t];
v1n=Normalize[N[v1,1000]]; 
v2n=Normalize[N[v2,1000]];
Abs1={Abs[v1n[[1]]],Abs[v1n[[2]]]};
Abs2={Abs[v2n[[1]]],Abs[v2n[[2]]]};
 
  • #3
Thanks djelovin! It seems that I could fix it doing what you told me and also defining the values of the parameters after the calculations. I'm new to this. Thanks again.
 
  • #4
I believe the underlying problem can be seen if you get rid of all your decimal points and N and attempts to fix this with thousand digit precision and just look at the exact values that you are attempting to calculate with approximate math.

For example, you can see your Abs1 for t==50 has -(E^50)/5+Sqrt[20+(E^100)/25] in both your numerator and denominator.

In[1]:= Table[Abs1,{t,50,50}]

Out[1]= {{(-E^50/5 + Sqrt[20 + E^100/25])/ (2*Sqrt[5*(1 + (-E^50/5 + Sqrt[20 + E^100/25])^2/20)]), 1/Sqrt[1 + (-E^50/5 + Sqrt[20 + E^100/25])^2/20]}}

FabulouslyCloseToZeroButApproximated/ FabulouslyCloseToZeroButApproximated and then throwing this at Plot doesn't seem so surprising when I make tables of those values and see that when t gets large enough that your error bits fall on the wrong side of the scale sometimes.

In other words your problem is what I believe I remember they call "ill posed."

If I'm remembering the right title, there is a nice little book from about 20 years ago titled "Real Computing Made Real: Preventing Errors In Scientific And Engineering Calculations" that tries to teach how to reformulate ill posed problems so that you get much greater accuracy in the results. Ah! Dover has republished that. I highly recommend that one to anyone pushing bits around.
 
Last edited:
  • #5


Hello! Thank you for sharing your issue with Mathematica's eigenvalues and eigenvectors. It's great to see that you have already compared your results with the analytical ones and have found consistency up to a certain point. This indicates that your code is functioning correctly up to that point.

Based on your description, it seems that the issue may lie in the numerical calculation of the eigenvalues and eigenvectors. When dealing with numerical calculations, it is important to consider the precision and accuracy of the results. You mentioned that you have tried changing the precision options, but were unable to solve the issue. In that case, I would recommend exploring other options such as increasing the working precision or using alternative methods for calculating the eigenvalues and eigenvectors.

Another factor to consider is the stability of the algorithm used for the numerical calculations. Sometimes, certain algorithms may not perform well for certain types of matrices, leading to unexpected results. It may be helpful to try different algorithms and see if that improves the accuracy of your results.

Additionally, it would be beneficial to check for any errors or warnings in your code or results. This can give you a better understanding of where the issue may be arising from.

Overall, troubleshooting numerical problems in Mathematica can be challenging, but with careful examination of your code and results, as well as exploring different options, you should be able to identify and resolve the issue. I hope this helps and good luck with your research!
 

1. What is the difference between analytical and numerical results in Mathematica?

Analytical results in Mathematica refer to solutions that can be obtained through symbolic manipulation and mathematical equations. These results are exact and do not involve any approximations. On the other hand, numerical results are obtained through numerical methods and involve approximations to find solutions to complex problems.

2. When should I use analytical or numerical methods in Mathematica?

Analytical methods should be used when exact solutions are desired and the problem can be solved using mathematical equations. Numerical methods should be used when the problem is too complex to be solved analytically or when exact solutions are not required.

3. How do I troubleshoot when I get different results from analytical and numerical methods in Mathematica?

If you get different results from analytical and numerical methods in Mathematica, it is important to check your input and make sure it is correct. You should also check the precision and accuracy settings in your calculations, as well as the convergence criteria for numerical methods. It may also be helpful to consult the Mathematica documentation or seek help from the Mathematica community.

4. Can I use a combination of analytical and numerical methods in Mathematica?

Yes, you can use a combination of analytical and numerical methods in Mathematica. This is often necessary when solving complex problems that cannot be solved purely analytically. You can use analytical methods to simplify the problem and then use numerical methods to obtain a more accurate solution.

5. Are there any advantages to using analytical methods over numerical methods in Mathematica?

The main advantage of using analytical methods in Mathematica is that they provide exact solutions, which can be useful for certain applications. Analytical methods also tend to be faster than numerical methods, as they do not require iterations. However, numerical methods are often necessary for solving more complex problems that cannot be solved analytically.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Advanced Physics Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • Atomic and Condensed Matter
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • Differential Equations
Replies
1
Views
2K
Replies
1
Views
4K
  • Advanced Physics Homework Help
Replies
2
Views
4K
  • STEM Academic Advising
Replies
2
Views
2K
Back
Top