Skip to content

Commit

Permalink
Adapt docs to new block syntax (Documenter.jl), and update them (deri…
Browse files Browse the repository at this point in the history
…vative, integrate)
  • Loading branch information
Luis Benet committed May 23, 2016
1 parent d67eddb commit 46881a4
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 205 deletions.
6 changes: 2 additions & 4 deletions docs/make.jl
@@ -1,15 +1,13 @@
using Documenter, TaylorSeries

makedocs(
# modules = TaylorSeries,
modules = Module[TaylorSeries],
clean = false,
doctest = false,
)

deploydocs(
deps = Deps.pip("pygments", "mkdocs", "mkdocs-bootstrap", "python-markdown-math"),
deps = Deps.pip("pygments", "mkdocs", "mkdocs-cinder", "python-markdown-math"),
repo = "github.com/JuliaDiff/TaylorSeries.jl.git",
julia = "release",
osname = "osx",
)

8 changes: 4 additions & 4 deletions docs/mkdocs.yml
Expand Up @@ -3,8 +3,8 @@ site_description: 'TaylorSeries.jl: A julia package to manipulate Taylor expansi
repo_url: https://github.com/JuliaDiff/TaylorSeries.jl
site_author: Luis Benet

# theme: cinder
theme: bootstrap
theme: cinder
# theme: bootstrap

extra_css:
- assets/Documenter.css
Expand All @@ -22,14 +22,14 @@ markdown_extensions:

docs_dir: 'build'

copyright: "Copyright &copy; 2014-2016, Luis Benet and David P. Sanders.<br>
copyright: "Copyright &copy; 2014-2016, Luis Benet and David P. Sanders.
<a https://github.com/JuliaDiff/TaylorSeries.jl>TaylorSeries.jl</a> is licensed under the
<a href='https://github.com/JuliaDiff/TaylorSeries.jl/blob/master/LICENSE.md'>
MIT Expat license</a>."

pages:
- 'Home': 'index.md'
- 'Background': 'background.md'
- 'User guide': 'user_guide.md'
- 'User guide': 'userguide.md'
- 'Examples': 'examples.md'
- 'API': 'api.md'
61 changes: 33 additions & 28 deletions docs/src/api.md
@@ -1,37 +1,42 @@
{meta}
CurrentModule = TaylorSeries

# Library

---

```@meta
CurrentModule = TaylorSeries
```

## Types

{docs}
TaylorSeries.Taylor1
TaylorSeries.HomogeneousPolynomial
TaylorSeries.TaylorN
TaylorSeries.ParamsTaylorN
```@docs
Taylor1
HomogeneousPolynomial
TaylorN
ParamsTaylorN
```

## Functions and methods

{docs}
TaylorSeries.taylor1_variable()
TaylorSeries.diffTaylor()
TaylorSeries.integTaylor()
TaylorSeries.deriv()
TaylorSeries.evaluate()

TaylorSeries.taylorN_variable()
TaylorSeries.set_variables()
TaylorSeries.show_params_TaylorN()
TaylorSeries.get_coeff()

## Internal use

{docs}
TaylorSeries.generate_tables
TaylorSeries.coeff_table
TaylorSeries.index_table
TaylorSeries.size_table
TaylorSeries.pos_table
```@docs
taylor1_variable
taylorN_variable
set_variables
show_params_TaylorN
get_coeff
```

```@docs
evaluate
derivative
integrate
gradient
jacobian
hessian
```

## Internals

```@docs
generate_tables
mulHomogCoef
```
111 changes: 56 additions & 55 deletions docs/src/examples.md
@@ -1,7 +1,3 @@

{meta}
CurrentModule = TaylorSeries

# Examples

---
Expand All @@ -24,34 +20,37 @@ of the equation
has *a priori* terms of fourth order, and the number of independent variables to
8.

{repl euler}
using TaylorSeries
# Define the variables α₁, ..., α₄, β₁, ..., β₄
make_variable(name, index::Int) = string(name, TaylorSeries.subscriptify(index))
variable_names = [make_variable("α", i) for i in 1:4]
append!(variable_names, [make_variable("β", i) for i in 1:4])
# Create the Taylor objects (order 4, numvars=8)
a1, a2, a3, a4, b1, b2, b3, b4 = set_variables(variable_names, order=4)
a1 # variable a1
```@repl euler
using TaylorSeries
# Define the variables α₁, ..., α₄, β₁, ..., β₄
make_variable(name, index::Int) = string(name, TaylorSeries.subscriptify(index))
variable_names = [make_variable("α", i) for i in 1:4]
append!(variable_names, [make_variable("β", i) for i in 1:4])
# Create the Taylor objects (order 4, numvars=8)
a1, a2, a3, a4, b1, b2, b3, b4 = set_variables(variable_names, order=4)
a1 # variable a1
```

Now we compute each term appearing in (\\ref{eq:Euler}), and compare them

{repl euler}
# left-hand side
lhs1 = a1^2 + a2^2 + a3^2 + a4^2 ;
lhs2 = b1^2 + b2^2 + b3^2 + b4^2 ;
lhs = lhs1 * lhs2
# right-hand side
rhs1 = (a1*b1 - a2*b2 - a3*b3 - a4*b4)^2 ;
rhs2 = (a1*b2 + a2*b1 + a3*b4 - a4*b3)^2 ;
rhs3 = (a1*b3 - a2*b4 + a3*b1 + a4*b2)^2 ;
rhs4 = (a1*b4 + a2*b3 - a3*b2 + a4*b1)^2 ;
rhs = rhs1 + rhs2 + rhs3 + rhs4
```@repl euler
# left-hand side
lhs1 = a1^2 + a2^2 + a3^2 + a4^2 ;
lhs2 = b1^2 + b2^2 + b3^2 + b4^2 ;
lhs = lhs1 * lhs2
# right-hand side
rhs1 = (a1*b1 - a2*b2 - a3*b3 - a4*b4)^2 ;
rhs2 = (a1*b2 + a2*b1 + a3*b4 - a4*b3)^2 ;
rhs3 = (a1*b3 - a2*b4 + a3*b1 + a4*b2)^2 ;
rhs4 = (a1*b4 + a2*b3 - a3*b2 + a4*b1)^2 ;
rhs = rhs1 + rhs2 + rhs3 + rhs4
```

Finally, we compare the two sides of the identity,

{repl euler}
lhs == rhs
```@repl euler
lhs == rhs
```

The identity is satisfied. $\\square$.

Expand All @@ -67,38 +66,40 @@ the function `fateman1`. We shall also evaluate the form $s^2+s$ in `fateman2`,
which involves fewer operations (and makes a fairer comparison to what
Mathematica does). Below we have used Julia v0.4.

{repl fateman}
using TaylorSeries
set_variables("x", numvars=4, order=40)
function fateman1(degree::Int)
T = Int128
oneH = HomogeneousPolynomial(one(T), 0)
# s = 1 + x + y + z + w
s = TaylorN([oneH,HomogeneousPolynomial([one(T),one(T),one(T),one(T)],1)],degree)
s = s^degree
# s is converted to order 2*ndeg
s = TaylorN(s, 2*degree)
s * ( s+TaylorN(oneH, 2*degree) )
end
fateman1(0);
@time f1 = fateman1(20);
```@repl fateman
using TaylorSeries
set_variables("x", numvars=4, order=40)
function fateman1(degree::Int)
T = Int128
oneH = HomogeneousPolynomial(one(T), 0)
# s = 1 + x + y + z + w
s = TaylorN([oneH,HomogeneousPolynomial([one(T),one(T),one(T),one(T)],1)],degree)
s = s^degree
# s is converted to order 2*ndeg
s = TaylorN(s, 2*degree)
s * ( s+TaylorN(oneH, 2*degree) )
end
fateman1(0);
@time f1 = fateman1(20);
```

Another implementation of the same:

{repl fateman}
function fateman2(degree::Int)
T = Int128
oneH = HomogeneousPolynomial(one(T), 0)
s = TaylorN([oneH,HomogeneousPolynomial([one(T),one(T),one(T),one(T)],1)],degree)
s = s^degree
# s is converted to order 2*ndeg
s = TaylorN(s, 2*degree)
return s^2 + s
end
fateman2(0);
@time f2 = fateman2(20);
get_coeff(f2,[1,6,7,20]) # coefficient of x y^6 z^7 w^{20}
sum(TaylorSeries.size_table)
```@repl fateman
function fateman2(degree::Int)
T = Int128
oneH = HomogeneousPolynomial(one(T), 0)
s = TaylorN([oneH,HomogeneousPolynomial([one(T),one(T),one(T),one(T)],1)],degree)
s = s^degree
# s is converted to order 2*ndeg
s = TaylorN(s, 2*degree)
return s^2 + s
end
fateman2(0);
@time f2 = fateman2(20);
get_coeff(f2,[1,6,7,20]) # coefficient of x y^6 z^7 w^{20}
sum(TaylorSeries.size_table)
```

The tests above show the necessity of using `Int128`, that
`fateman2` is nearly twice as fast as `fateman1`, and that the series has 135751
Expand Down

0 comments on commit 46881a4

Please sign in to comment.