Arc Tangent (ATAN) and Pi (Help)
At 22 JAN 2024 10:55:05PM Robert Heard wrote:
Hello all,
I thought I'd look to see if Pi had been established as a "constant" anywhere in OI.
But when I searched for "Pi", it came back with a curious page with title "ATN". It got more perplexing as I read on. It gave a reference to the use of this function and stated that it would return the value of Pi:
Pi = 4 * ANT(1) ←- Yes, "ANT".
So I figured I'd use ATAN(1) to see what I'd get as a result. Answer is 180. That is not Pi.
I remember very little from my lessons in trigonometry, so I'm hoping there is someone more knowledgeble on the subject who can fix up the errors on that Help page.
Cheers,
Robert.
At 22 JAN 2024 11:45PM cmeyer wrote:
If you use 22/7 you will be within -0.00126448926734961868021375957764
At 23 JAN 2024 03:33AM Andrew McAuley wrote:
For that to work the ATAN value has to be in radians not degrees.
World leaders in all things RevSoft
At 23 JAN 2024 06:10PM Robert Heard wrote:
Thanks Andrew.
Maybe you could ask the doco people to add that to the info when they update that help page.
Also thanks to previous reply. I knew about 22/7 as an approximation of Pi, but it is not nearly accurate enough for my purposes.
While on the subject of Pi, I am also interested to learn about precision of calculations (particularly in AREV32/64). Only through search in OI did I find the functions:
_ADDX, _SUBX, _MULX, _DIVX
but again, so little info there. What effect does setting the "Decimal places" have on the calculation?
Is there an "overriding" setting for calculation within a routine. In the Universe environment, there is a "PRECISION" command for this purpose. I don't believe there is something similar in AREV32/64.
Oh look, I just found another related function: _CMPX. But that Help page has some issues as well. Under "Parameters" it refers to "_addx". Oops. Suspected Copy/Paste scenario there. Also, I would have thought that the whole purpose of these functions is to use extended precision in the calculations or comparisons. So the example given, where A = 10 and B = 4, is not helpful.
At 24 JAN 2024 11:13AM bshumsky wrote:
Hi, Robert. When you searched _where_ did it come back with the page with title "ATN"? It wasn't anywhere in the OI documentation, was it?
In OpenInsight, the ATAN function takes the tangent value and returns the angle that has that tangent, specified in degrees. So ATAN(1) will yield 45, since a 45 degree angle has a tangent of 1.
If you looked on-line for how to estimate Pi, you probably saw that it can be derived by ATAN(1) which yield pi/4 - but that result is only helpful if the result is returned in radians. And to convert from degrees to radians requires that you already have some value for pi, so I don't think that calculation will be useful here…
- Bryan Shumsky
At 24 JAN 2024 11:38AM bob carten wrote:
You could use a page like https://clickcalculators.com/pi-calculator/20 to get a value with the desired precision, then make an insert to equate PI$ to that value.
At 24 JAN 2024 11:42AM bshumsky wrote:
<snip>
_ADDX, _SUBX, _MULX, _DIVX
but again, so little info there. What effect does setting the "Decimal places" have on the calculation?
</snip>
For add/subtract/multiply, I believe the calculation is done with the exact values, and then the "decimal places" parameter is applied. If you specify a number of decimal places that is less than the answer contains, the value will be rounded; if you specify a number of decimal places that is greater than the answer contains, the value will be padded with zeros.
For division, the number of decimal places tells the engine how many decimal places you wish to calculate before the value is returned. If you don't specify a value here, then a default precision of 128 is used.
Is there an "overriding" setting for calculation within a routine. In the Universe environment, there is a "PRECISION" command for this purpose. I don't believe there is something similar in AREV32/64.
No, I don't believe so - I think if you want to change the precision of a math operation, you have to use the extended math functions, and specifically set the precision for each calculation.
Oh look, I just found another related function: _CMPX. But that Help page has some issues as well. Under "Parameters" it refers to "_addx". Oops. Suspected Copy/Paste scenario there. Also, I would have thought that the whole purpose of these functions is to use extended precision in the calculations or comparisons. So the example given, where A = 10 and B = 4, is not helpful.
Can you tell me where you found the documentation on _CMPX that needs to be looked at? I can't find it myself…
- Bryan Shumsky
At 24 JAN 2024 06:33PM Robert Heard wrote:
Hello Bryan,
Thanks for your reply.
128 DECIMALS by default? That's HUGE! Does this only apply to OI 10+?
It's curious that AREV32 (in OI 9.4) will acknowledge 0.000001 in a comparison, but 0.0000001 is seen as ZERO. This is what started me on my journey into the world of precision.
The search I did was via the OI Help and using the Search tab, I typed "_MULX". I have since tried "_CMPX" and it is also found. Maybe the help on these routines did not get carried over from 9.4 to 10?
I also searched for "DECIMAL PLACES" and a helpful page came up entitled "Comparison operators". Included in the "Topics" panel were the 4 exteded arithmetic functions, among others, but it did not list _CMPX here.
But it states that anything less than 0.000005 (6 dec places) is considered ZERO. I do not find that in AREV32. I find that anything < 0.00001 (5 dec places) is considered ZERO. I would assume that AREV32 and OI use the same internal functions, so this disparity is perplexing.
Then I thought I would look to see how specify radians to the trig functions. But when I type "radians" into search, I get only 3 functions listed: "COs", "Sin", "Tan". These all say that the parameter is in RADIANS.
But then I typed "degrees" and got "Cos function", Sin function, Tan function. The help on these pages was the more standard appearance and more verbose. They all say that the parameter is in DEGREES.
So the question remains, how does one use the trig functions using RADIANS?
Robert.
At 24 JAN 2024 06:43PM Robert Heard wrote:
Thanks Bob, that's brilliant!
I didn't find this site on my web search. Bookmarked now!
Cheers,
Robert.
At 24 JAN 2024 09:53PM Matthew Crozier wrote:
how does one use the trig functions using RADIANS?
Multiply your input (in radians) by 180/PI$ (where PI$ has been EQUated somewhere).
Eg. Cos( Radians * 180/PI$ )
HTH, M@
At 24 JAN 2024 10:39PM bshumsky wrote:
Hi, Robert. No, the 128 digits precision for _divx applies to the extended precision division present since 9.3, I believe.
I'm sorry to be obtuse (ha ha) about the sin/cos/tan stuff, but I can't see where you search for "radians" and get any results? Similarly, I can't find anything on the "_cmpx" comparison operator - in fact, I can't even figure what it might do, since we also have _eqx, _nex, _gtx, _gex, _ltx, and _lex… I've looked in both the "classic" HTML documentation, as well as the new Wiki documentation, without finding anything.
If you can send me a screen shot of the help pages (to info @ revelation dot com) perhaps that would help me track it down…
- Bryan Shumsky
At 24 JAN 2024 11:01PM Robert Heard wrote:
Thanks Matt.
A roundabout way of achieving Pi, which was my initial idea.
But now I know how to operate in radians.
Robert.
At 24 JAN 2024 11:04PM Robert Heard wrote:
Hi Bryan,
Will do!
At 25 JAN 2024 07:15AM bshumsky wrote:
Hi, Robert. Thanks for that! It looks like you're finding the information on _cmpx in the old ".chm" (compiled help module) help files. As far as I can tell, the info on _cmpx is no longer relevant - although a program compiles in OI 10 if it's got _cmpx, it crashes when it's run, so I think it's not implemented.
As far as cos/sin/tan taking radians - I couldn't guess what .chm file you found that in; looking in the same .chm file as I think you're using, my search for "radians" turned up nothing. In any event, the sin/cos/tan functions seem to expect their "angle value" in degrees, NOT radians.
Hope that helps,
- Bryan Shumsky
At 29 JAN 2024 06:13PM Robert Heard wrote:
Hi Bryan,
It would appear that there is some kind of link broken/missing.
If no _cmpx in OI 10, how do you compare small fractions? Is there another routine? Has the logic been changed to check the decimal places in the comparison values and thereby adjust how the comparison is done?
Will have to make a note in the routine about "_cmpx" given the flick in OI 10.
Thanks for the inside info.
Robert.
At 30 JAN 2024 03:48AM Carl Pates wrote:
Robert,
_cmpx has always been implemented - there is a bug with how one of the operands is handled however.
Fixed for v10.2.2
Regards