[SS-111][SS-2327] arguments names interference - When using user functions, the answer is different than making step by step calculations. - Messages
As my english is very bad, I prefer to show you the picture about my problem
File not found.File not found.
If I make step by step caculations, the answer is correct (Which is 19.47°). When I try to make them using user functions, the answer is wrong even if I am using the same values for parameters.
The problem is triggered by your naming. You use x, y throughout your functions. It seems that actual parameters names interference with dummy parameters names. Here it's evident: arguments-bug.sm (2 KiB) downloaded 58 time(s).
To workaround, please change names of parameters in your functions, namely in atan2. E.g., you may make it atan2(yy;xx):= ....
Created SS-2327.
WroteYour coding is not correct:
"atan2(x,y) => returns the angle in radian from the 'x' axis to a line
containing the ORIGIN [0,0] and the point [x,y]. The value returned is
always between -π and π including π. Both x,y must be real".
Jean, you keep amusing me. Being a bright person, and making valuable contributions, you too often post either irrelevant or plain wrong comments, this one being both. It's wise to try to get some literacy in the topic before posting.
The coding of jofegibo is done letter-to-letter by definition given in Wikipedia (just above the "2.1 Derivation of atan2(y, x)" section), and is quite correct. It is somewhat redundant, as it's not necessary to check that y = 0 in subsequent conditions (it is already true since those conditions are in "else" clause of "if y!=0" ), but this doesn't do any harm.
Anyway, your comment is not only incorrect, but also irrelevant (as in other topics, too): the origial poster didn't ask advise on the coding, but made a well-defined question that highlights existing problem.
Please, try to refrain of irrelevant comments in every topic you happen to notice, just because it distracts those who have something to say on essence of the matter, and make it harder to search the forum for a relevant info.
containing the ORIGIN [0,0] and the point [x,y]. The value returned is
always between -π and π including π. Both x,y must be real".
That definition is correct and universal. What's confusing is Smath built-in "mwatan2(,,)
That's why I posted an example for edu/observe. Otherwise Smath angle is even more simple:
x:=64.644 ,,,,, y:=135.355
arg(x+y*i)=64.471393°
'z' in the front end comes out of the blue. If it's further needed, and produces red ?
Maybe some info are missing about what is doing what for what.
Cheers, Jean.
Wrote"atan2(x,y) => returns the angle in radian from the 'x' axis to a line
containing the ORIGIN [0,0] and the point [x,y]. The value returned is
always between -π and π including π. Both x,y must be real".
That definition is correct and universal.
Yes, that's true. So what? OP's post conforms to this definition completely.
QuoteWhat's confusing is Smath built-in "mwatan2(,,)
That's why I posted an example for edu/observe.
Oh, really?
Here you do two mistakes. First: mwatan2(,,) isn't SMath built-in. It's Matlab C++ Math Library extension's function.
Second: what you've posted wasn't presented as something "for edu/observe", as it started with:
WroteYour coding is not correct:
Btw, whos? A person who implemented Matlab's mwatan2? Does that belong here?
Two birds in one shot !
WroteYour atan2(y,x) is right with your Smath version.
But there is a bug in your version wrt to "atan2(,,)
the universal implementation and bug wrt Smath 5346
which version respects the maths adopted convention.
Wrote... and by same token: mwatan2[,,] is bug in Smath 5346.
Two birds in one shot !
Your own screenshot shows that there's NO error in mwatan(#,#). Maybe you were confused by the names of arguments?
By definition, atan2(y,x)≡arg(x+i*y)
Please notice that atan2 has y and x in "reversed" order.
What is "UNIVERSAL IMPLEMENTATION" of atan2? Link please.
WroteBy definition, atan2(y,x)â¡arg(x i*y)
Please notice that atan2 has y and x in "reversed" order.
What is "UNIVERSAL IMPLEMENTATION" of atan2? Link please.
atan2(y,x)â¡arg(x i*y)
Answer: WRONG, bug in your Smath version.
"Universal Implementation" of atan2 is as adopted since the very first day of FORTRAN,
respected in Mathcad 8/11 but not in your Smath version.
Wrote"Universal Implementation" of atan2 is as adopted since the very first day of FORTRAN,
respected in Mathcad 8/11 but not in your Smath version.
Oh really?
Let's ask IBM, the Fortran inventor:
http://www.ibm.com/support/knowledgecenter/SSGH4D_14.1.0/com.ibm.xlf141.aix.doc/language_ref/atan2.html?lang=en
Your version of Mathcad uses non-standard definition, but that doesn't make it standard.
WroteYour version of Mathcad uses non-standard definition, but that doesn't make it standard.
Ask Uni about his Mathcad version more recent than mine [8/11]
'tan' is Y/X we know that since ages. But polar angle is this way,
Both in Smath 5436 [correct] and Mathcad 8/11 also correct.
And the two are correct by the books.
A bug is a bug, end of it.
you are ignorant troll. End of it. I only ask you: please, don't ever bother to answer to my posts.
WroteJean,
you are ignorant troll. End of it. I only ask you: please, don't ever bother to answer to my posts.
Don't worry Mike, this kind of question will come again and again
as long as the bug is not cleared. My last post is the 1/1 Smath
to get the polar angle of a complex number, just replying the
very fisrt thread, not to you in particular. As you say: end of it.
If you take the code from Wikipedia, the error will not
https://en.wikipedia.org/wiki/Atan2#Definition_and_computation

Edit: no, I'm wrong.
Original function only works if its body os enclosed in eval(). Ber7's version works without line().
Happy reconciliation.

Actually, you should look what is actually assigned to a. To do so, just put caret at the beginning of the expression, and use right arrow to travel to the right. Keep attention to the underscore.
You'll see that it's only first part (sin(dlat/2))^2 that is actually assigned. Everything else is just added to the result of assignment:
(a:(sin(dlat/2))^2)+cos({lat1*π}/180)*cos({lat2*π}/180)*(sin(dlong/2))^2=0.0151
-
New Posts
-
No New Posts