JeongJin's Blog

지수와 로그 개념과 자바로 구현해 보기 본문

1일1공부/기초수학

지수와 로그 개념과 자바로 구현해 보기

정진킴 2023. 9. 10. 08:39

1. 제곱

    - 같은 수를 두 번 곱함

    - 거듭 제곱 : 같은 수를 거듭하여 곱합

2. 제곱근

    - a를 제곱하여 b가 될 대 a를 b의 제곱근이라고 함

    - a = 2^3, b= 8

제곱근 예시

public class Main {

    public static void main(String[] args) {
        // 1. 제곱, 제곱근, 지수
        System.out.println("== 제곱 ==");
        System.out.println(Math.pow(2, 3)); // 8
        System.out.println(Math.pow(2, -3)); // 0.125
        System.out.println(Math.pow(-2, -3)); // - 0.125
        System.out.println(Math.pow(2, 30)); // 1.073741824E9
        System.out.printf("%.0f\n", Math.pow(2, 30)); // 1073741824

        System.out.println("== 제곱근 ==");
        System.out.println(Math.sqrt(16)); // 4
        System.out.println(Math.pow(16, 1.0 / 2)); // 4
    }

}

 

3. 로그

    - a가 b가 되기 위해 제곱해야 하는 수

로그 예시

public class Main {

    public static void main(String[] args) {
        System.out.println("== 로그 ==");
        System.out.println(Math.E); // 2.718281828459045
        System.out.println(Math.log(Math.E)); // 1
        System.out.println(Math.log10(1000)); // 3
    }

}