Definitions of sqrt, sin, cos, pow etc. in cmath

后端 未结 8 1136
野趣味
野趣味 2020-12-13 00:13

Are there any definitions of functions like sqrt(), sin(), cos(), tan(), log(), exp() (these fr

8条回答
  •  时光说笑
    2020-12-13 01:18

    Usage: root(number,root,depth)

    Example: root(16,2) == sqrt(16) == 4
    Example: root(16,2,2) == sqrt(sqrt(16)) == 2
    Example: root(64,3) == 4

    Implementation in C#:

    double root(double number, double root, double depth = 1f)
    {
        return Math.Pow(number, Math.Pow(root, -depth));
    }
    

    Usage: Sqrt(Number,depth)

    Example: Sqrt(16) == 4
    Example: Sqrt(8,2) == sqrt(sqrt(8))

    double Sqrt(double number, double depth = 1) return root(number,2,depth);
    

    By: Imk0tter

提交回复
热议问题