Inverse bed in C #

We know that the inverse of tan is equal to Math.Atan , but what about bed inversion? cot(x) is defined as

 cot(x)=1/tan(x) 
+4
source share
4 answers

See Reverse Cotangent . For some values, the inverse will be atan(1/x) .

+9
source

Another alternative for inverse cotangent is Math.PI/2 - Math.Atan(x) , which has the advantage of working correctly when x is 0 .

+2
source

There are two commonly used conventions for cotangent inversion, since, for example, cot (1) = cot (1-pi). It is important to consider which definition to use.

  • Let arccot ​​(x) correspond to atan (1 / x) with values ​​between -pi / 2 and pi / 2. This gives breaks at 0 (jumps from -pi / 2 to pi / 2). This agreement is used in the response of Greg Hugh.

    arccot ​​with values ​​between -pi / 2 and pi / 2, image from Wolfram MathWorld

     public static double Acot(double x) { return (x < 0 ? -Math.PI/2 : Math.PI/2) - Math.Atan(x); } 

    or

     public static double Acot(double x) { return x == 0 ? 0 : Math.Atan(1/x); } 
  • Let arccot ​​(x) be a continuous function with values ​​from 0 to pi. This is the agreement used in Daniel Martin's answer.

    arccot ​​with values ​​between 0 and pi, image from Wikipedia

     public static double Acot(double x) { return Math.PI/2 - Math.Atan(x); } 
+2
source

You can use the Math.Atan2 method as an inverse crib, as shown below, without checking for a null value.

 var value = Math.Atan2(1,cotValue); 
0
source

Source: https://habr.com/ru/post/1308972/


All Articles