exp( ) gives unexpected answer for (2,2) input
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jonathon Cheah
il 2 Set 2022
Modificato: Bruno Luong
il 9 Set 2022
I have trouble understanding the results returned by exp():
given a= [1.4142 1.4121; 1.4142 1.4121] ;
exp(j*2*pi*a*10^3) = [0.2269 +0.9739i 0.8312+0.5560i ; 0.2269+0.9739i 0.8312+0.5560i]
but checking by elements:
exp(j*2*pi*1.4142*10^3)=0.3090+0.9511i
exp(j*2*pi*1.4121*10^3)=0.890+0.5878i
if a =[1.4142 1.4121];
then the answers agree with the element check. What am I missing?
1 Commento
James Tursa
il 2 Set 2022
Modificato: James Tursa
il 2 Set 2022
Please show the actual code ... i.e., copy & paste the code and actual MATLAB output. It could be that you hand typed in numbers based on MATLAB truncated display but the actual numbers used by MATLAB are different. E.g., what does 1.4142-a(1,1) and 1.4141-a(1,2) show? Or use format longg and display the "a" matrix again.
Risposta accettata
John D'Errico
il 2 Set 2022
Modificato: John D'Errico
il 2 Set 2022
I would bet a large sum of money that a is not exactly what you think it is.
a_you_think = [1.4142 1.4121; 1.4142 1.4121];
However, the odds are instead very good that those numbers are only rounded to 5 significant digits, then they were displayed as such. Remember that MATLAB carries roughly 16 significant digits in a double precision number. So that value of 1.4142 for a(1,1) could be anything in the interval (1.41415,1.41425).
a11 = [1.41415*(1+eps);1.41425*(1- eps)]
format long g
exp(j*2*pi*a11*10^3)
So is your output unexpected? It is only unexpected for YOU. I'm not at all surprised.
6 Commenti
Bruno Luong
il 9 Set 2022
Modificato: Bruno Luong
il 9 Set 2022
@Jonathon Cheah "The factor x10^3 is necessary but not sufficient effects in my ""small" delta comment.
The factor 10^3 + truncating digits of 1.414213562373095 are perfectly sufficient to explain. There is noting mysterious as you seem to imply.
Here are two numbers
a=1.414213562373095
ar=1.4141
Now the exponential values with factor 10^3
z=exp(1i*2*pi*a*10^3)
zr=exp(1i*2*pi*ar*10^3)
Q: How much is the difference in angles after scaling by 10e3?
theta=2*pi*(ar-a)*10^3 % in radian
A: And the angle error in degree,
thetadeg=rad2deg(theta) % in degres
OK the error of angle si about -40 degres, not quite one turn (=360 degres) but it is not small by any mean due solely to the factor 10^3, nothing else.
Q: Can I retreive the angle from z and zr alone?
A: Yes:
atan2(imag(zr/z),real(zr/z)) % compare with theta above
Q: Does the error of angle can explain the different between z and zr
z*exp(1i*theta)
zr
A: Perfectly
To summarize:
There is nothing surprise when you take time to decompose and check the bound of the error.
There is no lesson to be learnsed other then checking how your calculation chain propagate the error.
Più risposte (1)
Paul
il 2 Set 2022
Seems to give the expected result?
a= [1.4142 1.4121; 1.4142 1.4121]
exp(j*2*pi*a*10^3)
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!