pg_utils.numerics.symparser.jacobi_idx_subs

pg_utils.numerics.symparser.jacobi_idx_subs(expr: Expr, arg: Symbol, arg_a: Symbol = p, arg_b: Symbol = q) Expr[source]

Jacobi index substitution.

This function replaces the 1-arg and 1+`arg` factors in the expression to arg_a and arg_b, respectively, so as to facilitate derivation and calculation of Jacobi-like inner products.

Parameters:
  • expr (sympy.Expr) – expression

  • arg (sympy.Symbol) – the main variable x

  • arg_a (sympy.Symbol) – the symbol for 1 - x factors

  • arg_b (sympy.Symbol) – the symbol for 1 + x factors

Returns:

processed expression with 1 - x and 1 + x replaced

Warning

This function internally uses xreplace in order to avoid mixing 1 + x and 1 - x terms. However, this also means that unless the expression contains the terms in the exact expression, the terms won’t be properly replaced. The following terms are currently supported: * \(1 - x\) * \(x - 1\) * \(1/2 - x/2\) * \(x/2 - 1/2\) * \(1 + x\) * \(1/2 + x/2\)