역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

 C 언어나 C++ 언어에서는 asin 함수로 구현되어 있다.

아래의 소스는 Visual C++ 또는 gcc 로 컴파일되는 소스이다. 실행 결과는 같다.

/*
 * Filename: testArcSine.c
 *
 * Compile: cl testArcSine.c
 * Execute: testArcSine
 *
 *  Or
 *
 * Cpmpile: gcc -o testArcSine testArcSine.c
 * Execute: ./testArcSine
 *
 * Date: 2013. 1. 1.
 * Copyright (c) pkim _AT_ scripts.pe.kr
 */

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

double asinh(double x) {
    double y = log(x + sqrt(x*x + 1));
    return y;
}

double acosh(double x) {
    double y = log(x + sqrt(x*x - 1));
    return y;
}

int main() {

    double u, v;
    double x = -0.9;
    double y = asin(x);

    printf("y = asin(%g) = %.9f\n", x,  y);
    printf("sin(y) = sin(%.9f) = %g\n", y, sin(y));
    printf("\n");

    x = 1.1;
    u = acosh(x);
    printf("u = acosh(%g) = %.10f\n", x,  u);

    v = asinh(x);
    printf("v = asinh(%g) = %.10f\n", x, v);

    printf("cosh(u) = cosh(%.10f) = %g\n", u, cosh(u));
    printf("sinh(v) = sinh(%.10f) = %g\n", v, sinh(v));

    return 0;
}

/*
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9

u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
*/

 

 

 

Posted by Scripter
,

역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

Ruby 언어에서는 Math::asin() 함수로 구현되어 있다.

 

다음 소스는 Ruby, JRuby 중 어느 것으로 실행해도 같은 결과를 얻는다.

 

# -*- encoding: utf-8 -*-

# Filename: testArcSine.rb
#
# Execute: ruby testArcSine.rb
#
#  Or
#
# Execute: jruby testArcSine.rb
#
# Date: 2013. 1. 1.
# Copyright (c) pkim _AT_ scripts.pe.kr

def sin(x)
    y = Math::sin(x)
    return y
end

def asin(x)
    y = Math::asin(x)
    return y
end

def sinh(x)
    y = Math::sinh(x)
    return y
end

def cosh(x)
    y = Math::cosh(x)
    return y
end

def asinh(x)
    y = Math::log(x + Math::sqrt(x*x + 1))
    return y
end

def acosh(x)
    y = Math::log(x + Math::sqrt(x*x - 1))
    return y
end


x = -0.9
y = asin(x)
print "y = asin(%.1g) = %.9f\n" % [x,  y]
print "sin(y) = sin(%.9f) = %.1g\n" % [y, sin(y)]
print "\n"

x = 1.1
u = acosh(x)
print "u = acosh(%3.2g) = %.10f\n" % [x,  u]

v = asinh(x)
print "v = asinh(%3.2g) = %.10f\n" % [x,  v]

print "cosh(u) = cosh(%.10f) = %3.2g\n" % [u,  cosh(u)]
print "sinh(v) = sinh(%.10f) = %3.2g\n" % [v,  sinh(v)]

=begin
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9

u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
=end

 

 

Posted by Scripter
,

역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

Python 언어에서는 math.asin() 함수로 구현되어 있다.

이를 사용하기 위해서는 구문

import math

이 필요하다.

 

다음 소스는 Python, Jython, IronPython 중 어느 것으로 실행해도 같은 결과를 얻는다.

특히 IronPython 으로는 옵션 /target:exe 를 사용하여 컴파일하면 실행파일 testArcSine.exe 및 testArcSine.dll 파일을 얻는다, dll 파일이 있어야 exe 파일이 실행된다.

 

# -*- encoding: utf-8 -*-

# Filename: testArcSine.py
#
# Execute: python testArcSine.py
#
#  Or
#
# Execute: jython testArcSine.py
#
#  Or
#
# Execute: ipy testArcSine.py
#
#  Or
#
# Compile: ipy %IRONPYTHON_HOME%\Tools\Scripts\pyc.py /target:exe /main:testArcSine.py
# Execute: testArcSine
#
# Date: 2013. 1. 1.
# Copyright (c) pkim _AT_ scripts.pe.kr

import math

def sin(x):
            y = math.sin(x)
            return y

def asin(x):
            y = math.asin(x)
            return y

def sinh(x):
            y = math.sinh(x)
            return y

def cosh(x):
            y = math.cosh(x)
            return y

def asinh(x):
            y = math.log(x + math.sqrt(x*x + 1))
            return y

def acosh(x):
            y = math.log(x + math.sqrt(x*x - 1))
            return y


if __name__ == "__main__":
            x = -0.9
            y = asin(x)
            print "y = asin(%.1g) = %.9f" % (x,  y)
            print "sin(y) = sin(%.9f) = %.1g" % (y, sin(y))
            print

            x = 1.1
            u = acosh(x)
            print "u = acosh(%3.2g) = %.10f" % (x,  u)

            v = asinh(x)
            print "v = asinh(%3.2g) = %.10f" % (x,  v)

            print "cosh(u) = cosh(%.10f) = %3.2g" % (u,  cosh(u))
            print "sinh(v) = sinh(%.10f) = %3.2g" % (v,  sinh(v))

"""
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9

u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
"""

 

 

 

Posted by Scripter
,

역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

Java 언어에서는 java.lang.Math.asin(double) 메소드로 구현되어 있다.

 

/*
 * Filename: TestArcSine.java
 *
 * Compile: javac -d . TestArcSine.java
 * Execute: java TestArcSine
 *
 * Date: 2013. 1. 1.
 * Copyright (c) pkim _AT_ scripts.pe.kr
 */

public class TestArcSine {
        public static double sin(double x)  {
            double y = Math.sin(x);
            return y;
        }

        public static double asin(double x) {
            double y = Math.asin(x);
            return y;
        }

        public static double sinh(double x) {
            double y = Math.sinh(x);
            return y;
        }

        public static double cosh(double x) {
            double y = Math.cosh(x);
            return y;
        }

        public static double asinh(double x)
        {
            double y = Math.log(x + Math.sqrt(x*x + 1));
            return y;
        }

        public static double acosh(double x)
        {
            double y = Math.log(x + Math.sqrt(x*x - 1));
            return y;
        }

        public static void main(String[] args)
        {
            double x = -0.9;
            double y = asin(x);
            System.out.printf("y = asin(%.1g) = %.9f\n", x,  y);
            System.out.printf("sin(y) = sin(%.9f) = %.1g\n",  y, sin(y));
            System.out.printf("\n");

            x = 1.1;
            double u = acosh(x);
            System.out.printf("u = acosh(%3.2g) = %.10f\n", x,  u);

            double v = asinh(x);
            System.out.printf("v = asinh(%3.2g) = %.10f\n", x,  v);

            System.out.printf("cosh(u) = cosh(%.10f) = %3.2g\n", u,  cosh(u));
            System.out.printf("sinh(v) = sinh(%.10f) = %3.2g\n", v,  sinh(v));
        }
}

/*
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9

u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
*/

 

 

Posted by Scripter
,

역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

C# 언어에서는 Math.Asin 함수로 구현되어 있다.

아래의 소스는 Visual C# 으로 컴파일되는 소스이다.

/*
 * Filename: testArcSine.cs
 *
 * Compile: csc testArcSine.cs /reference:System.Numerics.dll
 * Execute: testArcSine
 *
 * Date: 2013. 1. 1.
 * Copyright (c) pkim _AT_ scripts.pe.kr
 */

using System;
using System.Numerics;

namespace ExperimentConsole
{
    class Program
    {
        public static double sin(double x)
        {
            double y = Math.Sin(x);
            return y;
        }

        public static double asin(double x)
        {
            double y = Math.Asin(x);
            return y;
        }

        public static double sinh(double x)
        {
            double y = Math.Sinh(x);
            return y;
        }

        public static double cosh(double x)
        {
            double y = Math.Cosh(x);
            return y;
        }

        public static double asinh(double x)
        {
            double y = Math.Log(x + Math.Sqrt(x*x + 1));
            return y;
        }

        public static double acosh(double x)
        {
            double y = Math.Log(x + Math.Sqrt(x*x - 1));
            return y;
        }

        public static void Main(string[] args)
        {
            double x = -0.9;
            double y = asin(x);
            Console.WriteLine("y = asin({0}) = {1:F9}", x,  y);
            Console.WriteLine("sin(y) = sin({0:F9}) = {1}",  y, sin(y));
            Console.WriteLine();

            x = 1.1;
            double u = acosh(x);
            Console.WriteLine("u = acosh({0}) = {1:F10}", x,  u);

            double v = asinh(x);
            Console.WriteLine("v = asinh({0}) = {1:F10}", x,  v);

            Console.WriteLine("cosh(u) = cosh({0:F10}) = {1}", u,  cosh(u));
            Console.WriteLine("sinh(v) = sinh({0:F10}) = {1}", v,  sinh(v));
        }
    }
}

/*
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9

u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
*/

 

 

Posted by Scripter
,

역삼각함수란 삼각함수의 역함수를 의미하고,

역쌍곡선함수란 쌍곡선함수의 역함수를 의미한다.

수학에서 sin 함수의 역함수는 arcsin 으로 표기되는데,

 C 언어나 C++ 언어에서는 asin 함수로 구현되어 있다.

아래의 소스는 Visual C++ 또는 g++ 로 컴파일되는 소스이다. 실행 결과는 같다.

 

/*
 * Filename: testArcSine.cpp
 *
 * Compile: cl /EHsc testArcSine.cpp
 * Execute: testArcSine
 *
 * Or
 *
 * Cpmpile: g++ -o testArcSine testArcSine.cpp
 * Execute: ./testArcSine
 *
 * Date: 2013. 1. 1.
 * Copyright (c) pkim _AT_ scripts.pe.kr
 */
 
#include <iostream>
#include <cmath>

double asinh(double x) {
    double y = log(x + sqrt(x*x + 1));
    return y;
}

double acosh(double x) {
    double y = log(x + sqrt(x*x - 1));
    return y;
}

int main() {
 
 std::cout.precision(10);
 
 double x = -0.9;
 double y = asin(x);
 std::cout << "y = asin(" << x << ") = " << y << std::endl;
 std::cout << "sin(y) = sin(" << y << ") = " << sin(y) << std::endl;
  std::cout << std::endl;
 
 x = 1.1;
 double u = acosh(x);
 std::cout << "u = acosh(" << x << ") = " << u << std::endl;
 
 double v = asinh(x);
 std::cout << "v = asinh(" << x << ") = " << v << std::endl;
 
 std::cout << "cosh(u) = cosh(" << u << ") = " << cosh(u) << std::endl;
 std::cout << "sinh(v) = sinh(" << v << ") = " << sinh(v) << std::endl;
 
    return 0;
}

/*
Output:
y = asin(-0.9) = -1.119769515
sin(y) = sin(-1.119769515) = -0.9

u = acosh(1.1) = 0.4435682544
v = asinh(1.1) = 0.9503469298
cosh(u) = cosh(0.4435682544) = 1.1
sinh(v) = sinh(0.9503469298) = 1.1
*/

 

 

Posted by Scripter
,