Posts: 2,700
Threads: 328
Joined: Apr 2022
Reputation:
219
(01-15-2024, 06:42 PM)bplus Wrote: @dbox to be a total nag, it seems to me a more productive use of time to get _Maptriangle working than exotic math functions.
The only people that would use exotic math functions can create their own from building blocks of the basic ones such as Sin, Cos and Tan and their Arc- prefixes because they would be quite familiar with and skilled at using Trig Indentities.
What's wrong with _MapTriangle?
Posts: 3,987
Threads: 178
Joined: Apr 2022
Reputation:
222
Nothing wrong in QB64 but there is no QBJS equivalent without using JS library or extension which trips me up getting equivalent results in QBJS that I get in QB64 without writing 2 sets of code.
S'OK I haven't figured out using assets either. Getting too old for new tricks I guess.
b = b + ...
Posts: 46
Threads: 7
Joined: Apr 2022
Reputation:
2
(01-15-2024, 02:34 PM)dbox Wrote: In the process of trying to expand QBJS' support for QB64 keywords I noticed a curiosity with the extended trigonometric functions. It looks like this has been the case for some time and predates "the incident".
There is a bit of inconsistency with the documentation in the wiki(s) for the support of these keywords. Some are well documented and have their own page like: _acos, _asin, _hypot, etc.. Many of them, however, are only referenced in the "Derived Mathematical Functions" section of the Mathematical Operations page. This section, though, is really just a reference of how to implement your own trig functions and doesn't really indicate that many (but not all) of those methods are actually available in the language.
The following functions from this section have first-class keyword support:
_sec, _csc, _cot, _arcsec, _arccsc, _arccot, _sinh, _cosh, _tanh, _sech, _csch, _coth
...while these do not have a dedicated keyword:
_arcsin, arccos, _arcsinh, _arccosh, _arccsch, _arccoth
So the curiosity that I found is related to the _arccsc method. If you run the following example you will see that you get two different answers for built-in function vs the provided logic in the wiki:
Code: (Select All)
Print _Arccsc(x)
Print Atn(1 / Sqr(1 - x * x)) + (Sgn(x) - 1) * (2 * Atn(1))
Which one is right? Arcus cosecant(x) is the same as sin^-1(1/x)
Code: (Select All)
x = 1.5 '(example value)
PRINT _ARCCSC(x)
'PRINT ATN(1 / SQR(1 - x * x)) + (SGN(x) - 1) * (2 * ATN(1))
PRINT _ASIN(1 / x)
Posts: 272
Threads: 24
Joined: Apr 2022
Reputation:
59
(01-16-2024, 10:31 AM)BSpinoza Wrote: Arcus cosecant(x) is the same as sin^-1(1/x) Perfect, thanks!
Posts: 1,000
Threads: 50
Joined: May 2022
Reputation:
27
01-16-2024, 11:33 PM
(This post was last modified: 01-16-2024, 11:38 PM by Kernelpanic.)
This formula is in the wiki, but it always gives an error message:
Code: (Select All)
Atn(1 / Sqrt(1 - (x * x))) + (Sgn(x) - 1) * (2 * Atn(1))
Why? I have not find any explains in the Internet.
Code: (Select All)
Dim As Double x, y, Arcc
x = 1.5
y = 1.5
Print "1. "; _Arccsc(x)
Print "1A. "; Atn(1 / Sqr(1 - x * x)) + (Sgn(x) - 1) * (2 * Atn(1))
Print
Print "2. "; _Asin(1 / x)
Print "3. "; _Arccsc(y)
Print "4. "; Atn(1 / Sqr(1 - y * y)) + (Sgn(y) - 1) * (2 * Atn(1))
Print
Print "5. "; _Asin(1 / x)
Print
Arcc = Atn(1 / Sqr(1 - (x * x))) + (Sgn(x) - 1) * (2 * Atn(1))
Print "6. "; Arcc
And the last result. . . Maybe a math guru can explain it.
Posts: 3,987
Threads: 178
Joined: Apr 2022
Reputation:
222
01-16-2024, 11:54 PM
(This post was last modified: 01-16-2024, 11:56 PM by bplus.)
The range of x and y for Trig formulas are intended to be from a unit circle st x^2 + y^2 = 1
Taking the SQR of a neg number will throw that error which happens when x > 1.
b = b + ...
Posts: 1,000
Threads: 50
Joined: May 2022
Reputation:
27
01-17-2024, 09:07 PM
(This post was last modified: 01-17-2024, 09:08 PM by Kernelpanic.)
(01-16-2024, 11:54 PM)bplus Wrote: The range of x and y for Trig formulas are intended to be from a unit circle st x^2 + y^2 = 1
Taking the SQR of a neg number will throw that error which happens when x > 1. Thanks! This works:
Code: (Select All)
Dim As Double x, y, Arcc
x = 1
y = 1
. . .
Unit circle! Yes, the “realization” slowly came back when I saw this.
Posts: 1,270
Threads: 118
Joined: Apr 2022
Reputation:
100
Where were videos like this when I was a stupid teenager!? We would spend part of our Friday night laughing our ass off at the Dukes of Hazard (and drooling over Katherine Bach). Oh those Daisy Dukes. I would have much rather watched mushroom land (with a smidgen of Daisy sprinkled in for effect).
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 1,000
Threads: 50
Joined: May 2022
Reputation:
27
Posts: 1,270
Threads: 118
Joined: Apr 2022
Reputation:
100
01-18-2024, 03:15 AM
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
|