Skip to content

feat: add math/base/special/chebyshev-u-polynomial - #17005

Open
anshurajbisoyi98-ctrl wants to merge 1 commit into
stdlib-js:developfrom
anshurajbisoyi98-ctrl:feat-chebyshev-u-polynomial
Open

anshurajbisoyi98-ctrl wants to merge 1 commit into
stdlib-js:developfrom
anshurajbisoyi98-ctrl:feat-chebyshev-u-polynomial

Conversation

@anshurajbisoyi98-ctrl

Copy link
Copy Markdown
Contributor

Description

What is the purpose of this pull request?

This pull request:

  • adds @stdlib/math/base/special/chebyshev-u-polynomial, which evaluates a Chebyshev polynomial of the second kind.

For integer n it uses the three-term recurrence, like SciPy's eval_chebyu, with U_{-n}(x) = -U_{n-2}(x) for negative degrees. Non-integer n is defined through the hypergeometric function, as in the issue, but I evaluate it with the equivalent closed form sin((n+1)θ)/sin(θ) (and the sinh version for x > 1) instead of calling hyp2f1 directly. With hyp2f1 the results drift badly for larger |n| once x is negative:

// n = 15.346288344544398, x = -0.8962157653203189
// mpmath:                -0.31945900691175589
// (n+1)*hyp2f1( ... ):    0.04666264165261343
// this package:          -0.3194590069117585

SciPy has the same problem for non-integer degrees, so the test fixtures are generated with mpmath.chebyu rather than SciPy.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

Is the closed form OK for non-integer degrees, or would you rather keep hyp2f1 to match SciPy? I can also add the C implementation in a follow-up PR.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution.

I used Claude Code to write the package, tests and docs, following the layout of hyp2f1 and the review comments on #5774. I checked accuracy against mpmath and SciPy, and ran the tests, examples and benchmark locally.


@stdlib-js/reviewers

Signed-off-by: anshurajbisoyi98-ctrl <anshurajbisoyi98@gmail.com>
@anshurajbisoyi98-ctrl
anshurajbisoyi98-ctrl requested a review from a team November 30, 2026 11:15
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Nov 30, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/chebyshev-u-polynomial $\\color{green}325/325$
$\\color{green}+100.00\\%$
$\\color{green}39/39$
$\\color{green}+100.00\\%$
$\\color{green}3/3$
$\\color{green}+100.00\\%$
$\\color{green}325/325$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: evaluate a Chebyshev polynomial of the second kind at a value x

2 participants