Skip to content

power: avoid pow for the exponents of x^2 and x^(-1) - #171

Merged
dance858 merged 1 commit into
mainfrom
power-fast-exponents
Nov 25, 2026
Merged

dance858 merged 1 commit into
mainfrom
power-fast-exponents

Conversation

@dance858

Copy link
Copy Markdown
Collaborator

power called libm's pow for every entry, even for x^2 and x^(-1). It now uses plain arithmetic for the exponents those two and their derivatives need (2, 1, 0, -1, -2, -3) and pow for the rest. Results can differ from pow in the last bits.

Median ms, before / after:

Problem Gradient Jacobian Hessian
battery-calibration, K = 20000 0.291 / 0.076 0.786 / 0.605 2.24 / 1.67
control-of-car, N = 10000 0.660 / 0.177 0.476 / 0.479 2.22 / 1.62
optimal-power-flow, 10000 buses 0.070 / 0.052 3.76 / 2.66 8.84 / 7.41
nmf (100, 100, 5) 0.313 / 0.208 - 1.94 / 1.82

🤖 Generated with Claude Code

https://claude.ai/code/session_012aJMguJbVnytNNJEuvumcb

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012aJMguJbVnytNNJEuvumcb
@dance858
dance858 merged commit 884723d into main Nov 25, 2026
14 checks passed
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

Successfully merging this pull request may close these issues.

1 participant