Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline Sutyi  
#1 Posted : 30 March 2020 01:40:06(UTC)
Sutyi

Rank: Newbie

Groups: Registered
Joined: 30/03/2020(UTC)
Posts: 4
United States
Location: West Virginia

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,Cool*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,

SutyiBiggrin Complex Bode Plot rev2.sm (77kb) downloaded 18 time(s).
Offline Jean Giraud  
#2 Posted : 30 March 2020 18:51:19(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
Originally Posted by: Sutyi Go to Quoted Post
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
Offline Jean Giraud  
#3 Posted : 30 March 2020 20:02:58(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
atan(re,im) deconfuse.PNG
Offline Jean Giraud  
#4 Posted : 30 March 2020 21:14:50(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
Bode.PNG
Offline Jean Giraud  
#5 Posted : 30 March 2020 23:15:25(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
Originally Posted by: Sutyi Go to Quoted Post
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
Offline Jean Giraud  
#6 Posted : 31 March 2020 00:22:03(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
atan(2) otherwise.PNG
Offline Sutyi  
#7 Posted : 31 March 2020 01:35:19(UTC)
Sutyi

Rank: Newbie

Groups: Registered
Joined: 30/03/2020(UTC)
Posts: 4
United States
Location: West Virginia

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 Bode plot example.xmcd (77kb) downloaded 3 time(s). Bode plot example.pdf (191kb) downloaded 12 time(s).
Offline Jean Giraud  
#8 Posted : 31 March 2020 03:59:04(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
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 (91kb) downloaded 9 time(s).

Offline Jean Giraud  
#9 Posted : 31 March 2020 05:04:45(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
... Fourier spectrum added.
Possibly, we may extract a resulting sine wave.

Complex Bode Plot rev2 [Direct Domain Fourier Spectrum].sm (27kb) downloaded 7 time(s).
Offline Sutyi  
#10 Posted : 01 April 2020 00:53:15(UTC)
Sutyi

Rank: Newbie

Groups: Registered
Joined: 30/03/2020(UTC)
Posts: 4
United States
Location: West Virginia

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
Offline Jean Giraud  
#11 Posted : 01 April 2020 04:14:39(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
Originally Posted by: Sutyi Go to Quoted Post
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 (101kb) downloaded 10 time(s).

Offline Sutyi  
#12 Posted : 02 April 2020 00:42:02(UTC)
Sutyi

Rank: Newbie

Groups: Registered
Joined: 30/03/2020(UTC)
Posts: 4
United States
Location: West Virginia

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
Offline Jean Giraud  
#13 Posted : 02 April 2020 04:06:17(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,582
Canada

Was thanked: 775 time(s) in 615 post(s)
Originally Posted by: Sutyi Go to Quoted Post
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
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.