Agent skill
numpy-polynomial
Install this agent skill to your Project
npx add-skill https://github.com/cuba6112/skillfactory/tree/main/skills/numpy-polynomial
SKILL.md
Overview
NumPy's polynomial package provides a modern, class-based API for handling power series. It replaces the legacy poly1d conventions with objects that handle domain scaling, root finding, and advanced orthogonal polynomials (Chebyshev, Legendre) for numerical stability.
When to Use
- Fitting a curve to noisy experimental data using least-squares.
- Finding the zeros (roots) of a mathematical function approximated by a polynomial.
- Performing high-precision function approximation using Chebyshev series.
- Computing integrals or derivatives of polynomial models.
Decision Tree
- Creating a new polynomial from coefficients?
- Use
Polynomial([c0, c1, c2]). Note: coefficients are in increasing degree.
- Use
- Fitting data?
- Use
Polynomial.fit(x, y, deg). It automatically scales the domain for stability.
- Use
- Need to evaluate the fit?
- Use the returned object directly:
p(x).
- Use the returned object directly:
Workflows
-
Stable Data Fitting
- Identify noisy data (x, y).
- Use
p = Polynomial.fit(x, y, deg=3)to find the best fit. - Evaluate the model over a range using
p.linspace()to visualize the result.
-
Polynomial Root Finding
- Define coefficients
[c0, c1, c2](constant, linear, quadratic). - Instantiate the polynomial:
p = Polynomial(coefs). - Call
p.roots()to find the values of x wherep(x) = 0.
- Define coefficients
-
Orthogonal Series Interpolation
- Import the
Chebyshevclass. - Use
Chebyshev.interpolate(func, deg)to create a series that matches a function at Chebyshev points. - Utilize the resulting object for high-precision function approximation.
- Import the
Non-Obvious Insights
- Increasing Degree: The modern API uses coefficients in order (0, 1, 2...), reversing the
poly1dconvention (highest degree first). This is a common source of bugs during migration. - Domain Scaling:
Polynomial.fit()maps the input $x$ values to a internal window (usually $[-1, 1]$). Evaluating usingp.convert().coefdirectly on raw $x$ values without scaling will fail; always use the class instancep(x). - Arithmetic Restrictions: Polynomials with different domain or window attributes cannot be mixed in arithmetic operations; they must be converted to a shared domain first.
Evidence
- "The various routines in numpy.polynomial all deal with series whose coefficients go from degree zero upward, which is the reverse order of the poly1d convention." Source
- "Polynomials with different domain and window attributes are not considered equal, and can’t be mixed in arithmetic." Source
Scripts
scripts/numpy-polynomial_tool.py: Implements curve fitting and root finding using the modern API.scripts/numpy-polynomial_tool.js: Simulated polynomial evaluator logic.
Dependencies
numpy(Python)
References
- references/README.md
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
prompt-engineering
Comprehensive prompt engineering techniques for Claude models. Use this skill when crafting, optimizing, or debugging prompts for Claude API, Claude Code, or any Claude-powered application. Covers system prompts, role prompting, multishot examples, chain of thought, XML structuring, long context handling, extended thinking, prompt chaining, Claude 4.x-specific best practices, and agentic orchestration including subagents, agent loops, skills, MCP integration, and multi-agent workflows.
adk-rag-agent
Build RAG (Retrieval-Augmented Generation) agents with Google ADK and Vertex AI RAG Engine. Use when implementing document Q&A, knowledge base search, or citation-backed responses. Covers VertexAiRagRetrieval tool, corpus setup, and citation formatting.
headless-cli-agents
Build agentic systems using Claude CLI in headless mode or the Claude Agent SDK. Use when building automation pipelines, CI/CD integrations, multi-agent orchestration, or programmatic Claude interactions. Covers CLI flags (-p, --output-format), session management (--resume, --continue), Python SDK (claude-agent-sdk), custom tools, and agent loop patterns.
notion-knowledge-capture
Capture conversations and decisions into structured Notion pages; use when turning chats/notes into wiki entries, how-tos, decisions, or FAQs with proper linking.
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
gh-fix-ci
Inspect GitHub PR checks with gh, pull failing GitHub Actions logs, summarize failure context, then create a fix plan and implement after user approval. Use when a user asks to debug or fix failing PR CI/CD checks on GitHub Actions and wants a plan + code changes; for external checks (e.g., Buildkite), only report the details URL and mark them out of scope.
Didn't find tool you were looking for?