-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add transformations for infinite and semi infinite integral. #33
Conversation
@ChrisRackauckas I applied this to Quadrature Algorithms. Can you check this further so that I can apply this to Cubature as well? |
What do you mean? Cubature is just multi-dimensional quadrature. |
@ChrisRackauckas No, I meant have I done correctly ? I added the check only to |
It looks like it's written always assuming that lb and ub is scalar or length 1 which isn't correct, but when that's fixed it should be good to go. |
No, I have checked this works for vector inputs as well. Should I add a test case as well? |
Yes, on scalar and vector. |
src/Quadrature.jl
Outdated
function transform_inf(t , p , f) | ||
v(t) = t ./ (1 .- t.^2) | ||
if t isa Number | ||
j = ForwardDiff.derivative(v, t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just write down the analytical solution to the derivatives here?
src/Quadrature.jl
Outdated
end | ||
|
||
function transformation_if_inf(prob) | ||
if (!(prob.lb isa Number) && all(prob.lb .== -Inf) && all(prob.ub .== Inf)) || (prob.lb == -Inf && prob.ub == Inf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this could be selectively applied to the directions which are Inf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, does the transformation hold for that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can cache the indexes to transform and then if transform, then X otherwise identity.
src/Quadrature.jl
Outdated
if lb isa Number && ub isa Number | ||
if lb == -Inf && ub == Inf | ||
j = (1 .+ t.^2 )/(1 .- t.^2).^2 | ||
return f(v_inf(t) , p)*(j) | ||
elseif lb != -Inf && ub == Inf | ||
a = lb | ||
j = 1 ./ ((1 .- t).^2) | ||
return f(v_semiinf(t , a) , p)*(j) | ||
elseif lb == -Inf && ub != Inf | ||
error("Semi Infinte integrals of limits 0 to Inf are supported") | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a separate dispatch
src/Quadrature.jl
Outdated
j = 1 ./ ((1 .- t).^2) | ||
return f(v_semiinf(t , a) , p)*(j) | ||
elseif lb == -Inf && ub != Inf | ||
error("Semi Infinte integrals of limits 0 to Inf are supported") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you just flip the integral to handle this case?
No description provided.