WeixiangYan/CodeTransOcean huggingface dataset:
Task: Trigonometric functions


C++: #include <iostream>
#include <cmath>

#ifdef M_PI 
double const pi = M_PI;
#else
double const pi = 4*std::atan(1);
#endif

double const degree = pi/180;

int main()
{
  std::cout << "=== radians ===\n";
  std::cout << "sin(pi/3) = " << std::sin(pi/3) << "\n";
  std::cout << "cos(pi/3) = " << std::cos(pi/3) << "\n";
  std::cout << "tan(pi/3) = " << std::tan(pi/3) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5) << "\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5) << "\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5) << "\n";

  std::cout << "\n=== degrees ===\n";
  std::cout << "sin(60°) = " << std::sin(60*degree) << "\n";
  std::cout << "cos(60°) = " << std::cos(60*degree) << "\n";
  std::cout << "tan(60°) = " << std::tan(60*degree) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5)/degree << "°\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5)/degree << "°\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5)/degree << "°\n";

  return 0;
}




Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}
Task: Trigonometric functions


C++: #include <iostream>
#include <cmath>

#ifdef M_PI 
double const pi = M_PI;
#else
double const pi = 4*std::atan(1);
#endif

double const degree = pi/180;

int main()
{
  std::cout << "=== radians ===\n";
  std::cout << "sin(pi/3) = " << std::sin(pi/3) << "\n";
  std::cout << "cos(pi/3) = " << std::cos(pi/3) << "\n";
  std::cout << "tan(pi/3) = " << std::tan(pi/3) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5) << "\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5) << "\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5) << "\n";

  std::cout << "\n=== degrees ===\n";
  std::cout << "sin(60°) = " << std::sin(60*degree) << "\n";
  std::cout << "cos(60°) = " << std::cos(60*degree) << "\n";
  std::cout << "tan(60°) = " << std::tan(60*degree) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5)/degree << "°\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5)/degree << "°\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5)/degree << "°\n";

  return 0;
}






Python: Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from math import degrees, radians, sin, cos, tan, asin, acos, atan, pi
>>> rad, deg = pi/4, 45.0
>>> print("Sine:", sin(rad), sin(radians(deg)))
Sine: 0.7071067811865475 0.7071067811865475
>>> print("Cosine:", cos(rad), cos(radians(deg)))
Cosine: 0.7071067811865476 0.7071067811865476
>>> print("Tangent:", tan(rad), tan(radians(deg)))
Tangent: 0.9999999999999999 0.9999999999999999
>>> arcsine = asin(sin(rad))
>>> print("Arcsine:", arcsine, degrees(arcsine))
Arcsine: 0.7853981633974482 44.99999999999999
>>> arccosine = acos(cos(rad))
>>> print("Arccosine:", arccosine, degrees(arccosine))
Arccosine: 0.7853981633974483 45.0
>>> arctangent = atan(tan(rad))
>>> print("Arctangent:", arctangent, degrees(arctangent))
Arctangent: 0.7853981633974483 45.0
>>>
Task: Trigonometric functions


C++: #include <iostream>
#include <cmath>

#ifdef M_PI 
double const pi = M_PI;
#else
double const pi = 4*std::atan(1);
#endif

double const degree = pi/180;

int main()
{
  std::cout << "=== radians ===\n";
  std::cout << "sin(pi/3) = " << std::sin(pi/3) << "\n";
  std::cout << "cos(pi/3) = " << std::cos(pi/3) << "\n";
  std::cout << "tan(pi/3) = " << std::tan(pi/3) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5) << "\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5) << "\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5) << "\n";

  std::cout << "\n=== degrees ===\n";
  std::cout << "sin(60°) = " << std::sin(60*degree) << "\n";
  std::cout << "cos(60°) = " << std::cos(60*degree) << "\n";
  std::cout << "tan(60°) = " << std::tan(60*degree) << "\n";
  std::cout << "arcsin(1/2) = " << std::asin(0.5)/degree << "°\n";
  std::cout << "arccos(1/2) = " << std::acos(0.5)/degree << "°\n";
  std::cout << "arctan(1/2) = " << std::atan(0.5)/degree << "°\n";

  return 0;
}







VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Trigonometric functions



C#: using System;

namespace RosettaCode {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("=== radians ===");
            Console.WriteLine("sin (pi/3) = {0}", Math.Sin(Math.PI / 3));
            Console.WriteLine("cos (pi/3) = {0}", Math.Cos(Math.PI / 3));
            Console.WriteLine("tan (pi/3) = {0}", Math.Tan(Math.PI / 3));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5));
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5));
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5));
            Console.WriteLine("");
            Console.WriteLine("=== degrees ===");
            Console.WriteLine("sin (60) = {0}", Math.Sin(60 * Math.PI / 180));
            Console.WriteLine("cos (60) = {0}", Math.Cos(60 * Math.PI / 180));
            Console.WriteLine("tan (60) = {0}", Math.Tan(60 * Math.PI / 180));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5) * 180/ Math.PI);
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5) * 180 / Math.PI);
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5) * 180 / Math.PI);

            Console.ReadLine();
        }
    }
}


Go: package main

import (
    "fmt"
    "math"
)

const d = 30.
const r = d * math.Pi / 180

var s = .5
var c = math.Sqrt(3) / 2
var t = 1 / math.Sqrt(3)

func main() {
    fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
    fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
    fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
    fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
    fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
    fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
    fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
    fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
    fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
    fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
    fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
    fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}
Task: Trigonometric functions



C#: using System;

namespace RosettaCode {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("=== radians ===");
            Console.WriteLine("sin (pi/3) = {0}", Math.Sin(Math.PI / 3));
            Console.WriteLine("cos (pi/3) = {0}", Math.Cos(Math.PI / 3));
            Console.WriteLine("tan (pi/3) = {0}", Math.Tan(Math.PI / 3));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5));
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5));
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5));
            Console.WriteLine("");
            Console.WriteLine("=== degrees ===");
            Console.WriteLine("sin (60) = {0}", Math.Sin(60 * Math.PI / 180));
            Console.WriteLine("cos (60) = {0}", Math.Cos(60 * Math.PI / 180));
            Console.WriteLine("tan (60) = {0}", Math.Tan(60 * Math.PI / 180));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5) * 180/ Math.PI);
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5) * 180 / Math.PI);
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5) * 180 / Math.PI);

            Console.ReadLine();
        }
    }
}





Python: Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from math import degrees, radians, sin, cos, tan, asin, acos, atan, pi
>>> rad, deg = pi/4, 45.0
>>> print("Sine:", sin(rad), sin(radians(deg)))
Sine: 0.7071067811865475 0.7071067811865475
>>> print("Cosine:", cos(rad), cos(radians(deg)))
Cosine: 0.7071067811865476 0.7071067811865476
>>> print("Tangent:", tan(rad), tan(radians(deg)))
Tangent: 0.9999999999999999 0.9999999999999999
>>> arcsine = asin(sin(rad))
>>> print("Arcsine:", arcsine, degrees(arcsine))
Arcsine: 0.7853981633974482 44.99999999999999
>>> arccosine = acos(cos(rad))
>>> print("Arccosine:", arccosine, degrees(arccosine))
Arccosine: 0.7853981633974483 45.0
>>> arctangent = atan(tan(rad))
>>> print("Arctangent:", arctangent, degrees(arctangent))
Arctangent: 0.7853981633974483 45.0
>>>
Task: Trigonometric functions



C#: using System;

namespace RosettaCode {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("=== radians ===");
            Console.WriteLine("sin (pi/3) = {0}", Math.Sin(Math.PI / 3));
            Console.WriteLine("cos (pi/3) = {0}", Math.Cos(Math.PI / 3));
            Console.WriteLine("tan (pi/3) = {0}", Math.Tan(Math.PI / 3));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5));
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5));
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5));
            Console.WriteLine("");
            Console.WriteLine("=== degrees ===");
            Console.WriteLine("sin (60) = {0}", Math.Sin(60 * Math.PI / 180));
            Console.WriteLine("cos (60) = {0}", Math.Cos(60 * Math.PI / 180));
            Console.WriteLine("tan (60) = {0}", Math.Tan(60 * Math.PI / 180));
            Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5) * 180/ Math.PI);
            Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5) * 180 / Math.PI);
            Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5) * 180 / Math.PI);

            Console.ReadLine();
        }
    }
}






VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Trigonometric functions




Go: package main

import (
    "fmt"
    "math"
)

const d = 30.
const r = d * math.Pi / 180

var s = .5
var c = math.Sqrt(3) / 2
var t = 1 / math.Sqrt(3)

func main() {
    fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
    fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
    fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
    fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
    fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
    fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
    fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
    fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
    fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
    fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
    fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
    fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}


Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}
Task: Trigonometric functions





Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}



Python: Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from math import degrees, radians, sin, cos, tan, asin, acos, atan, pi
>>> rad, deg = pi/4, 45.0
>>> print("Sine:", sin(rad), sin(radians(deg)))
Sine: 0.7071067811865475 0.7071067811865475
>>> print("Cosine:", cos(rad), cos(radians(deg)))
Cosine: 0.7071067811865476 0.7071067811865476
>>> print("Tangent:", tan(rad), tan(radians(deg)))
Tangent: 0.9999999999999999 0.9999999999999999
>>> arcsine = asin(sin(rad))
>>> print("Arcsine:", arcsine, degrees(arcsine))
Arcsine: 0.7853981633974482 44.99999999999999
>>> arccosine = acos(cos(rad))
>>> print("Arccosine:", arccosine, degrees(arccosine))
Arccosine: 0.7853981633974483 45.0
>>> arctangent = atan(tan(rad))
>>> print("Arctangent:", arctangent, degrees(arctangent))
Arctangent: 0.7853981633974483 45.0
>>>
Task: Trigonometric functions





Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}




VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Trigonometric functions




Go: package main

import (
    "fmt"
    "math"
)

const d = 30.
const r = d * math.Pi / 180

var s = .5
var c = math.Sqrt(3) / 2
var t = 1 / math.Sqrt(3)

func main() {
    fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
    fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
    fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
    fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
    fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
    fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
    fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
    fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
    fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
    fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
    fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
    fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}




Python: Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from math import degrees, radians, sin, cos, tan, asin, acos, atan, pi
>>> rad, deg = pi/4, 45.0
>>> print("Sine:", sin(rad), sin(radians(deg)))
Sine: 0.7071067811865475 0.7071067811865475
>>> print("Cosine:", cos(rad), cos(radians(deg)))
Cosine: 0.7071067811865476 0.7071067811865476
>>> print("Tangent:", tan(rad), tan(radians(deg)))
Tangent: 0.9999999999999999 0.9999999999999999
>>> arcsine = asin(sin(rad))
>>> print("Arcsine:", arcsine, degrees(arcsine))
Arcsine: 0.7853981633974482 44.99999999999999
>>> arccosine = acos(cos(rad))
>>> print("Arccosine:", arccosine, degrees(arccosine))
Arccosine: 0.7853981633974483 45.0
>>> arctangent = atan(tan(rad))
>>> print("Arctangent:", arctangent, degrees(arctangent))
Arctangent: 0.7853981633974483 45.0
>>>
Task: Trigonometric functions




Go: package main

import (
    "fmt"
    "math"
)

const d = 30.
const r = d * math.Pi / 180

var s = .5
var c = math.Sqrt(3) / 2
var t = 1 / math.Sqrt(3)

func main() {
    fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
    fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
    fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
    fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
    fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
    fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
    fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
    fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
    fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
    fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
    fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
    fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}





VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Trigonometric functions







Python: Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from math import degrees, radians, sin, cos, tan, asin, acos, atan, pi
>>> rad, deg = pi/4, 45.0
>>> print("Sine:", sin(rad), sin(radians(deg)))
Sine: 0.7071067811865475 0.7071067811865475
>>> print("Cosine:", cos(rad), cos(radians(deg)))
Cosine: 0.7071067811865476 0.7071067811865476
>>> print("Tangent:", tan(rad), tan(radians(deg)))
Tangent: 0.9999999999999999 0.9999999999999999
>>> arcsine = asin(sin(rad))
>>> print("Arcsine:", arcsine, degrees(arcsine))
Arcsine: 0.7853981633974482 44.99999999999999
>>> arccosine = acos(cos(rad))
>>> print("Arccosine:", arccosine, degrees(arccosine))
Arccosine: 0.7853981633974483 45.0
>>> arctangent = atan(tan(rad))
>>> print("Arctangent:", arctangent, degrees(arctangent))
Arctangent: 0.7853981633974483 45.0
>>>


VB: Public Sub trig()
    Pi = WorksheetFunction.Pi()
    Debug.Print Sin(Pi / 2)
    Debug.Print Sin(90 * Pi / 180)
    Debug.Print Cos(0)
    Debug.Print Cos(0 * Pi / 180)
    Debug.Print Tan(Pi / 4)
    Debug.Print Tan(45 * Pi / 180)
    Debug.Print WorksheetFunction.Asin(1) * 2
    Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
    Debug.Print WorksheetFunction.Acos(0) * 2
    Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
    Debug.Print Atn(1) * 4
    Debug.Print Atn(1) * 180 / Pi
End Sub
Task: Trigonometric functions

C: #include <math.h>
#include <stdio.h>

int main() {
  double pi = 4 * atan(1);
  
  double radians = pi / 4;
  double degrees = 45.0;
  double temp;
  
  printf("%f %f\n", sin(radians), sin(degrees * pi / 180));
  
  printf("%f %f\n", cos(radians), cos(degrees * pi / 180));
  
  printf("%f %f\n", tan(radians), tan(degrees * pi / 180));
  
  temp = asin(sin(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = acos(cos(radians));
  printf("%f %f\n", temp, temp * 180 / pi);
  
  temp = atan(tan(radians));
  printf("%f %f\n", temp, temp * 180 / pi);

  return 0;
}





Java: public class Trig {
        public static void main(String[] args) {
                
                double radians = Math.PI / 4;
                double degrees = 45.0;
                
                System.out.println(Math.sin(radians) + " " + Math.sin(Math.toRadians(degrees)));
                
                System.out.println(Math.cos(radians) + " " + Math.cos(Math.toRadians(degrees)));
                
                System.out.println(Math.tan(radians) + " " + Math.tan(Math.toRadians(degrees)));
                
                double arcsin = Math.asin(Math.sin(radians));
                System.out.println(arcsin + " " + Math.toDegrees(arcsin));
                
                double arccos = Math.acos(Math.cos(radians));
                System.out.println(arccos + " " + Math.toDegrees(arccos));
                
                double arctan = Math.atan(Math.tan(radians));
                System.out.println(arctan + " " + Math.toDegrees(arctan));
        }
}