kyosu v0.1.0
Complex Without Complexes
Loading...
Searching...
No Matches

◆ legendre

auto kyosu::legendre = eve::functor<legendre_t>
inlineconstexpr

Computes the value of the Legendre and associated Legendre functions of order n ( and m) at x:

For positive integer n the standard legendre functions are polynomials:

  • The Legendre polynomial of order n is given by \(\displaystyle \mbox{L}_{n}(x) = \frac{e^x}{n!}\frac{d^n}{dx^n}(x^ne^{-x})\).

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace eve
{
// Regular overload
auto constexpr legendre(kyosu::concepts::real auto n, kyosu::concepts::cayley_dickson auto z) noexcept; // 1
auto constexpr legendre(kyosu::concepts::real auto n, kyosu::concepts::real auto z) noexcept; // 1
// Lanes masking
constexpr auto legendre[conditional_expr auto c](/* any previous overload */) noexcept; // 2
constexpr auto legendre[logical_value auto m](/* any previous overload */) noexcept; // 2
// Semantic options
constexpr auto legendre[successor](integral_value auto n,
kyosu::concepts::cayley_dickson auto pnm1) noexcept; // 3
}
General Cayley-dickson concept.
Definition concepts.hpp:41
General real concept.
Definition concepts.hpp:48
constexpr auto legendre
Computes the value of the Legendre and associated Legendre functions of order n ( and m) at x:
Definition legendre.hpp:114

Parameters

  • n: real positive argument.
  • z: cayley_dickson or real argument
  • pn, pnm1: cayley_dickson arguments
  • c: Conditional expression masking the operation.
  • m: Logical value masking the operation.

Return value

  1. The value of the Legendre function of order n at z is returned.
  2. The operation is performed conditionnaly.
  3. The successor option implements the three term recurrence relation for the (associated) Legendre functions, \(\displaystyle \mbox{P}_{l+1} = \left((2l+1)\mbox{P}_{l}(x)-l\mbox{P}_{l-1}(x)\right)/(l+1)\).

External references

Example

// revision 1
#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
eve::wide xd{0.5, -1.5, 0.1, -1.0, 19.0, 25.0, 21.5, 10000.0};
eve::wide n{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
double x(0.5);
std::cout << "<- xd = " << xd << '\n';
std::cout << "<- n = " << n << '\n';
std::cout << "<- x = " << x << '\n';
auto ln = kyosu::legendre(n, x);
auto lnp1 = kyosu::legendre(n + 1, x);
auto lnp2 = kyosu::legendre(n + 2, x);
std::cout << "-> legendre(n, x) = " << ln << '\n';
std::cout << "-> legendre(n+1, x) = " << lnp1 << '\n';
std::cout << "-> legendre(n+2, x) = " << lnp2 << '\n';
std::cout << "-> legendre[eve::successor](n+1, x, lnp1, ln) = " << kyosu::legendre(n + 1, x, lnp1, ln) << '\n';
std::cout << "-> legendre[eve::ignore_last(2)](n, xd) = " << kyosu::legendre[eve::ignore_last(2)](n, xd)
<< '\n';
std::cout << "-> legendre[n > 3](n, xd) = " << kyosu::legendre[n > 3](n, xd) << '\n';
std::cout << "-> legendre(3.0, xd) = " << kyosu::legendre(3.0, xd) << '\n';
std::cout << "-> legendre(n, 2.0) = " << kyosu::legendre(n, 2.0) << '\n';
std::cout << "-> legendre(n, x) = " << kyosu::legendre(n, x) << '\n';
}