Japt: Approximating arccosine

In most languages, trigonometric functions are a module shipped with the default language. In Japt, the Javascript-based code golfing language, that’s sadly not the case. There is no built-in for arcsine nor for arccosine.

While you can embed Javascript in Japt, that would be what ever the opposite of Feng Shui is:

$M.acos($U
$.......$  // Evaluating as regular Javascript,
 M         // get the Japt built-in `M` which maps to Javascript's `Math`
  .acos( U // and call `acos()` on it with the default input `U`.

It works, but it’s definitely not pretty.

Instead of falling back on the underlying language, we can brute-force a reasonable approximation:

ToMP1/7l¹ñ@McX aUÃv
T                   // Take 0
 o                  // and create a range from that
  MP                // to π
    1/7l¹           // with a resolution of 1/7!.
         ñ@         // Sort this range so that
           McX      // the cosine of a given value
               aU   // is closest to the default input `U`,
                 Ãv // then return the first element.

While essentially code bowling length-wise, we can stay in Japt-land without dropping down to Javascript.
The result is accurate to roughly four significant digits.