Документация Engee

Automatic differentiation through spherical harmonic transforms

Страница в процессе перевода.

This example finds a positive value of in:

for some such that . We do this by using derivative information through:

using FastTransforms, LinearAlgebra

The colatitudinal grid (mod ):

N = 15
θ = (0.5:N-0.5)/N
0.03333333333333333:0.06666666666666667:0.9666666666666667

The longitudinal grid (mod ):

M = 2*N-1
φ = (0:M-1)*2/M
0.0:0.06896551724137931:1.9310344827586206

We precompute a spherical harmonic—​Fourier plan:

P = plan_sph2fourier(Float64, N)
FastTransforms Spherical harmonic--Fourier plan for 15×29-element array of Float64

And an FFTW Fourier analysis plan on :

PA = plan_sph_analysis(Float64, N, M)
FastTransforms plan for FFTW Fourier analysis on the sphere for 15×29-element array of Float64

Our choice of and angular parametrization of :

k = [2/7, 3/7, 6/7]
r = (θ,φ) -> [sinpi(θ)*cospi(φ), sinpi(θ)*sinpi(φ), cospi(θ)]
#1 (generic function with 1 method)

Our initial guess for :

λ = 1.0
1.0

Then we run Newton iteration and grab an espresso:

for _ in 1:7
    F = [sin(λ*(k⋅r(θ,φ))) for θ in θ, φ in φ]
    Fλ = [(k⋅r(θ,φ))*cos(λ*(k⋅r(θ,φ))) for θ in θ, φ in φ]
    U = P\(PA*F)
    Uλ = P\(PA*Fλ)
    global λ = λ - (norm(U)^2-1)/(2*sum(U.*Uλ))
    println("λ: $(rpad(λ, 18)) and the 2-norm: $(rpad(norm(U), 18))")
end
λ: 0.5565017029393282 and the 2-norm: 1.8510924318185522
λ: 0.5031571262839712 and the 2-norm: 1.104184591487036
λ: 0.5010418434316171 and the 2-norm: 1.0040147091934828
λ: 0.5010383094266805 and the 2-norm: 1.0000066984258862
λ: 0.5010383094167955 and the 2-norm: 1.0000000000187361
λ: 0.5010383094167953 and the 2-norm: 1.0000000000000004
λ: 0.5010383094167954 and the 2-norm: 0.9999999999999999

This page was generated using Literate.jl.