@@ -10,7 +10,7 @@ Basic arithmetic, integration, differentiation, evaluation, and root finding ove
10
10
11
11
## Installation
12
12
13
- ``` julia-repl
13
+ ``` julia
14
14
(v1.2 ) pkg> add Polynomials
15
15
16
16
julia> using Polynomials
@@ -27,28 +27,28 @@ julia> using Polynomials
27
27
28
28
Construct a polynomial from its coefficients, lowest order first.
29
29
30
- ``` julia-repl
30
+ ``` julia
31
31
julia> Polynomial ([1 ,0 ,3 ,4 ])
32
32
Polynomial (1 + 3 x^ 2 + 4 x^ 3 )
33
33
```
34
34
35
35
An optional variable parameter can be added.
36
36
37
- ``` julia-repl
37
+ ``` julia
38
38
julia> Polynomial ([1 ,2 ,3 ], :s )
39
39
Polynomial (1 + 2 s + 3 s^ 2 )
40
40
```
41
41
42
42
Construct a polynomial from its roots.
43
43
44
- ``` julia-repl
44
+ ``` julia
45
45
julia> fromroots ([1 ,2 ,3 ]) # (x-1)*(x-2)*(x-3)
46
46
Polynomial (- 6 + 11 x - 6 x^ 2 + x^ 3 )
47
47
```
48
48
49
49
Evaluate the polynomial ` p ` at ` x ` .
50
50
51
- ``` julia-repl
51
+ ``` julia
52
52
julia> p = Polynomial ([1 , 0 , - 1 ])
53
53
julia> p (0.1 )
54
54
0.99
@@ -58,7 +58,7 @@ julia> p(0.1)
58
58
59
59
The usual arithmetic operators are overloaded to work on polynomials, and combinations of polynomials and scalars.
60
60
61
- ``` julia-repl
61
+ ``` julia
62
62
julia> p = Polynomial ([1 ,2 ])
63
63
Polynomial (1 + 2 x)
64
64
@@ -86,7 +86,7 @@ Polynomial(0.25 - 0.5x)
86
86
87
87
Note that operations involving polynomials with different variables will error.
88
88
89
- ``` julia-repl
89
+ ``` julia
90
90
julia> p = Polynomial ([1 , 2 , 3 ], :x )
91
91
julia> q = Polynomial ([1 , 2 , 3 ], :s )
92
92
julia> p + q
@@ -99,7 +99,7 @@ Integrate the polynomial `p` term by term, optionally adding constant
99
99
term ` k ` . The order of the resulting polynomial is one higher than the
100
100
order of ` p ` .
101
101
102
- ``` julia-repl
102
+ ``` julia
103
103
julia> integrate (Polynomial ([1 , 0 , - 1 ]))
104
104
Polynomial (x - 0.3333333333333333 x^ 3 )
105
105
@@ -110,7 +110,7 @@ Polynomial(2.0 + x - 0.3333333333333333x^3)
110
110
Differentiate the polynomial ` p ` term by term. The order of the
111
111
resulting polynomial is one lower than the order of ` p ` .
112
112
113
- ``` julia-repl
113
+ ``` julia
114
114
julia> derivative (Polynomial ([1 , 3 , - 1 ]))
115
115
Polynomial (3 - 2 x)
116
116
```
@@ -122,7 +122,7 @@ Return the roots (zeros) of `p`, with multiplicity. The number of
122
122
roots returned is equal to the order of ` p ` . By design, this is not type-stable,
123
123
the returned roots may be real or complex.
124
124
125
- ``` julia-repl
125
+ ``` julia
126
126
julia> roots (Polynomial ([1 , 0 , - 1 ]))
127
127
2 - element Array{Float64,1 }:
128
128
- 1.0
@@ -161,8 +161,7 @@ Visual example:
161
161
162
162
Polynomial objects also have other methods:
163
163
164
- * 0-based indexing is used to extract the coefficients of $a_0 + a_1
165
- x + a_2 x^2 + ...$, coefficients may be changed using indexing
164
+ * 0-based indexing is used to extract the coefficients of ` [a0, a1, a2, ...] ` , coefficients may be changed using indexing
166
165
notation.
167
166
168
167
* ` coeffs ` : returns the entire coefficient vector
0 commit comments