Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have code that uses Eigenvalues on matrices of various sizes. But the output of what should be a very simple problem, namely finding the eigenvalue of a 1x1 matrix, is overly complicated.

Eigenvalues[{{1-(0.2494562342391921 Exp[-2(-0.2+x)^2]+0.769722872465748 Exp[-2x^2])/(1-x^2)}}]

returns

(3.28871*10^-17 E^(-2 (-0.2+x)^2-2 x^2) (2.3405*10^16 E^(2 (-0.2+x)^2)+7.58524*10^15 E^(2 x^2)-3.04071*10^16 E^(2 (-0.2+x)^2+2 x^2)+3.04071*10^16 E^(2 (-0.2+x)^2+2 x^2) x^2))/(-1.+x^2)

Where did those 10^-17 and 10^16 terms come from? Why can't it just give me

1-(0.2494562342391921 Exp[-2(-0.2+x)^2]+0.769722872465748 Exp[-2x^2])/(1-x^2)

?

share|improve this question
    
The eigencode probably tried to factor a symbolic expression. That gets dicey when there are approximate numbers involved. –  Daniel Lichtblau Apr 25 at 21:02
1  
@DanielLichtblau: a nasty side-effect is that Chop produces zero while FullSimplify acts as desired. –  Wouter Apr 26 at 16:38
    
@Wouter I assure you that particular side effect has bitten me more times, and in more delicate places, than I can describe in this forum. –  Daniel Lichtblau Apr 26 at 19:57
    
@Wouter: Yes, the interaction with Chop is exactly why I asked. In the end, I now check for 1x1 matrix and not send it through Eigenvalues unnecessarily, which sidesteps this issue. –  Chris K Apr 27 at 14:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.