Skip to main content
saved 2 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES7), 9694 bytes

Probably not the golfiest formulasway, especially for edge cases.

Returns [atan(x), asinacos(x), acosasin(x)].

x=>[(p=1.571,g=x=>v=1g=x=>1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*gc=2*g((1-x*x)**.5/++x),2*v]p-c]

Try it online!Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

(source: Wikipedia)

JavaScript (ES7), 96 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

(source: Wikipedia)

JavaScript (ES7), 94 bytes

Probably not the golfiest way, especially for edge cases.

Returns [atan(x), acos(x), asin(x)].

x=>[(p=1.571,g=x=>1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),c=2*g((1-x*x)**.5/++x),p-c]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

(source: Wikipedia)

added a link to Wikipedia
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES7), 96 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

(source: Wikipedia)

JavaScript (ES7), 96 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

JavaScript (ES7), 96 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

(source: Wikipedia)

saved 2 bytes
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

JavaScript (ES7), 9896 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>2*++k-1+h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

JavaScript (ES7), 98 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>2*++k-1+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

JavaScript (ES7), 96 bytes

Probably not the golfiest formulas, especially for edge cases.

Returns [atan(x), asin(x), acos(x)].

x=>[(p=1.571,g=x=>v=1/x?x/(h=k=>k+++k+(k>>9?0:k*k*x*x/h(k)))``:p)(x),p-2*g((1-x*x)**.5/++x),2*v]

Try it online!

Formulas

The arctangent is approximated with the continued fractions:

$$\arctan(x)=\dfrac{x}{1+\dfrac{(1x)^2}{3+\dfrac{(2x)^2}{5+\dfrac{(3x)^2}{7+\ddots}}}}$$

We then use:

$$\arccos(-1)=\pi\\\arccos(x)=2\arctan\left(\frac{\sqrt{1-x^2}}{1+x}\right),\:-1<x\le1$$

and:

$$\arcsin(x)=\frac{\pi}{2}-\arccos(x)$$

minor update
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
added an explanation
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
added an explanation
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650
Loading