atan2 (complex) function

atan2 (complex) function - Returns incorrect result - Сообщения

#1 Опубликовано: 29.03.2020 19:40:06
Nick

Nick

0 сообщений из 4 понравились пользователям.

Группа: User

It took me a great deal of effort to figure out why the complex atan function returns the wrong result. I compared it with Mathcad until I realized that it was working partially after I entered 90-atan(a,b)*180/PI. This at least matched the Mathcad result until -90 degrees was reached. Beyond it would require a different combination.
In any case I can share my example file that I had created so you can understand the issue.
I am using your latest Smath Studio Desktop that was published last November.

Regards,

Sincerely,

Sutyi:d Complex Bode Plot rev2.sm (76 КиБ) скачан 67 раз(а).
#2 Опубликовано: 30.03.2020 12:51:19
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

It took me a great deal of effort to figure out why the complex atan function returns the wrong result


That's not true ... atan(2) from f(x) menu.

atan(re,im).PNG
#3 Опубликовано: 30.03.2020 14:02:58
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

atan(re,im) deconfuse.PNG
#4 Опубликовано: 30.03.2020 15:14:50
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Bode.PNG
#5 Опубликовано: 30.03.2020 17:15:25
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

It took me a great deal of effort to figure out why the complex atan function returns the wrong result.


complex atan = atan(2)
Nothing wrong Smath native code atan(2)

atan2(,,).PNG
#6 Опубликовано: 30.03.2020 18:22:03
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

atan(2) otherwise.PNG
#7 Опубликовано: 30.03.2020 19:35:19
Nick

Nick

0 сообщений из 4 понравились пользователям.

Группа: User

Dear Jean Giraud,

I have created the Mathcad-13 equivalent file of my Smath Studio file.

Please compare the two. I am uploading it both as .xmcd and the PDF version of it.

Attempt to repeat the Mathcad results using the zedgraph logarithmic setup for the phase and please let me know where you think this is going wrong.

Thank you,

NickФайл не найден.Файл не найден.
#8 Опубликовано: 30.03.2020 21:59:04
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

I'm not adept of Bode plot, plots are in the freaked domain.
Direct domain looks different but real from measuring
equipment or from otherwise log scale.
If you want to do more maths/physics, it will be from the
direct domain... per say Fourier spectrum.
Mathcad is now for Museum in my box.
Collab Alyles is champion in that, he may catch on the fly.
Cheers ... Jean ... PDF opens fine.

Complex Bode Plot rev2 [Direct Domain].sm (90 КиБ) скачан 51 раз(а).

#9 Опубликовано: 30.03.2020 23:04:45
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

... Fourier spectrum added.
Possibly, we may extract a resulting sine wave.

Complex Bode Plot rev2 [Direct Domain Fourier Spectrum].sm (26 КиБ) скачан 38 раз(а).
#10 Опубликовано: 31.03.2020 18:53:15
Nick

Nick

0 сообщений из 4 понравились пользователям.

Группа: User

Hello Jean Giraud,

There are a few issues that tripped you as well based on what I am seeing in your Direct Domain version of the file. The original Mathcad file I was attempting to convert to Smath Studio so I could promote its use with my colleagues used an indexed datapoint stacking method with n=0 to 200 in increments of 1 to compute the values of the function.

Zedgraph cannot work with that data structure setup. It literally handles the equation evaluating without you knowing about it how to a number you specify when you set up Zedgraph.
Since I am not a software programmer, after looking at the Zedgraph source files posting I could not figure out how it is internally set up.

In Electronics Engineering that I am practicing since 1976, Bode Plots are essential. Zedgraph is the only way I found where you can set up the frequency scale logarithmically so that it would present a Bode Plot correctly in Smath Studio.

Based on you checking out the atan2 function and the bad result in Zedgraph I am venturing to say that the issue might be within the Zedgraph plotting engine and not in the Smath Studio software.

So this post of mine should go to someone who is either willing to jump into Zedgraph or create a similarly functioning plotting tool for Smath Studio. I am afraid to say that the standard Smath Studio plotting tool is a bear. It is very difficult to work with not being able to set it up as you wish and it completely lacks the logarithmic scaling functionality that an Electrical/Electronics Engineer would need as presented in my example.

Thank you very much the time you spent on this subject. Do you have any idea where it needs to go?

On a personal level I am impressed with Smath Studio's capabilities and honestly trying to champion its use. Except the above described shortcoming would need to be addressed.

Respectfully,

Sutyi
#11 Опубликовано: 31.03.2020 22:14:39
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

So this post of mine should go to someone who is either willing to jump into Zedgraph or create a similarly functioning plotting tool for Smath Studio. I am afraid to say that the standard Smath Studio plotting tool is a bear. It is very difficult to work with not being able to set it up as you wish and it completely lacks the logarithmic scaling functionality that an Electrical/Electronics Engineer would need as presented in my example.


In lot of instances Mathcad 2D plots is more immediate.
Many of my 2D Smath are far superior for publishing.
log-log Bode plots is even more attractive than Mathcad.
I lost patience on that, not being my cup of tea !
No recollection who is the artisan of that one.
Cheers, welcome to Smath Community ... Jean.

2DPlots ZedGraph log-log.sm (100 КиБ) скачан 58 раз(а).

#12 Опубликовано: 01.04.2020 18:42:02
Nick

Nick

0 сообщений из 4 понравились пользователям.

Группа: User

I understand. Also last night after I got off teleworking I investigated the issue a bit further. I was wrong, the issue is not Zedgraph, it is how Smath Studio interprets atan2. I compared that with Matlab and Wolfram and both interpret it the same way as Smath Studio. Mathcad is the outlier here by following the Electronics Engineering definition of complex arctangents. Too bad but I believe this difference can be overcome with writing a programming function in Smath Studio to do that. I am not the best with these programming structures, my mind works a little different but hopefully will be able to do that on my own. It might take some time, but that is OK.
Thank you for looking into it.

Best Regards
#13 Опубликовано: 01.04.2020 22:06:17
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

I understand. Also last night after I got off teleworking I investigated the issue a bit further. I was wrong, the issue is not Zedgraph, it is how Smath Studio interprets atan2. I compared that with Matlab and Wolfram and both interpret it the same way as Smath Studio. Mathcad is the outlier here by following the Electronics Engineering definition of complex arctangents. Too bad but I believe this difference can be overcome with writing a programming function in Smath Studio to do that. I am not the best with these programming structures, my mind works a little different but hopefully will be able to do that on my own. It might take some time, but that is OK.
Thank you for looking into it.


Oh ! my friend: calm down coding Smath/Mathcad
atan(2) was controversed in Mathcad up to 11.
In fact, Smath that is more largely based on universal libraries
often detects wrong MCD code, though not wrong within itself.
example: UnitVector(x):= x/|x|... nonsense as such coded Smath
Smath... UnitVector(x):x/norme(x) ... universal compliance.
UnitVector was detected while solving Quaternions.
there are more occurences [3D axes system].
Maths stuff will last as long as it takes times to paint the sky.
Keep hardworking ... Jean
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений