|
2 | 2 | series(y, x, [x0=0,] ns; name = nameof(y)) |
3 | 3 |
|
4 | 4 | Expand the variable `y` in a power series in the variable `x` around `x0` to orders `ns`. |
| 5 | +
|
| 6 | +Examples |
| 7 | +======== |
| 8 | +
|
| 9 | +```julia |
| 10 | +julia> @variables z ϵ |
| 11 | +2-element Vector{Num}: |
| 12 | + z |
| 13 | + ϵ |
| 14 | +
|
| 15 | +julia> series(z, ϵ, 2, 0:3) |
| 16 | +z[0] + z[1]*(-2 + ϵ) + z[2]*((-2 + ϵ)^2) + z[3]*((-2 + ϵ)^3) |
| 17 | +``` |
5 | 18 | """ |
6 | 19 | function series(y, x, x0, ns; name = nameof(y)) |
7 | 20 | c, = @variables $name[ns] |
|
15 | 28 | taylor_coeff(f, x[, n]; rationalize=true) |
16 | 29 |
|
17 | 30 | Calculate the `n`-th order coefficient(s) in the Taylor series of `f` around `x = 0`. |
| 31 | +
|
| 32 | +Examples |
| 33 | +======== |
| 34 | +```julia |
| 35 | +julia> @variables x y |
| 36 | +2-element Vector{Num}: |
| 37 | + x |
| 38 | + y |
| 39 | +
|
| 40 | +julia> taylor_coeff(series(y, x, 0:5), x, 0:2:4) |
| 41 | +3-element Vector{Num}: |
| 42 | + y[0] |
| 43 | + y[2] |
| 44 | + y[4] |
| 45 | +``` |
18 | 46 | """ |
19 | 47 | function taylor_coeff(f, x, n = missing; rationalize=true) |
20 | 48 | if n isa AbstractArray |
@@ -70,6 +98,9 @@ julia> taylor(exp(x), x, 0:3; rationalize=false) |
70 | 98 |
|
71 | 99 | julia> taylor(√(x), x, 1, 0:3) |
72 | 100 | 1 + (1//2)*(-1 + x) - (1//8)*((-1 + x)^2) + (1//16)*((-1 + x)^3) |
| 101 | +
|
| 102 | +julia> isequal(taylor(exp(im*x), x, 0:5), taylor(exp(im*x), x, 0:5)) |
| 103 | +true |
73 | 104 | ``` |
74 | 105 | """ |
75 | 106 | function taylor(f, x, ns; kwargs...) |
|
0 commit comments