Expansion of polynomials: Difference between revisions

From tehowiki
Jump to navigation Jump to search
new
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
* '''[[oeis:A295237|A295237]]''' <code>a:=series(csc(x)*(1-sqrt(1-4*sin(x)))/2, x=0, 20): seq(n!*coeff(a, x, n), n=0..19); # E.g.f.</code>
* '''[[oeis:A295237|A295237]]''' <code>a:=series(csc(x)*(1-sqrt(1-4*sin(x)))/2, x=0, 20): seq(n!*coeff(a, x, n), n=0..19); # E.g.f.</code>
 
* '''[[oeis:A345969|A345969]]''' Expansion of the e.g.f. <code>1 / sqrt(3 - 2 / ((1 - x)*exp(x)))</code>
==== Postfix notation ====
** Maple: <code>a := series(1/sqrt(3-2/((1-x)*exp(x))), x=0, 25): seq(n!*coeff(a, x, n), n=0..24);</code>
** jOEIS: <code>new PolynomialFieldSequence(0, "[[1],[1,-1]]" ",1,3,2,p1,x,exp,*,/,-,sqrt,/", 0, 1)</code>
===Parameters===
The expansion of (exponential) generating functions is performed by <code>'''[https://github.com/archmageirvine/joeis/tree/master/src/irvine/oeis/PolynomialFieldSequence.java PolynomialFieldSequence]'''</code> with a constructor that has up to 5 parameters:
The expansion of (exponential) generating functions is performed by <code>'''[https://github.com/archmageirvine/joeis/tree/master/src/irvine/oeis/PolynomialFieldSequence.java PolynomialFieldSequence]'''</code> with a constructor that has up to 5 parameters:
 
* <code>offset:</code> first index
* <code>offset</code>: first index
* <code>polys:</code> a list of list of integers in square brackets, specifying the coefficients of a list of polynomials. The polynomials are referenced by p0, p1, p2, ... where p0 gives the initial term of the iteration. For example, 1-x = '''1'''*x^0 '''-1'''*x^1 -> ['''1,-1'''].  
* <code>polys</code>: a list of list of integers in square brackets, specifying the coefficients of a list of polynomials. The polynomials are referenced by p0, p1, p2, ... where p0 gives the initial term of the iteration.  
* <code>postfix:</code> a string starting with a delimiter, followed by a list of elements that are separated by this delimiter
* <code>postfix</code>: a string starting with a delimiter, followed by a list of elements that are separated by this delimiter
* <code>dist:</code> an optional increment to the current index
* <code>dist</code>: an optional increment to the current index
* <code>gfType:</code> 0 for an o.g.f., 1 for an e.g.f., +4 if the denominator should be returned instead of the numerator (default 0 = o.g.f)
* <code>gfType</code>: 0 for an o.g.f., 1 for an e.g.f., +4 if the denominator should be returned instead of the numerator, default 0
* <code>modulus, factor:</code> which element to take when zeros are suppressed (default 1), and periodicity when zeroes are suppressed (default 1). Even coefficients are selected by (0,2), odd coefficients by (1,2).
* <code>modulus</code>: which element to take when zeros are suppressed, default 1
=== Postfix notation ===
* <code>factor</code>: periodicity when zeroes are suppressed, default 1. Even coefficients are selected by (0,2), odd coefficients by (1,2).
The operations of the postfix string are performed in their sequential order. They operate on a stack, and the final result is the lowest stack element.
====Special operators====
* <code>A</code> push the generating function to be defined
* <code>x</code> push the free variable
* <code>0, 1, 2, ... </code> push an integer
* <code>p<sub>i</sub></code> push the predefined polynomial with index '''i''' (cf. <code>polys</code> above)
* <code>&lt;i</code> shift the top stack element by '''i''', i.e. multiply by x<sup>i</sup>
* <code>^i</code> take the top stack element to the i-th power, where <code>i</code> can be an integer or a fraction (<code>^1/2</code> is <code>sqrt</code>)
* <code>dif</code> differentiate the top stack element
* <code>int</code> formal integration of the top stack element
* <code>sub</code> substitute, call the g.f. <code>A</code> with the top stack element
====Arithmetic operators, functions with 2 arguments====
Replace the 2 top stack elements '''a''', '''b''' by '''a op b''', where ''op'' is one of:
* <code>+</code> <code>-</code> <code>*</code> <code>/</code>
* <code>agm</code>
====Functions with 1 argument====
Replace the top stack element by the function's result:
* <code>abs</code> <code>acosh</code> <code>asin</code> <code>asinh</code> <code>atan</code> <code>atanh</code>  <code>cos</code> <code>cosh</code> <code>cot</code> <code>coth</code> <code>csc</code> <code>csch</code> <code>eta</code> <code>exp</code> <code>lambertW</code> <code>log</code> <code>neg</code> <code>sec</code> <code>sech</code> <code>sin</code> <code>sinh</code> <code>sqrt</code> <code>tan</code> <code>tanh</code>
* <code>catalan</code>(x) = (1 - sqrt(1 - 4*x)) / (2*x)
===Caveats===
* Usually the g.f.s have offset 0 and start with a term 1, so <code>p0 = "[[1]]"</code> in most cases. The first polynomial p0 must always include the coefficient of x<sup>0</sup>, even if the offset is &gt; 0, for example: <code>p0 = "[[0,1]]"</code>.
* Usually the parameter <code>dist</code> is not needed. Sometimes, it must be set to a value &gt; 0 to start the iteration properly.
* <code>sqrt</code> expects an argument of the form ''1-x''. sqrt(x) does not work, it can sometimes be avoided by quadrating all occurrences of x.
===Commandline activation===
A script <code>OEIS-mat/scripts/poly</code> facilitates the testing of the polynomial expansions. It is activated with up to 4 parameters:
* <code>poly polys postfix [-i dist] [-t gfTtype]</code>
===Generator Callcodes===
There are 3 callcodes:
* <code>poly offset polys postfix</code>
* <code>polyx offset polys postfix dist gfType</code>
* <code>polyz offset polys postfix dist gfType modulus factor</code>

Latest revision as of 19:57, 25 April 2025

  • A295237 a:=series(csc(x)*(1-sqrt(1-4*sin(x)))/2, x=0, 20): seq(n!*coeff(a, x, n), n=0..19); # E.g.f.
  • A345969 Expansion of the e.g.f. 1 / sqrt(3 - 2 / ((1 - x)*exp(x)))
    • Maple: a := series(1/sqrt(3-2/((1-x)*exp(x))), x=0, 25): seq(n!*coeff(a, x, n), n=0..24);
    • jOEIS: new PolynomialFieldSequence(0, "[[1],[1,-1]]" ",1,3,2,p1,x,exp,*,/,-,sqrt,/", 0, 1)

Parameters

The expansion of (exponential) generating functions is performed by PolynomialFieldSequence with a constructor that has up to 5 parameters:

  • offset: first index
  • polys: a list of list of integers in square brackets, specifying the coefficients of a list of polynomials. The polynomials are referenced by p0, p1, p2, ... where p0 gives the initial term of the iteration. For example, 1-x = 1*x^0 -1*x^1 -> [1,-1].
  • postfix: a string starting with a delimiter, followed by a list of elements that are separated by this delimiter
  • dist: an optional increment to the current index
  • gfType: 0 for an o.g.f., 1 for an e.g.f., +4 if the denominator should be returned instead of the numerator (default 0 = o.g.f)
  • modulus, factor: which element to take when zeros are suppressed (default 1), and periodicity when zeroes are suppressed (default 1). Even coefficients are selected by (0,2), odd coefficients by (1,2).

Postfix notation

The operations of the postfix string are performed in their sequential order. They operate on a stack, and the final result is the lowest stack element.

Special operators

  • A push the generating function to be defined
  • x push the free variable
  • 0, 1, 2, ... push an integer
  • pi push the predefined polynomial with index i (cf. polys above)
  • <i shift the top stack element by i, i.e. multiply by xi
  • ^i take the top stack element to the i-th power, where i can be an integer or a fraction (^1/2 is sqrt)
  • dif differentiate the top stack element
  • int formal integration of the top stack element
  • sub substitute, call the g.f. A with the top stack element

Arithmetic operators, functions with 2 arguments

Replace the 2 top stack elements a, b by a op b, where op is one of:

  • + - * /
  • agm

Functions with 1 argument

Replace the top stack element by the function's result:

  • abs acosh asin asinh atan atanh cos cosh cot coth csc csch eta exp lambertW log neg sec sech sin sinh sqrt tan tanh
  • catalan(x) = (1 - sqrt(1 - 4*x)) / (2*x)

Caveats

  • Usually the g.f.s have offset 0 and start with a term 1, so p0 = "1" in most cases. The first polynomial p0 must always include the coefficient of x0, even if the offset is > 0, for example: p0 = "0,1".
  • Usually the parameter dist is not needed. Sometimes, it must be set to a value > 0 to start the iteration properly.
  • sqrt expects an argument of the form 1-x. sqrt(x) does not work, it can sometimes be avoided by quadrating all occurrences of x.

Commandline activation

A script OEIS-mat/scripts/poly facilitates the testing of the polynomial expansions. It is activated with up to 4 parameters:

  • poly polys postfix [-i dist] [-t gfTtype]

Generator Callcodes

There are 3 callcodes:

  • poly offset polys postfix
  • polyx offset polys postfix dist gfType
  • polyz offset polys postfix dist gfType modulus factor