PARI stems from Pascal ARIthmetic (although switched to C,
now a pun on pari de Pascal),
and GP means the Great Programmable calculator,
distributed under the GNU General Public License.
PARI/GP is a widely used computer algebra system designed
for fast computations in number theory (factorizations, algebraic
number theory, elliptic curves…), but also contains a large number
of other useful functions to compute with mathematical entities such
as matrices, polynomials, power series, algebraic numbers, etc.,
and a lot of transcendental functions.
The substpol is a way to turn an expression into a function,
without retyping the expression.
To be sure that we have functions, we evaluate at a point.
print(gp('f(2)'))print(gp('g(2)'))
Now we apply the Cauchy integral formula.
gp('intcirc(z=0, 0.5, g(z)/f(z))')
There is one root in a disk centered at z = 0 of radius 0.5.
Because f is a cubic polynomial, if we enlarge the radius enough,
we know the radius of the disk that contains all roots.
and we see three different expansions of 142
as 2 + 2^2 + 2^3 + 2^7 + O(2^10), and
1 + 2*3 + 2*3^3 + 3^4 + O(3^10), and the familiar
2 + 4*10 + 10^2 + O(10^10).
We can detect integer relations between floating-point approximations.
As a test we take the relation log(15)=log(3*5)=log(3)+log(5).
gp('u = [log(15.0), log(3.0), log(5.0)]')gp('u')
We have the list [2.708050201,1.098612289,1.609437912]
of three floating-point numbers.
gp('r = lindep(u)')
The result [-1,1,1]~
indicates that -log(15)+log(3)+log(5)=0.
The flag ~ at the end is there because the output is a column vector.
gp('type(r)')
And we see t_COL as the type.
We can look for algebraic dependencies between numbers,
which is equivalent to calling lindep on the list [1,x,x^2,..,x^k].
gp('x = 3^(1/6)')
Let us check if GP can detect from the value
1.200936955 that x is an algebraic number,
that is: that x is a root of a polynomial.
Compute the first 10 best rational approximations for
the transcendental number \(e = \exp(1)\).
The \(k\)-th number in the sequence has \(k\) decimal
places in the denominator.
Is computing the Taylor series of sin(x)*cos(x)
the same as multiplying the Taylor series of sin(x)
with the Taylor series of cos(x)?
In your answer, calculate with Taylor series of order 10.
Use the Cauchy integral formula to show that sin(3*Pi*x)
has 2 roots in a disk of the complex plane centered at the origin
and with radius 0.5.
Consider r=1.2599210498948732.
Find the algebraic number that is closest to r.