-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Manifest.toml | ||
.ipynb_checkpoints/ | ||
docs/build/ | ||
docs/src/generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# # 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 | ||
|
||
# ```julia | ||
# using Pkg | ||
# Pkg.add("https://github.com/chrisdjscott/DACE_jll.jl.git") | ||
# Pkg.add("https://github.com/chrisdjscott/DACE.jl.git") | ||
# ``` | ||
|
||
# ## 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) | ||
|
||
# Create `y` as `AlgebraicVector` of type `DA` and size 1 | ||
|
||
y = AlgebraicVector{DA}(1) | ||
|
||
# Store the Taylor expansion of `sin(x)` in the first element of `y` | ||
|
||
y[1] = sin(x) | ||
|
||
# Invert the Taylor polynomial | ||
|
||
inv_y = DACE.invert(y) | ||
|
||
# Finally compare the polynomial inversion of `sin(x)` | ||
|
||
println("polynomial inversion of sin(x)") | ||
println(inv_y) | ||
|
||
# with `asin(x)` | ||
|
||
println("asin(x)") | ||
println(asin(x)) |