# Satellitetoolbox Legendre

> SatelliteToolboxLegendre.jl for computing associated Legendre functions and derivatives. Use when working with spherical harmonics, gravity field expansions, or geomagnetic field computations.

- Skill: `majiayu000/satellitetoolbox-legendre` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds add majiayu000/satellitetoolbox-legendre`
- Raw SKILL.md: https://api.skillmd.com/api/skills/majiayu000/satellitetoolbox-legendre/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: majiayu000 (https://skillmd.com/u/majiayu000)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/majiayu000/satellitetoolbox-legendre

---


# SatelliteToolboxLegendre.jl

Associated Legendre functions and derivatives with multiple normalization options. Repo: [JuliaSpace/SatelliteToolboxLegendre.jl](https://github.com/JuliaSpace/SatelliteToolboxLegendre.jl)

## Computing Legendre Functions

```julia
# P[n+1, m+1] = P_{n,m}[cos(ϕ)]
P = legendre(Val(:full), ϕ, n_max)                    # Full normalization
P = legendre(Val(:schmidt), ϕ, n_max, m_max)          # Schmidt semi-normalization
P = legendre(Val(:unnormalized), ϕ, n_max)            # Unnormalized

# In-place (zero-allocation)
legendre!(Val(:full), P, ϕ, n_max, m_max)
```

## Computing Derivatives

```julia
(dP, P) = dlegendre(Val(:full), ϕ, n_max)             # Returns both dP and P
dlegendre!(dP, ϕ, P, n_max, m_max)                     # In-place (P must be pre-computed)
```

## Key Conventions
- First argument `N` selects normalization: `Val(:full)`, `Val(:schmidt)`, `Val(:unnormalized)`
- Angle `ϕ` in **radians**
- Indexing: `P[n+1, m+1]` for degree `n`, order `m`
- Optional `ph_term=true` includes Condon-Shortley phase `(-1)^m`
- In-place variants infer `n_max`/`m_max` from matrix dimensions if omitted
- Zero external dependencies (pure Julia)

