Skip to content

Commit a57b0cb

Browse files
committed
add examples for simps and simps_weights
1 parent 321c9d0 commit a57b0cb

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

doc/specs/stdlib_experimental_quadrature.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,18 @@ If the size of `y` is two, the result is the same as if `trapz` had been called
117117

118118
### Example
119119

120-
TBD
120+
```fortran
121+
program demo_simps
122+
use stdlib_experimental_quadrature, only: simps
123+
implicit none
124+
real :: x(5) = [0., 1., 2., 3., 4.]
125+
real :: y(5) = 3.*x**2
126+
print *, simps(y, x)
127+
! 64.0
128+
print *, simps(y, 0.5)
129+
! 32.0
130+
end program demo_simps
131+
```
121132

122133
## `simps_weights` - Simpson's rule weights for given abscissas
123134

@@ -147,4 +158,15 @@ If the size of `x` is two, then the result is the same as if `trapz_weights` had
147158

148159
### Example
149160

150-
TBD
161+
```fortran
162+
program demo_simps_weights
163+
use stdlib_experimental_quadrature, only: simps_weights
164+
implicit none
165+
real :: x(5) = [0., 1., 2., 3., 4.]
166+
real :: y(5) = 3.*x**2
167+
real :: w(5)
168+
w = simps_weights(x)
169+
print *, sum(w*y)
170+
! 64.0
171+
end program demo_simps_weights
172+
```

0 commit comments

Comments
 (0)