Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended Trig Methods
#11
(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. Smile

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?
Reply
#12
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 + ...
Reply
#13
(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)
Reply
#14
(01-16-2024, 10:31 AM)BSpinoza Wrote: Arcus cosecant(x) is the same as sin^-1(1/x)
Perfect, thanks!
Reply
#15
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.
[Image: Illegal-Function-Call2024.jpg]
Reply
#16
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 + ...
Reply
#17
(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.  Tongue

Reply
#18
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. Tongue I would have much rather watched mushroom land (with a smidgen of Daisy sprinkled in for effect).
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply
#19
Quote:Oh those Daisy Dukes. [Image: tongue.png] I would have much rather watched mushroom land (with a smidgen of Daisy sprinkled in for effect).
@Terry - do you mean this Daisy?  Big Grin

[Image: Daisy-Duck2024-01-08.jpg]
Reply
#20
Photo 
(01-17-2024, 11:24 PM)Kernelpanic Wrote:
Quote:Oh those Daisy Dukes. [Image: tongue.png] I would have much rather watched mushroom land (with a smidgen of Daisy sprinkled in for effect).
@Terry - do you mean this Daisy?  Big Grin

[Image: Daisy-Duck2024-01-08.jpg]
No, the original and only Daisy Duke.

[Image: HD3GP9jpg-JS419185327.jpg?w=620]
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply




Users browsing this thread: 1 Guest(s)