Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Feb 19, 2023
1 parent f7a60d9 commit 7558b18
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ To perform one-dimensional quadrature, we can simply construct an `IntegralProbl
into the problem as the fourth argument of `IntegralProblem`.

```julia
using Integrals
f(x, p) = sin(x*p)
using Integrals
f(x, p) = sin(x * p)
p = 1.7
prob = IntegralProblem(f, -2, 5, p)
sol = solve(prob, QuadGKJL())
```

For basic multidimensional quadrature we can construct and solve a `IntegralProblem`. Since we are using no arguments `p` in this example, we omit the fourth argument of `IntegralProblem`
For basic multidimensional quadrature we can construct and solve a `IntegralProblem`. Since we are using no arguments `p` in this example, we omit the fourth argument of `IntegralProblem`
from above. The lower and upper bounds are now passed as vectors, with the `i`th elements of
the bounds giving the interval of integration for `x[i]`.

Expand Down
2 changes: 1 addition & 1 deletion ext/IntegralsFastGaussQuadratureExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::Integrals.GaussLeg
err = nothing
SciMLBase.build_solution(prob, alg, val, err, retcode = ReturnCode.Success)
end
end
end
2 changes: 1 addition & 1 deletion src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ function GaussLegendre(; n = 250, subintervals = 1, nodes = nothing, weights = n
nodes, weights = gausslegendre(n)
end
return GaussLegendre(nodes, weights, subintervals)
end
end
28 changes: 14 additions & 14 deletions test/gaussian_quadrature_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,36 @@ alg = GaussLegendre(subintervals = 7)
sol = solve(prob, alg)
@test sol.u -exp(3) * 3.3 + 3.3 / exp(5) - 40 + cos(5) - cos(3)

f = (x, p) -> exp(-x^2)
f = (x, p) -> exp(-x^2)
prob = IntegralProblem(f, 0.0, Inf)
alg = GaussLegendre()
sol = solve(prob, alg)
@test sol.u sqrt(π)/2
alg = GaussLegendre(subintervals=1)
@test sol.u sqrt(π)/2
alg = GaussLegendre(subintervals=17)
@test sol.u sqrt(π)/2
@test sol.u sqrt(π) / 2
alg = GaussLegendre(subintervals = 1)
@test sol.u sqrt(π) / 2
alg = GaussLegendre(subintervals = 17)
@test sol.u sqrt(π) / 2

prob = IntegralProblem(f, -Inf, Inf)
alg = GaussLegendre()
sol = solve(prob, alg)
@test sol.u sqrt(π)
alg = GaussLegendre(subintervals=1)
alg = GaussLegendre(subintervals = 1)
@test sol.u sqrt(π)
alg = GaussLegendre(subintervals=17)
alg = GaussLegendre(subintervals = 17)
@test sol.u sqrt(π)

prob = IntegralProblem(f, -Inf, 0.0)
alg = GaussLegendre()
sol = solve(prob, alg)
@test sol.u sqrt(π)/2
alg = GaussLegendre(subintervals=1)
@test sol.u sqrt(π)/2
alg = GaussLegendre(subintervals=17)
@test sol.u sqrt(π)/2
@test sol.u sqrt(π) / 2
alg = GaussLegendre(subintervals = 1)
@test sol.u sqrt(π) / 2
alg = GaussLegendre(subintervals = 17)
@test sol.u sqrt(π) / 2

# Make sure broadcasting correctly handles the argument p
f = (x, p) -> 1 + x + x^p[1] - cos(x*p[2]) + exp(x)*p[3]
f = (x, p) -> 1 + x + x^p[1] - cos(x * p[2]) + exp(x) * p[3]
p = [0.3, 1.3, -0.5]
prob = IntegralProblem(f, 2, 6.3, p)
alg = GaussLegendre()
Expand Down

0 comments on commit 7558b18

Please sign in to comment.