Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
airy_aibessel_j0bessel_j1bessel_y0bessel_y1chebyshev_polynomial_tchebyshev_polynomial_uchebyshev_polynomial_vchebyshev_polynomial_wentrerferfcerfcxerfinvgammaincgammaincchermite_polynomial_hhermite_polynomial_hei0ei1i1elaguerre_polynomial_llegendre_polynomial_plog_ndtrlogitmodified_bessel_i0modified_bessel_i1modified_bessel_k0modified_bessel_k1multigammalnndtrndtripolygammascaled_modified_bessel_k0scaled_modified_bessel_k1shifted_chebyshev_polynomial_tshifted_chebyshev_polynomial_ushifted_chebyshev_polynomial_vshifted_chebyshev_polynomial_wsincSpecialBinaryOptionsSpecialLogitOptionsSpecialPolynomialOptionsSpecialSoftmaxOptionsSpecialUnaryOptionsspherical_bessel_j0xlog1pyzeta
absacosacoshAdaptivePool1dShapeAdaptivePool2dShapeaddaddbmmAddbmmOptionsaddcdivAddcdivOptionsaddcmulAddcmulOptionsaddmmAddmmOptionsaddmvAddmvOptionsaddrAddrOptionsadjointallallcloseAllcloseOptionsAlphaBetaOptionsamaxaminaminmaxAminmaxOptionsangleanyapplyOutarangeare_deterministic_algorithms_enabledargmaxargminargsortargwhereas_stridedas_tensorasinasinhAssertNoShapeErrorAssertNotErrorAsStridedOptionsAtat_error_index_out_of_boundsatanatan2atanhatleast_1datleast_2datleast_3dAtShapeautocast_decrement_nestingautocast_increment_nestingautograd_gradient_mismatch_errorautograd_not_registered_errorAutogradConfigAutogradDeviceAutogradDTypeAutogradEntryAutogradHandleAutogradHandleImplAxesRecordBackwardFnbaddbmmBaddbmmOptionsbartlett_windowBaseKernelConfigbatch_dimensions_do_not_match_errorbernoulliBernoulliOptionsBinaryBackwardFnBinaryBroadcastResultBinaryDTypeBinaryKernelConfigCPUBinaryKernelCPUBinaryOpConfigBinaryOpNamesBinaryOpSchemaBinaryOptionsbincountBincountOptionsbitwise_andbitwise_left_shiftbitwise_notbitwise_orbitwise_right_shiftbitwise_xorblackman_windowblock_diagbmmBooleanDTypeRulebroadcast_error_incompatible_dimensionsbroadcast_shapesbroadcast_tensorsbroadcast_toBroadcastShapeBroadcastShapeRulebroadcastShapesbucketizeBucketizeOptionsBufferUsagebuildEinopsErrorbuildErrorMessagecanBroadcastTocartesian_prodcatCatOptionsCatShapeCauchyOptionscdistCdistOptionsceilceluCeluFunctionalOptionschain_matmulCheckShapeErrorCholeskyShapechunkchunk_error_dim_out_of_rangeChunkOptionsclampClampOptionsclear_autocast_cacheclearEinopsCacheclearEinsumCacheclonecolumn_stackcombinationsCombinationsOptionscompiled_with_cxx11_abicomplexconjconj_physicalcontiguousConv1dShapeConv2dShapeConv3dShapeConvTranspose2dShapecopysigncorrcoefcoscoshcount_nonzeroCountNonzeroOptionscovcoverage_reportcoverageReportCoverageReportCovOptionsCPUForwardFnCPUKernelConfigCPUKernelEntryCPUOnlyResultCPUTensorDatacreateCumExtremeResultcreateTorchCreationOpSchemaCumExtremeResultcummaxcummincumprodCumShapecumsumcumulative_trapezoidCumulativeOptionsCumulativeOptionsWithDimdeg2raddetachDeterministicOptionsDetShapeDevicedevice_error_requiresDeviceBufferDeviceCapabilitiesDeviceCheckedResultDeviceConfigDeviceContextDeviceEntryDeviceHandleDeviceInputDeviceOptionsDeviceRegistryDeviceTypediagdiag_embedDiagEmbedOptionsdiagflatDiagflatOptionsDiagFlatOptionsdiagonal_scatterDiagonalOptionsDiagonalScatterOptionsDiagOptionsDiagShapediffDiffOptionsdigammadimension_error_out_of_rangeDispatchConfigdistDistOptionsdivdotDotShapeRuleDoubleDoubleDimdropoutDropoutFunctionalOptionsdsplitdstackDTypedtype_already_registered_errordtype_components_mismatch_errordtype_not_found_errorDTypeComponentsDTypeConfigDTypeCoverageReportDTypeDisplayConfigDTypeEntryDTypeHandleDTypeHandleImplDTypeInfoDTypeRegistryDTypeRuleDTypeSerializationConfigDynamicShapeEigShapeeinops_error_ambiguous_decompositioneinops_error_anonymous_in_outputeinops_error_dimension_mismatcheinops_error_invalid_patterneinops_error_reduce_undefined_outputeinops_error_repeat_missing_sizeeinops_error_undefined_axiseinsumeinsum_error_dimension_mismatcheinsum_error_index_out_of_rangeeinsum_error_invalid_equationeinsum_error_invalid_sublist_elementeinsum_error_operand_count_mismatcheinsum_error_subscript_rank_mismatcheinsum_error_unknown_output_indexEinsumOptionsEinsumOutputShapeEllipsiseluelu_EluFunctionalOptionsembedding_bag_error_requires_2d_inputemptyempty_cacheempty_likeeqequalerferfcerfinvexpexp2expandexpand_asexpand_error_incompatibleExpandShapeexpm1ExponentialOptionseyeEyeOptionsfftFFTOptionsfindKernelWithPredicatefindSimilarPatternsflattenFlattenOptionsFlattenShapeflipflip_error_dim_out_of_rangefliplrFlipShapeflipudfloat_powerFloatDTypeRulefloorfloor_dividefmaxfminfmodformatEquationErrorformatShapefracfrexpfrombufferfullfull_likefunction_already_registered_errorFunctionConfigFunctionEntryFunctionHandlegathergather_error_dim_out_of_rangeGatherShapegcdgegeluGeometricOptionsget_autocast_cpu_dtypeget_autocast_gpu_dtypeget_autocast_ipu_dtypeget_autocast_xla_dtypeget_default_deviceget_default_dtypeget_deterministic_debug_modeget_device_configget_device_contextget_device_moduleget_dtype_infoget_file_pathget_float32_matmul_precisionget_num_interop_threadsget_num_threadsget_op_infoget_printoptionsget_real_dtypeget_rng_stategetAutogradgetDTypegetEinopsCacheSizegetEinsumCacheSizegetFunctiongetKernelgetMethodgetOpInfoGetOpKindGetOpSchemagetScalarKernelgluGluFunctionalOptionsGradContextGradFnGradientsForgtHalfHalfDimhamming_windowhann_windowhardshrinkhardsigmoidhardswishhardtanhhardtanh_HardtanhFunctionalOptionshas_autogradhas_devicehas_dtypehas_kernelhasAutogradhasDTypehasFunctionhasKernelhasMethodhasScalarKernelHasShapeErrorheavisidehistcHistcOptionshistogramHistogramOptionsHistogramResulthsplithstackhypoti0IdentityShapeifftimagindex_addindex_copyindex_fillindex_putindex_reduceindex_selectindex_select_error_dim_out_of_rangeIndexPutOptionsIndexSelectShapeIndexSpecIndicesOptionsIndicesSpecinitialize_deviceInputsForInsertDiminvalid_config_errorinverseInverseShapeirfftis_anomaly_check_nan_enabledis_anomaly_enabledis_autocast_cache_enabledis_autocast_cpu_enabledis_autocast_ipu_enabledis_autocast_xla_enabledis_complexis_complex_dtypeis_cpu_only_modeis_deterministic_algorithms_warn_only_enabledis_floating_pointis_floating_point_dtypeis_inference_mode_enabledis_nonzerois_tensoris_warn_always_enabledis_webgpu_availableIs2DIsAtLeast1DIsBinaryOpIsBinaryOpNameiscloseIscloseOptionsisfiniteisinisinfisnanisneginfisposinfisrealIsReductionOpIsReductionOpNameIsRegistryErrorIsShapeErroristftISTFTOptionsIsUnaryOpIsUnaryOpNameitem_error_not_scalarItemResultkaiser_windowKaiserWindowOptionskernel_not_registered_errorkernel_signature_mismatch_errorKernelConfigKernelConfigWebGPUKernelEntryKernelHandleKernelInfoKernelPredicateKernelRegistryKernelWebGPUkronkthvalueKthvalueOptionslcmldexpleleaky_reluleaky_relu_LeakyReluFunctionalOptionslerplevenshteinDistancelgammalinalg_error_not_square_matrixlinalg_error_requires_2dlinalg_error_requires_at_least_2dlinearlinspacelist_custom_deviceslist_custom_dtypeslist_deviceslist_dtypeslist_functionslist_kernelslist_methodslist_opslistCustomDTypeslistDTypeslistFunctionslistKernelsListKernelsOptionslistMethodslistOpsListOpsOptionsloglog_softmaxlog10log1plog2logaddexplogaddexp2logcumsumexplogical_andlogical_notlogical_orlogical_xorLogitOptionsLogNormalOptionsLogOptionslogsigmoidlogspacelogsumexpLogsumexpOptionsltLUShapeLuSolveOptionsmasked_fillmasked_selectmasked_select_asyncMaskSpecmatmulmatmul_error_inner_dimensions_do_not_matchMatmul2DShapeMatmulShapeMatmulShapeRuleMatrixTransposeShapemaxmaximummeanmedianmemory_statsmemory_summarymeshgridmethod_already_registered_errormethod_dtype_not_supported_errorMethodConfigMethodEntryMethodHandleminminimummishmmMMShapeRulemodemovedimmsortmulmultinomialmultinomial_asyncMultinomialAsyncOptionsMultinomialOptionsMultiplyBymvMVShapeRulenan_to_numnanmeannanmediannanquantileNanReductionOptionsnansumNanToNumOptionsnarrownarrow_copynarrow_error_length_exceeds_boundsnarrow_error_start_out_of_boundsNarrowShapeneneedsBroadcastnegNegativeDimnextafternonzeroNonzeroOptionsnormnormalNormalOptionsNormOptionsnumelonesones_likeop_kind_mismatch_errorop_not_found_errorOpCoverageEntryOpInfoOpKindOpNameOpSchemaOpSchemasouterOuterShapepackPackShapepermutepermute_error_dimension_count_mismatchPermuteShapepoissonpolarPool1dShapePool2dShapePool3dShapepositivepowpreluPrintOptionsprodprofiler_allow_cudagraph_cupti_lazy_reinit_cuda12promote_typesPromoteDTypeRulePutOptionsquantileQuantileOptionsrad2degrandrand_likerandintrandint_likeRandintLikeOptionsRandintOptionsrandnrandn_likeRandomLikeOptionsRandomOptionsrandpermRangeSpecRankravelrealrearrangeRearrangeOptionsRearrangeShapereciprocalreduceReduceOperationReduceOptionsReduceShapeReductionKernelConfigCPUReductionKernelCPUReductionOpNamesReductionOpSchemaReductionOptionsReductionShapeRuleregister_backwardregister_deviceregister_dtyperegister_forwardregister_functionregister_methodregister_scalar_forwardregisterAutogradRegisterBackwardOptionsregisterBinaryOpregisterDTypeRegisterDTypeOptionsRegisteredDTyperegisterFunctionRegisterFunctionOptionsregisterKernelRegisterKernelOptionsregisterMethodRegisterMethodOptionsregisterScalarKernelregisterUnaryOpregistration_failed_errorrelurelu_relu6ReluFunctionalOptionsremainderRemoveDimrepeatrepeat_interleaveRepeatInterleaveOptionsRepeatOptionsRepeatShapeReplaceDimrequireWebGPUreset_peak_memory_statsreshapeReshapeShaperesult_typerfftrollRollOptionsrot90Rot90Optionsroundrrelurrelu_RreluFunctionalOptionsrsqrtSafeExpandShapeSameDTypeRuleSameShapeRuleSaveForBackwardScalarCPUForwardFnScalarCPUKernelConfigScalarKernelEntryScalarKernelHandleScalarWebGPUKernelConfigScaleDimscatterscatter_addscatter_add_scatter_error_dim_out_of_rangescatter_reducescatter_reduce_ScatterReduceOptionsScatterShapesearchsortedSearchSortedOptionsselectselect_error_index_out_of_boundsselect_scatterSelectShapeseluset_default_deviceset_default_tensor_typeset_deterministic_debug_modeset_float32_matmul_precisionset_printoptionsset_warn_alwaysSetupContextFnShapeShapeCheckedResultShapedTensorShapeErrorMessageShapeOpSchemaShapeRulesigmoidsignsignbitsilusinsincsinhSizeOptionsslice_error_out_of_boundsslice_scatterSliceOptionsSliceScatterOptionsSliceShapeSliceSpecsoftmaxsoftmax_error_dim_out_of_rangeSoftmaxShapesoftminSoftminFunctionalOptionssoftplusSoftplusFunctionalOptionssoftshrinksoftsignsortSortOptionssplitsplit_error_dim_out_of_rangeSplitOptionssqrtsquaresqueezeSqueezeOptionsSqueezeShapestackStackOptionsStackShapestdstd_meanStdVarMeanOptionsStdVarOptionsstftSTFTOptionsStrideOptionssubSublistSublistElementSubscriptIndexsumSVDShapeswapaxessym_floatsym_intsym_notttaketake_along_dimTakeAlongDimOptionstantanhtanhshrinktensortensor_splitTensorCreatorTensorDatatensordotTensordotOptionsTensorLikeTensorMetaTensorOptionsTensorStoragethresholdthreshold_tileTileShapeToOptionstopkTopkOptionsTorchtraceTraceShapetransposetranspose_dims_error_out_of_rangetranspose_error_requires_2d_tensorTransposeDimsShapeTransposeDimsShapeCheckedTransposeShapetrapezoidTrapezoidOptionsTriangularOptionstriltril_indicesTriOptionsTripletriutriu_indicestrue_dividetruncTupleOfLengthTypedArrayTypedArrayForTypedStorageTypeOptionsUnaryBackwardFnUnaryDTypeUnaryKernelConfigCPUUnaryKernelCPUUnaryOpConfigUnaryOpFnUnaryOpNamesUnaryOpParamsUnaryOpSchemaUnaryOptionsunbindunbind_error_dim_out_of_rangeUnbindOptionsunflattenUniformOptionsuniqueunique_consecutiveUniqueConsecutiveOptionsUniqueOptionsunpackUnpackShapeunravel_indexunregister_deviceunsqueezeUnsqueezeOptionsUnsqueezeShapeuse_deterministic_algorithmsValidateBatchedSquareMatrixValidateChunkDimValidatedEinsumShapevalidateDeviceValidateDeviceValidatedRearrangeShapeValidatedReduceShapeValidatedRepeatShapevalidateDTypeValidateEinsumValidateOperandCountValidateRanksValidateScalarValidateSplitDimValidateSquareMatrixValidateUnbindDimValueOptionsvar_var_meanvdotviewview_as_complexview_as_realvmapvsplitvstackWebGPUKernelConfigWebGPUOnlyResultWebGPUTensorDatawhereWindowOptionsxlogyzeroszeros_like
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. torch.js
  3. torch
  4. special
  5. laguerre_polynomial_l

torch.special.laguerre_polynomial_l

function laguerre_polynomial_l<S extends Shape>(x: Tensor<S, 'float32'>, n: number | Tensor, _options?: SpecialPolynomialOptions<S>): Tensor<S, 'float32'>

Computes Laguerre polynomial L_n(x).

The Laguerre polynomials L_n(x) are orthogonal on [0, ∞) with weight exp(-x). Natural for:

  • Quantum mechanics: hydrogen atom radial wavefunctions (associated Laguerre), Rydberg formula
  • Exponential decay problems: reliability, survival analysis, failure rates, waiting times
  • Signal processing: exponentially decaying signals, radioactive decay, pharmacokinetics
  • Approximation on [0, ∞): function expansion with exponential weight preferred at origin
  • Probability models: exponential distribution, Poisson processes, gamma distributions
  • Orthogonal polynomial methods: natural basis for [0, ∞) problems without explicit boundary conditions

Domain [0, ∞): Unlike Chebyshev/Hermite, Laguerre is on semi-infinite half-line. Weight exp(-x) suppresses oscillations at large x; zeros are all positive.

Quantum Hydrogen: Radial part of hydrogen atom solution uses associated Laguerre polynomials; Laguerre polynomials with n=2l + 1 (related to principal quantum number) define allowed orbits.

Ln(x)=exn!dndxn(xne−x) (Rodrigues formula)Explicit: Ln(x)=∑k=0n(−1)k(nk)xkk!Recurrence: L0(x)=1,L1(x)=1−x,Ln+1(x)=(2n+1−x)Ln(x)−nLn−1(x)n+1Orthogonality: ∫0∞e−xLm(x)Ln(x)dx=δmn (norm 1, unlike others)Generating function: e−xt/(1−t)1−t=∑n=0∞Ln(x)tn\begin{aligned} L_n(x) = \frac{e^x}{n!} \frac{d^n}{dx^n}(x^n e^{-x}) \text{ (Rodrigues formula)} \\ \text{Explicit: } L_n(x) = \sum_{k=0}^n (-1)^k \binom{n}{k} \frac{x^k}{k!} \\ \text{Recurrence: } L_0(x) = 1, \quad L_1(x) = 1 - x, \quad L_{n+1}(x) = \frac{(2n+1-x)L_n(x) - nL_{n-1}(x)}{n+1} \\ \text{Orthogonality: } \int_0^\infty e^{-x} L_m(x) L_n(x) dx = \delta_{mn} \text{ (norm 1, unlike others)} \\ \text{Generating function: } \frac{e^{-xt/(1-t)}}{1-t} = \sum_{n=0}^\infty L_n(x) t^n \end{aligned}Ln​(x)=n!ex​dxndn​(xne−x) (Rodrigues formula)Explicit: Ln​(x)=k=0∑n​(−1)k(kn​)k!xk​Recurrence: L0​(x)=1,L1​(x)=1−x,Ln+1​(x)=n+1(2n+1−x)Ln​(x)−nLn−1​(x)​Orthogonality: ∫0∞​e−xLm​(x)Ln​(x)dx=δmn​ (norm 1, unlike others)Generating function: 1−te−xt/(1−t)​=n=0∑∞​Ln​(x)tn​
  • Semi-infinite domain: [0, ∞), not bounded interval like Chebyshev or Hermite
  • Exponential weight: Orthogonal with weight exp(-x), not 1; natural for decay problems
  • Positive roots: All n zeros of L_n are in (0, ∞); no negative roots
  • Recurrence efficiency: Three-term recurrence with rational coefficients (n+1 denominator)
  • Boundary behavior: L_n(0) = 1 for all n; L_n(x) → -∞ or oscillates for large x (weight suppresses)
  • Norm is 1: Orthogonality integral = δ_mn (not n! like Hermite or 2^n n! √π like Chebyshev physicist)
  • Hydrogen atom: Associated Laguerre L_n^(k)(x) used in hydrogen; standard Laguerre special case
  • Semi-infinite: Domain [0, ∞); behavior for x 0 not physical (polynomial extrapolation)
  • Recurrence numerically sensitive: Denominator n+1 can cause issues for large n; forward recurrence stable
  • Associated Laguerre needed for hydrogen: Standard Laguerre is special case (k=0); use library for L_n^(k)

Parameters

xTensor<S, 'float32'>
Input tensor with values ≥ 0 (semi-infinite domain; diverges for x → ∞, but weight exp(-x) suppresses)
nnumber | Tensor
Polynomial degree (non-negative integer). Can be scalar or Tensor
_optionsSpecialPolynomialOptions<S>optional

Returns

Tensor<S, 'float32'>– Tensor with L_n(x) values

Examples

// Basic evaluation
const x = torch.linspace(0, 5, 5);
const L_0 = torch.special.laguerre_polynomial_l(x, 0);  // [1, 1, 1, 1, 1]
const L_1 = torch.special.laguerre_polynomial_l(x, 1);  // 1 - x
const L_2 = torch.special.laguerre_polynomial_l(x, 2);  // 1 - 2*x + 0.5*x^2

// Hydrogen atom radial wavefunctions
const r = torch.linspace(0, 20, 100);  // Radial coordinate (in Bohr radii)
const n_level = 2;  // Principal quantum number
const l_orbital = 0;  // Angular momentum (s-orbital)
// Associated Laguerre L_{n-l-1}^{2l+1}(2*r/n) appears in R_nl(r)
// For simplicity, using standard Laguerre:
const L_basis = torch.special.laguerre_polynomial_l(r, 2 * l_orbital + 1);
// Multiplied by r^l * exp(-r/n) * (normalization) gives radial wavefunction

// Exponential decay modeling
const t = torch.linspace(0, 10, 50);  // Time
const lambda = 0.1;  // Decay rate
const x_decay = lambda.mul(t);  // Scaled time
const L_3 = torch.special.laguerre_polynomial_l(x_decay, 3);
// Laguerre polynomials weight naturally with exp(-λt) behavior

// Recurrence verification
const x_test = torch.tensor([2.0]);
const L_0_t = torch.special.laguerre_polynomial_l(x_test, 0);  // 1
const L_1_t = torch.special.laguerre_polynomial_l(x_test, 1);  // 1 - 2 = -1
const L_2_t = torch.special.laguerre_polynomial_l(x_test, 2);  // 1 - 2*2 + 0.5*4 = 1
// L_2 = (3*L_1 - 2*L_0) / 2 = (3*(-1) - 2*1)/2 = -5/2 ... verification needed

// Approximation on [0, ∞)
const x_aprox = torch.linspace(0, 5, 100);
const n_terms = 5;
const laguerre_basis = [];
for (let i = 0; i < n_terms; i++) {
  laguerre_basis.push(torch.special.laguerre_polynomial_l(x_aprox, i));
}
// Forms orthogonal basis for [0, ∞) with exp(-x) weight

See Also

  • PyTorch torch.special.laguerre_polynomial_l()
  • torch.special.hermite_polynomial_h - Hermite on (-∞, ∞) with exp(-x²) weight
  • torch.special.hermite_polynomial_he - Probabilist's Hermite with Gaussian weight
  • torch.special.legendre_polynomial_p - Legendre on [-1, 1] with constant weight
Previous
i1e
Next
legendre_polynomial_p