158 days ago · Tech · hide · Fediverse post

The calculator utility bc has a minimal math library. For example, there’s no tangent function because you’re expected take the ratio of sine and cosine. (The Gnu version of bc goes have a function for tangent, but the POSIX version does not.) And yet bc includes support for Bessel functions J(x). The bc function j takes two arguments. Is the first argument n or x? Grok said the function arguments are j(n,x). I thought I should run man bc just to make sure, and it said j(x, n) Returns the bessel integer order n (truncated) of x. So Grok says j(n,x) and the documentation that ships with the software says j(x,n). Which one should you believe? Neither! You should run a little test. ~$ bc -l >>> j(1, 0) 0 >>> j(0, 1) .76519768655796655144 Now J1(0) = 0, so apparently the first argument is the order n. Grok was right and the man page was wrong. As further confirmation, let’s see which argument is truncated. >>> j(1.2, 3.4) .17922585168150711099 >>> j(1, 3.4) .17922585168150711099 >>>…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town