Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler first example #106

Closed
KronosTheLate opened this issue Oct 11, 2022 · 1 comment
Closed

Simpler first example #106

KronosTheLate opened this issue Oct 11, 2022 · 1 comment

Comments

@KronosTheLate
Copy link
Contributor

KronosTheLate commented Oct 11, 2022

I can imagine a non-trivial portion of users only want to perform 1D integrals. A simple example showing how a numerical integral of cosine equals sine would be:

julia> using Integrals

julia> f(x, p) = cos(x)
f (generic function with 1 method)

julia> my_sin(x) = solve(IntegralProblem(f, 0, x), HCubatureJL()).u 
my_sin (generic function with 1 method)

julia> # `my_sin` is a numerical approximation of sin

julia> # The integration constant is zero

julia> let x = rand(10)
           @. my_sin(x) ≈ sin(x)
       end
10-element BitVector:
 1
 1
 1
 1
 1
 1
 1
 1
 1
 1

This example does the problem specification, solving, and solution extraction in a single line and of course therefore not be the first example. But something to that flavor.

@ChrisRackauckas
Copy link
Member

Yes, this would be a good thing to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants