@@ -10,7 +10,7 @@ Basic arithmetic, integration, differentiation, evaluation, and root finding ove
10
10
11
11
## Installation
12
12
13
- ``` julia
13
+ ``` julia-repl
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
30
+ ``` julia-repl
31
31
julia> Polynomial([1,0,3,4])
32
32
Polynomial(1 + 3x^2 + 4x^3)
33
33
```
34
34
35
35
An optional variable parameter can be added.
36
36
37
- ``` julia
37
+ ``` julia-repl
38
38
julia> Polynomial([1,2,3], :s)
39
39
Polynomial(1 + 2s + 3s^2)
40
40
```
41
41
42
42
Construct a polynomial from its roots.
43
43
44
- ``` julia
44
+ ``` julia-repl
45
45
julia> fromroots([1,2,3]) # (x-1)*(x-2)*(x-3)
46
46
Polynomial(-6 + 11x - 6x^2 + x^3)
47
47
```
48
48
49
49
Evaluate the polynomial ` p ` at ` x ` .
50
50
51
- ``` julia
51
+ ``` julia-repl
52
52
julia> p = Polynomial([1, 0, -1])
53
53
julia> p(0.1)
54
54
0.99
@@ -57,7 +57,8 @@ julia> p(0.1)
57
57
#### Arithmetic
58
58
59
59
The usual arithmetic operators are overloaded to work on polynomials, and combinations of polynomials and scalars.
60
- ``` julia
60
+
61
+ ``` julia-repl
61
62
julia> p = Polynomial([1,2])
62
63
Polynomial(1 + 2x)
63
64
@@ -85,7 +86,7 @@ Polynomial(0.25 - 0.5x)
85
86
86
87
Note that operations involving polynomials with different variables will error.
87
88
88
- ``` julia
89
+ ``` julia-repl
89
90
julia> p = Polynomial([1, 2, 3], :x)
90
91
julia> q = Polynomial([1, 2, 3], :s)
91
92
julia> p + q
@@ -98,7 +99,7 @@ Integrate the polynomial `p` term by term, optionally adding constant
98
99
term ` k ` . The order of the resulting polynomial is one higher than the
99
100
order of ` p ` .
100
101
101
- ``` julia
102
+ ``` julia-repl
102
103
julia> integral(Polynomial([1, 0, -1]))
103
104
Polynomial(x - 0.3333333333333333x^3)
104
105
@@ -109,7 +110,7 @@ Polynomial(2.0 + x - 0.3333333333333333x^3)
109
110
Differentiate the polynomial ` p ` term by term. The order of the
110
111
resulting polynomial is one lower than the order of ` p ` .
111
112
112
- ``` julia
113
+ ``` julia-repl
113
114
julia> derivative(Polynomial([1, 3, -1]))
114
115
Polynomial(3 - 2x)
115
116
```
@@ -121,7 +122,7 @@ Return the roots (zeros) of `p`, with multiplicity. The number of
121
122
roots returned is equal to the order of ` p ` . By design, this is not type-stable,
122
123
the returned roots may be real or complex.
123
124
124
- ``` julia
125
+ ``` julia-repl
125
126
julia> roots(Polynomial([1, 0, -1]))
126
127
2-element Array{Float64,1}:
127
128
-1.0
0 commit comments