Skip to content

Commit f7d732d

Browse files
committed
add spec for simps_weights
1 parent 8b6dcb7 commit f7d732d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/stdlib_experimental_quadrature.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,31 @@ If the size of `y` is two, the result is the same as if `trapz` had been called
111111
### Example
112112

113113
TBD
114+
115+
# `simps_weights` - Simpson's rule weights for given abscissas
116+
117+
Given an array of abscissas `x`, computes the array of weights `w` such that if `y` represented function values tabulated at `x`, then `sum(w*y)` produces a Simpson's rule approximation to the integral.
118+
119+
Simpson's rule is defined for odd-length arrays only. For even-length arrays, an optional argument `even` may be used to specify at which index to replace Simpson's rule with Simpson's 3/8 rule. The 3/8 rule will be used for the array section `x(even:even+4)` and the ordinary Simpon's rule will be used elsewhere.
120+
121+
### Syntax
122+
123+
`result = simps_weights(x [, even])`
124+
125+
### Arguments
126+
127+
`x`: Shall be a rank-one array of type `real`.
128+
129+
`even`: (Optional) Shall be a scalar integer of default kind. Its default value is `1`.
130+
131+
### Return value
132+
133+
The result is a `real` array with the same size and kind as `x`.
134+
135+
If the size of `x` is one, then the sole element of the result is zero.
136+
137+
If the size of `x` is two, then the result is the same as if `trapz_weights` had been called instead.
138+
139+
### Example
140+
141+
TBD

0 commit comments

Comments
 (0)