Skip to content

Commit 0b385e7

Browse files
committed
Add spec for simps
1 parent b1fb265 commit 0b385e7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/stdlib_experimental_quadrature.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,39 @@ program demo_trapz_weights
7777
end program
7878
7979
```
80+
81+
# `simps` - integrate sampled values using Simpson's rule
82+
83+
Returns the Simpson's rule integral of an array `y` representing discrete samples of a function. The integral is computed assuming either equidistant abscissas with spacing `dx` or arbitary abscissas `x`.
84+
85+
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 `u(even:even+4)` and the ordinary Simpon's rule will be used elsewhere.
86+
87+
### Syntax
88+
89+
`result = simps(y, x [, even])`
90+
91+
`result = simps(y, dx [, even])`
92+
93+
### Arguments
94+
95+
`y`: Shall be a rank-one array of type `real`.
96+
97+
`x`: Shall be a rank-one array of type `real` having the same kind and size as `y`.
98+
99+
`dx`: Shall be a scalar of type `real` having the same kind as `y`.
100+
101+
`even`: (Optional) Shall be a scalar integer of default kind. Its default value is `1`.
102+
103+
### Return value
104+
105+
The result is a scalar of type `real` having the same kind as `y`.
106+
107+
If the size of `y` is zero or one, the result is zero.
108+
109+
If the size of `y` is two, the result is the same as if `trapz` had been called instead, regardless of the value of `even`.
110+
111+
If the size of `y` is even, the result
112+
113+
### Example
114+
115+
TBD

0 commit comments

Comments
 (0)