Polynomial inversion
This is a DACE example showing polynomial inversion, demonstrating:
- How to load DACE.jl
- How to initialise the DACE library
- How to create a
DA
object - How to create an
AlgebraicVector
- How to invert a Taylor polynomial
Install dependencies
Make sure the required packages are installed
using Pkg
Pkg.add("DACE")
Using DACE
Write
using DACE
to load DACE functions and objects into our script.
Initialise DACE for 10th-order computations in 1 variable
DACE.init(10, 1)
Initialise x
as a DA
object
x = DACE.DA(1, 1)
I COEFFICIENT ORDER EXPONENTS
1 1.0000000000000000e+00 1 1
------------------------------------------------
Create y
as AlgebraicVector
of type DA
and size 1
y = AlgebraicVector{DA}(1)
1-element DACE.AlgebraicVectorAllocated{DA}:
ALL COEFFICIENTS ZERO
------------------------------------------------
Store the Taylor expansion of sin(x)
in the first element of y
y[1] = sin(x)
I COEFFICIENT ORDER EXPONENTS
1 1.0000000000000000e+00 1 1
2 -1.6666666666666666e-01 3 3
3 8.3333333333333332e-03 5 5
4 -1.9841269841269841e-04 7 7
5 2.7557319223985893e-06 9 9
------------------------------------------------
Invert the Taylor polynomial
inv_y = DACE.invert(y)
1-element DACE.AlgebraicVectorAllocated{DA}:
I COEFFICIENT ORDER EXPONENTS
1 1.0000000000000000e+00 1 1
2 1.6666666666666666e-01 3 3
3 7.4999999999999997e-02 5 5
4 4.4642857142857137e-02 7 7
5 3.0381944444444437e-02 9 9
------------------------------------------------
Finally compare the polynomial inversion of sin(x)
println("polynomial inversion of sin(x)")
println(inv_y)
polynomial inversion of sin(x)
[[[ 1 vector
I COEFFICIENT ORDER EXPONENTS
1 1.0000000000000000e+00 1 1
2 1.6666666666666666e-01 3 3
3 7.4999999999999997e-02 5 5
4 4.4642857142857137e-02 7 7
5 3.0381944444444437e-02 9 9
------------------------------------------------
]]]
with asin(x)
println("asin(x)")
println(asin(x))
asin(x)
I COEFFICIENT ORDER EXPONENTS
1 1.0000000000000000e+00 1 1
2 1.6666666666666669e-01 3 3
3 7.5000000000000067e-02 5 5
4 4.4642857142857206e-02 7 7
5 3.0381944444444586e-02 9 9
------------------------------------------------
This page was generated using Literate.jl.