Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/6959ed27-accc-800e-8e87-21aa81e93c07
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=========================================================================== βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β 0xfaded's Curvature Method Analysis β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£ β β β STRENGTHS: β β β No trig functions in main loop (only sqrt/hypot) β β β Excellent SIMD/vectorization potential β β β Fixed iteration count (predictable performance) β β β Elegant geometric interpretation (evolute-based) β β β Robust across all eccentricities β β β β PERFORMANCE: β β β’ Scalar (Python): Comparable to Newton (~0.7-1.0x) β β β’ Vectorized (NumPy): Up to 2-4x faster than Newton β β β’ The advantage grows with batch size and parallelization β β β β BEST USE CASES: β β β’ Batch processing many points β β β’ GPU implementations (CUDA, OpenCL) β β β’ Game engines / collision detection β β β’ Real-time graphics β β β’ Any SIMD-optimized code β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ This is much more revealing! The vectorized benchmark clearly shows where 0xfaded's curvature method really shines: When vectorized with NumPy, the curvature method is 2-4x faster than Newton's method This is because sqrt operations vectorize much better than trig operations The advantage is consistent across different eccentricities Let me now copy the comprehensive analysis to the outputs folder and create a nice summary. Excellent! Now let me copy everything to outputs and create a summary report: I've created a comprehensive benchmark analysis. Let me now provide a summary to the user that captures the key findings. Results Summary The benchmarks confirm that 0xfaded's curvature-based method is 2-4x faster than Newton's method when vectorized (processing batches of points). Here are the key findings: Vectorized Performance (the real win) Batch Size Curvature Method Newton's Method Speedup 10,000 pts 1.2 ms 3.7 ms 3.0x 100,000 pts 10-14 ms 40-41 ms 3-4x Why It's Faster The curvature method's genius is avoiding trigonometric functions in the main loop: Curvature method: Uses only sqrt, *, /, +, - (all vectorize excellently) Newton's method: Requires cos, sin every iteration (expensive and hard to vectorize) On modern CPUs: sqrt: ~15-20 cycles, vectorizes 4-8 operations at once sin/cos: ~50-100 cycles, poor vectorization Accuracy Both methods achieve identical machine-precision accuracy (~4Γ10β»ΒΉβΆ deviation from the ellipse). Bottom Line For single-point calculations in Python, Newton's method is slightly faster due to Python's optimized C math library. But for batch processing, GPU computing, game engines, or any SIMD-optimized code, the curvature method delivers significant performance gainsβexactly the use cases mentioned in that Hacker News thread (collision plugins for Unity, etc.). Ellipse benchmark summary Document Β· MD Comprehensive analysis PY Micro benchmark PY Ellipse benchmark PY Wait, can you benchmark this in c or c++ or rust or zig instead, I don't trust microbenchmarks in python like this 7:59 PM The user is right to be skeptical - Python has a lot of overhead and the results can be misleading. Let me create a proper C or C++ benchmark that will give more accurate results. I'll use C++ since it's straightforward and will show the true performance characteristics. You're absolutely right - Python's interpreter overhead and optimized C math library can mask the real differences. Let me write a proper C++ benchmark. bash cd /home/claude && g++ -O3 -march=native -ffast-math ellipse_benchmark.cpp -o ellipse_benchmark -lm && ./ellipse_benchmark Output
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)