num_integrate_semi_infinite is right-infinite only, so the documented left-infinite rule rejects a convergent integral

Open
#372 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
r, rust
Domain
backend, data

Research direction

Start by locating num_integrate_semi_infinite and num_integrate_left_infinite and comparing their implementations with the num_integrate_semi_infinite docstring. Reproduce the reported integral(-inf,0] case and inspect how callback evaluation failures are reported. Done when the left-infinite behavior matches the documented rule and the convergent example succeeds without a misleading evaluation-budget error.

Written by the indexing model from the issue text.

Description

area/numerical good first issue help wanted kind/doc-mismatch severity/4-minor

num_integrate_semi_infinite only ever integrates [bound, +inf); the left-infinite rule that its own docstring lists is not implemented there, so a convergent integral(-inf,0] of exp(x) fails with an error that blames the evaluation budget.

suppressWarnings(suppressMessages(library(rssn)))
s <- rssn_session()
p <- function(lbl, e) cat(sprintf("%-42s %s\n", lbl,
       tryCatch(value_text(e), error = function(z) paste("ERROR:", conditionMessage(z)))))
ex <- rssn_callback(function(x) exp(x),  s, signature = "(float) -> float")
en <- rssn_callback(function(x) exp(-x), s, signature = "(float) -> float")
p("semi_infinite(0, 1e-12, 400, exp(x))",  call_value("num_integrate_semi_infinite", 0, 1e-12, 400, ex, session = s))
p("left_infinite(0, 1e-12, 400, exp(x))",  call_value("num_integrate_left_infinite", 0, 1e-12, 400, ex, session = s))
p("semi_infinite(0, 1e-12, 400, exp(-x))", call_value("num_integrate_semi_infinite", 0, 1e-12, 400, en, session = s))
semi_infinite(0, 1e-12, 400, exp(x))   ERROR: outside the domain of the operator: argument 3 must be finite and representable as Float
left_infinite(0, 1e-12, 400, exp(x))   {value: 1, evaluations: 189, error: 0.00000000000005675870579818286, converged: true}
semi_infinite(0, 1e-12, 400, exp(-x))  {value: 1, evaluations: 189, error: 0.00000000000005675870579818286, converged: true}

integral(-inf,0] exp(x) dx = 1 converges, and num_integrate_left_infinite computes it, so the request is well posed. The docstring of num_integrate_semi_infinite says "Semi-infinite rules: finite_bound,tolerance,max_evaluations,callback; left-infinite integrates (-infinity,bound], right-infinite [bound,infinity)" and the description ends "Integral over [a, inf) using x = a + t/(1-t), t in [0, 1)" — the operator is only the right-infinite map, and the left-infinite bullet describes a different operator. The two 1 results above are bit-identical (189 evaluations, same error estimate) because semi_infinite(0, exp(-x)) and left_infinite(0, exp(x)) are mirror images of one another, which confirms the direction is fixed rather than chosen from the bound.

The error text also misdirects: "argument 3" is max_evaluations (400, perfectly finite); the offending value is the callback's exp(x) at a large node. A user following the docstring concludes their budget is malformed.

rssn 0.3.0, R 4.6.2 binding, Windows x86_64.

Dominant language
Rust
Stars
36
Forks
3
Avg merge
14h 51m
Merged PRs (30d)
29

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Apich-Organization/rssn

All issues in Apich-Organization/rssn

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.