Namespaces
Variants

std:: legendre, std:: legendref, std:: legendrel

From cppreference.net
double legendre ( unsigned int n, double x ) ;

double legendre ( unsigned int n, float x ) ;
double legendre ( unsigned int n, long double x ) ;
float legendref ( unsigned int n, float x ) ;

long double legendrel ( unsigned int n, long double x ) ;
(1)
double legendre ( unsigned int n, IntegralType x ) ;
(2)
1) 차수 n 와 인수 x 의 비연관 르장드르 다항식 을 계산합니다.
2) 모든 integral type 인자를 받는 오버로드 집합 또는 함수 템플릿. (1) 과 동등하며, 인자를 double 로 캐스팅한 후 적용됩니다.

모든 특수 함수와 마찬가지로, legendre 함수는 구현체가 __STDCPP_MATH_SPEC_FUNCS__ 를 최소 201003L 값으로 정의하고, 사용자가 표준 라이브러리 헤더를 포함하기 전에 __STDCPP_WANT_MATH_SPEC_FUNCS__ 를 정의한 경우에만 <cmath> 에서 사용 가능함이 보장됩니다.

목차

매개변수

n - 다항식의 차수
x - 인자, 부동 소수점 또는 정수 타입의 값

반환값

If no errors occur, value of the order- n unassociated Legendre polynomial of x , that is
1
2 n
n!
d n
dx n
(x 2
- 1) n
, is returned.

오류 처리

오류는 math_errhandling 에 지정된 대로 보고될 수 있습니다.

  • 인수가 NaN이면, NaN이 반환되고 도메인 오류가 보고되지 않습니다.
  • 이 함수는 |x| > 1 인 경우에 대해 정의될 필요가 없습니다.
  • 만약 n 이 128보다 크거나 같으면, 그 동작은 구현에 따라 정의됩니다.

참고 사항

TR 29124을 지원하지 않지만 TR 19768을 지원하는 구현체들은 이 함수를 tr1/cmath 헤더와 std::tr1 네임스페이스에서 제공합니다.

이 함수의 구현체는 또한 boost.math에서 사용 가능합니다 .

처음 몇 개의 르장드르 다항식은 다음과 같습니다:

  • legendre(0, x) = 1 .
  • legendre(1, x) = x .
  • legendre(2, x) =
    1
    2
    (3x 2
    - 1)
    .
  • legendre(3, x) =
    1
    2
    (5x 3
    - 3x)
    .
  • legendre(4, x) =
    1
    8
    (35x 4
    - 30x 2
    + 3)
    .

예제

(gcc 6.0에서 표시된 대로 작동)

#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1
#include <cmath>
#include <iostream>
double P3(double x)
{
    return 0.5 * (5 * std::pow(x, 3) - 3 * x);
}
double P4(double x)
{
    return 0.125 * (35 * std::pow(x, 4) - 30 * x * x + 3);
}
int main()
{
    // spot-checks
    std::cout << std::legendre(3, 0.25) << '=' << P3(0.25) << '\n'
              << std::legendre(4, 0.25) << '=' << P4(0.25) << '\n';
}

출력:

-0.335938=-0.335938
0.157715=0.157715

참고 항목

라게르 다항식
(함수)
에르미트 다항식
(함수)

외부 링크

Weisstein, Eric W. "Legendre Polynomial." MathWorld — Wolfram 웹 리소스에서 발췌.