1 hour ago · Tech · hide · 0 comments

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 >>>…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.