Numerical Integration
This module features quadrature rules and other numerical methods for computing definite integrals.
Gauss_legendre(a, b, n, func)
Calculating the integral of a function for given bounds via Gauß-Legendre
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
n
|
int
|
Number of subintervals |
required |
func
|
Callable
|
Function that needs to be integrated |
required |
Returns:
| Name | Type | Description |
|---|---|---|
res |
float
|
Value of the integration |
Source code in openum/numint.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
Newton_cotes(n, a, b, func)
Calculating the integral of a function for given bounds via Newton-Cotes
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
n
|
int
|
Number of subintervals |
required |
func
|
Callable
|
Function that needs to be integrated |
required |
Returns:
| Name | Type | Description |
|---|---|---|
sum_integral |
float
|
Value of the integration |
Source code in openum/numint.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Romberg(n, a, b, func)
Calculating the integral of a function for given bounds via Romberg
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of subintervals |
required |
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
func
|
Callable
|
Function that needs to be integrated |
required |
Returns:
| Name | Type | Description |
|---|---|---|
value |
float
|
Value of the integration |
Source code in openum/numint.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
Simpson_1_3(n, a, b, func)
Calculating the integral of a function for given bounds via Simpson 1/3
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of subintervals |
required |
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
func
|
Callable
|
Function that needs to be integrated |
required |
Returns:
| Name | Type | Description |
|---|---|---|
result |
float
|
Value of the integration |
Source code in openum/numint.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
Simpson_3_8(n, a, b, func)
Calculating the integral of a function for given bounds via Simpson's 3/8 rule
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of subintervals |
required |
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
func
|
Callable
|
Function that needs to be integrated |
required |
Returns:
| Name | Type | Description |
|---|---|---|
result |
float
|
Value of the integration |
Source code in openum/numint.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
Trapezoidal(n, a, b, func)
Calculating the integral of a function for given bounds via Trapezoidal rule
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
n
|
int
|
Number of subintervals |
required |
func
|
Callable
|
Function that needs to be integrated |
required |
Returns:
| Name | Type | Description |
|---|---|---|
I |
float
|
Value of the integration |
Source code in openum/numint.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
precalc(n, a, b)
Calculating the stepsize and the x_values
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of subintervals |
required |
a
|
float
|
Lower bound of the integral |
required |
b
|
float
|
Upper bound of the integral |
required |
Returns:
| Name | Type | Description |
|---|---|---|
h |
float
|
Stepsize |
x_values |
list
|
x values |
Source code in openum/numint.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |