10-29-2023, 06:04 AM
function "_ARCSEC()" is wrong?
|
10-30-2023, 09:22 AM
The same problem with QB64 _ARCCSC-Funktion: domain of x for real result: |x| >1 !
Pls. check this sources: https://en.wikipedia.org/wiki/Inverse_tr..._functions https://mathworld.wolfram.com/InverseCosecant.html https://www.wolframalpha.com/input/?i=arccosec%28x%29 But in the QB64 help and WIKI: Code: (Select All)
Example: Code: (Select All)
gives: 0.52358... But arccosec(0.5) is not defined! The alternative formula for _ARCCSC(x): arccosec(x) = arcsin(1/x) Code: (Select All)
This delivers: 0.52358... nan "nan" is correct here. conclusion: I think both functions _ARCSEC and _ARCCSC are not correct in QB64!
10-30-2023, 10:24 AM
It goes to show how much people use these extended functions in QB64 -- they're completely backwards!
Code: (Select All) double func_arcsec(double num) { If you look in libqb.cpp, you'll find the code above. Take a moment to look at it and you'll see that the logic here is completely reversed! We're tossing errors in the range where we should give valid results, and we're giving valid results in the range where we should be tossing errors! Fix is rather simple though -- just go into libqb.cpp and down around line 33925, change the above to the following: Code: (Select All) double func_arcsec(double num) { Save and you should be good to go. (If not, then in the QB64PE menu, click DEBUG and then PURGE C++ LIBRARIES. That should rebuild the c-side of things and correct the issue after you've saved the changes above.)
10-30-2023, 01:33 PM
(This post was last modified: 10-30-2023, 01:36 PM by Kernelpanic.)
10-30-2023, 02:42 PM
(10-30-2023, 01:33 PM)Kernelpanic Wrote:Quote:Save and you should be good to go. (If not, then in the QB64PE menu, click DEBUG and then PURGE C++ LIBRARIES. That should rebuild the c-side of things and correct the issue after you've saved the changes above.)I did that, but I still get an error message. You've fixed it! Before, it was running and giving answers for you, when it shouldn't have. Now, it errors out in the range of -1 to 1, which is where the second method is printing "NaN" -- Not a Number as a result. That ERROR message *is* the fix in this case.
10-30-2023, 09:43 PM
Quote:That ERROR message *is* the fix in this case.I thought NAN was the correct answer. The error message may be correct, but it's somehow . . . not so well. I think that NAN would be better.
10-31-2023, 04:23 PM
Both functions patched and changes are pushed into the repo. This issue should be corrected in the next release.
|
« Next Oldest | Next Newest »
|
Users browsing this thread: 5 Guest(s)