r/numerical • • 4h ago

507 functions in pure standard library, and the 1155x slowdown that comes with it

0 Upvotes

There is a class of problem where the dependency graph is the problem. You want a Runge-Kutta step, a Gauss-Legendre quadrature rule, a Cholesky factorisation, a symplectic integrator for a Hamiltonian system, and to get any of them you end up with NumPy, SciPy, matplotlib and whatever those pull in, on a machine that may not have a C toolchain. I wrote this library for the case where the thing that has to keep working is the physics, not the wheel.

scientific-computing-system is pure Python with zero runtime dependencies: 34 subpackages plus causal.py and sensitivity.py, 35 public feature modules, exporting 507 names (343 functions, 164 classes). tests/test_readme_surface.py derives those counts from the package itself, so the number in the README cannot drift away from the code.

What is inside, briefly: linear algebra and calculus (cds.math_utils, cds.interpolate with SVD, QR, Cholesky, LU, power iteration), ODE and PDE solvers (cds.diffeq, cds.pde with Euler, RK4, adaptive RK45, implicit stiff methods, symplectic integrators, 1-D heat and wave), quadrature (cds.numerical_integration with trapezoid, Simpson 1/3 and 3/8, Romberg, Gauss-Legendre, adaptive Simpson, 2-D tensor rules), optimisation (gradient, Newton, Adam, Nelder-Mead, annealing), statistics and Bayes (cds.stats, cds.probability, cds.bayes), Monte Carlo, an educational cds.ml, signal processing and wavelets, single and multi-qubit state-vector circuits in cds.quantum, graph algorithms, symbolic modelling with expression trees and LaTeX export in cds.modeling, uncertainty propagation and variance-based sensitivity, units with dimensional compatibility, and a workflow layer with approval gates and hash-based run manifests.

The CLI is a cds command with 13 subcommands: modules, info, version, constants, calc, stats, sample, integrate, hypothesis, prompt, benchmark, plot and dashboard. Two of those are honest caveats rather than features: cds modules prints a curated 26 entries and is not the full catalog, and cds dashboard needs the [dashboard] extra.

The catch is real and the README does not hide it. Pure Python is slow on dense numerics: the committed benchmark artifact records 100x100 matrix multiplication at 0.0696 s against NumPy's 0.000060 s, about 1155x slower. That number comes from one CI run whose platform, CPU and library versions were not recorded, so it is order-of-magnitude rather than a measurement you can compare against your machine.

Install is pip install scientific-computing-system, or npm install -g scientific-computing-system for the Node wrapper. Optional extras exist for plotting ([plot]) and the dashboard, and there are lazy backend adapters in cds.tools that discover NumPy, SciPy, statsmodels, scikit-learn, SymPy or Z3 if you happen to have them, without requiring any of them.

What it does not do: it is not a NumPy replacement and the README says so, the machine-learning module is educational rather than production, and if your workload is dense linear algebra at scale you should reach for the 2.0 build or NumPy. MIT, 2.2.25: https://github.com/Furox-Art/scientific-computing-system


r/numerical • • 8d ago

Physics Programming Part 5: Spring Physics

Thumbnail youtu.be
1 Upvotes

I explain the mathematics underpinning spring mechanics then implement a solution in C++ using a net as an example. Implementation begins at 10:05. Feedback is welcome.


r/numerical • • 29d ago

Free plane stress/strain FEA tool with h- and p-refinement (up to P=4) and stress-line visualization

Thumbnail github.com
3 Upvotes

Hi all,

I’ve been working on an open-source 2D finite element solver focused on plane stress / plane strain problems. It has a particular emphasis on principal stress trajectories, which I find really useful for building intuition about how load flows through a structure (the same idea behind strut-and-tie thinking and optimizing shapes around holes and notches).

What it does:

  • Plane stress and plane strain formulations
  • h-refinement (1 element → 4 or 16)
  • p-refinement up to P=4: T3/T6/T10/T15 triangles and Q4/Q9/Q16/Q25 quads
  • Solves with either the Elimination or Lagrange Augmentation method
  • Abaqus-style .inp mesh import
  • Contours for displacement, σxx, σyy, τxy, von Mises, principal stresses and max shear
  • Two stress-line (PSL) modes: a grid-based one and a continuous streamline one
  • Animated results and an adjustable contour range, so a single stress concentration doesn’t wash out the plot
  • Interactive OpenTK viewer, with a C# front end and a C++ solver (DLL)

Included example problems: plate with a central hole (full and symmetric models), notched plate, four-point bending beam, padeye with inclined load, circular arch, annular disc, beam-column and a frame. Screenshots and GIFs are in the README.

It’s MIT licensed, and the repo has a pre-built Release folder, so you can try it without compiling.

🔗 https://github.com/Samson-Mano/Plane_stress_analyzer_PSL


r/numerical • • Sep 29 '26

The Physics Update Loop

Thumbnail youtu.be
1 Upvotes

I go through how I separate general updates from physics updates, why I use a fixed timestep, how the accumulator works, and what happens when the simulation starts falling behind.

I explain the reasoning behind the design decisions and why I rejected the alternatives. I show the implementation of the loop.


r/numerical • • Sep 27 '26

https://youtu.be/vBp8mKsKrOo

1 Upvotes

r/numerical • • Sep 04 '26

Which OS is best for developing numerical models that leverage ai

0 Upvotes

I am an engineer that develops numerical models and I want to integrate ai into my workflow of modeling cfd simulation, parameter estimation and optimization . I personally think that developing everything in Mac OS and creating a version of my modeling software to run in Linux solely for running in hpc for models with too many cells. I don’t think a pc version or even owning a pc is even needed when the only software needed is my own cpp Fortran and python model for ai leverage, numerical modeling and simulation, and Tecplot and Blender for post processing and visualization. Does anyone absolutely need a pc for numerical modeling?


r/numerical • • Aug 23 '26

What career paths exists between computational mechanics, scientific computing (SciML), FEA (or meshfree) solver development, and HPC (GPU acceleration, porting codebases) ?? How about doing a PhD for improving the above?

5 Upvotes

I'm currently, technically, doing an MS in Structural Engineering. For me, my interest has been more towards computational side of mechanics rather than Structural design  or simply using am FEA software (although I do consider it as a backup)

So far I've taken courses in:

- Linear static, and dynamics FEM (soon taking non linear FEM too)

-  Structural Optimization (topology opt. and other general algorithms)

-  Structural Dynamics

-  Structural System Testing and model updation. (Parameter identification and optimization, signal processing)

Now, I plan to take these in the coming quarter:

- Numerical Linear Algebra

- Numerical PDE

- Fracture Mechanics ?

I also volunteered to aid in a RESEARCH in crack growth prediction using Auto-encoder and a (Thermodynamics-informed Latent Space Dynamics Identification) / LSTM surrogate model. It used phase-field-fracture simulation data and HPC resources to complete the whole thing.

What I keep finding myself interested in is not necessarily fracture or SHM specifically, but the computational methods underneath these problems... (does that make sense?)

For example, I'd like to become capable of doing things like:

- implementing (maintaining) numerical/FE method solvers rather than only running an established FEA software.

- developing surrogate/reduced-order models for expensive simulations 

- combining simulation with optimization, uncertainty/stochastic methods (took a course called Random vibrations, so...)

- parallelizing/accelerating scientific codes on CPUs/GPUs

- doing proper verification, convergence studies, benchmarking and performance work

- potentially developing or maintaining actual CAE/FEA solver software

- I'd also like to do all these for other Physics (GR, QM, etc.) simulations too, if possible, one day. 

I'm still interested in the underlying mechanics/physics, so I don't want to become a generic software engineer who happens to have once studied structures. But I'm also increasingly unsure that "structural engineer" describes the career I'm actually aiming for.

I've seen titles such as Computational Mechanics Engineer, R&D Engineer, Solver Developer, Scientific Software Engineer, CAE Software Developer, Research Engineer, Simulation/HPC Engineer, etc., but I'm trying to understand what these careers actually look like from people doing them.

So my main questions become:

1. Which industrial jobs genuinely involve developing numerical methods/solvers or computational tools?

2. Which of those are realistically accessible with an MS? Is there an entry path into solver-algorithm development/R&D without a PhD?

3. If I don't start a PhD immediately after my MS, would an R&D/software role at a simulation company (ANSYS etc.) be the obvious route? What other options would i have?

4. For the kind of work I'm describing, would you recommend a PhD? If so, is it reasonable for the PhD identity to be "computational mechanics/scientific computing" while fracture, composites, structural dynamics, soft materials, etc. serve as application problems rather than choosing one of those as my permanent specialization?

5. What skills most distinguish someone who is actually hireable for solver/scientific-computing work? I'm particularly wondering about C/C++/Fortran, Python, Linux, Git/build systems, MPI/OpenMP/CUDA, PETSc/Trilinos or similar libraries, numerical linear algebra, testing/verification, convergence studies and HPC performance work.

Basically, I'm neither here nor there atp. So I'd really appreciate all sorts of input. Where else do you think I could find answers to these? other subs? Linkedin profiles?


r/numerical • • Jul 22 '26

Physics Programming part 3 - Rotation and the Quaternion

Thumbnail youtu.be
3 Upvotes

r/numerical • • Jun 23 '26

Is it wise to create a mesh out of unit cells with scanline algorithm

Thumbnail reddit.com
2 Upvotes

r/numerical • • Jun 20 '26

Angular Momentum and The Inertia Tensor

Thumbnail youtu.be
1 Upvotes

r/numerical • • May 21 '26

Introduction to Integration Methods

Thumbnail youtu.be
3 Upvotes

r/numerical • • Feb 24 '26

Gauss-Legendre Quadrature in Arbitrary Precision

8 Upvotes

Just for fun, I decided to try my hand at computing the weights and abscissae of the Gauss-Legendre quadrature numerically in arbitrary precision. Here is the GitHub repo. Mostly relying on the mpmath Python library.

The basic idea ended up being to use a uniform grid and perform a bisection search in each interval until the correct number of zeroes were found for the Nth Legendre polynomial. I don't have much experience working with Legendre polynomials (and their zeroes), so I would be very appreciative if someone could point towards a more efficient algorithm.

Enjoy!


r/numerical • • Feb 13 '26

Electron Scattering by repulsive (smoothed) Coulomb potential confined in a 2D Box (Visualizing Quantum Mechanics)

9 Upvotes

Electron scattering by repulsive (smoothed) Coulomb potential at the center. The 1x1 normalized two-dimensional region confines the particle, once Dirichlet-type conditions are set at the mesh boundaries; this allows visualization of the post-collision interference pattern structure. Numerical simulation of the time-dependent Schrödinger equation, performed in Python. Implicit method of Crank-Nicolson PDEs (unitary). Initial condition: Gaussian packet. Note: Time scale and physical constants are set to arbitrary units for this preliminary testing phase.

Source Code & More Simulations: I have documented this project, including the Python source code on my personal portfolio. You can also find other simulations on Quantum Mechanics and other Physics topics there:

https://alexisfespinozaq.github.io/aespinoza-physics-portfolio/

Feedback on the physics or the code implementation is very welcome!


r/numerical • • Feb 10 '26

Check out these Six Pythag Proofs, all Visualised with Animation!

Thumbnail youtu.be
0 Upvotes

r/numerical • • Jan 19 '26

just a fun simulation

Post image
6 Upvotes

r/numerical • • Jan 19 '26

[Research, Question] Using Symplectic Integrators (Leapfrog) inside Neural Networks to preserve gradient norms over 10k steps. Is this numerically sound?

5 Upvotes

Hi everyone,

I'm working on a project where I try to replace standard matrix multiplications in Recurrent Neural Networks (RNNs) with a Hamiltonian dynamics update step.

The goal is to solve the "vanishing gradient" problem (where the signal decays exponentially over time) by treating the hidden state update as a flow on a manifold using a Symplectic Integrator.

My Approach:

  1. State: Separated into Position q and Momentum p.
  2. Integrator: I'm using a standard Position-Verlet / Leapfrog scheme.
  3. Constraint: Since calculating the exact Riemannian metric tensor is too expensive O(d^3), I am approximating the Christoffel symbols using a Low-Rank factorization to keep it O(d).

The Result:

Empirically, the stability is shocking.

I can train the model on short sequences T=20 and extrapolate to T=10,000 with 100% accuracy on the Parity/XOR task.

This implies that the learned dynamics are preserving the relevant phase space structure (parity bit) without significant drift for orders of magnitude longer than the training horizon.

Test the model: https://huggingface.co/spaces/Manifold-Labs/manifold-xor-demo

My Question for this sub:

From a numerical analysis perspective, does applying a symplectic integrator to a system with external forcing (the inputs to the neural net) completely invalidate the conservation properties?

I know energy isn't perfectly conserved, but does the "bounded error" property of symplectic integrators still hold effectively enough to explain this extreme stability/extrapolation?

I would love a sanity check on the math.

Code/Repo: https://github.com/DepthMuun/gfn

Edit: Testing visual GFN vs VIT

To achieve this, no architectural changes of any kind were made, the test was simply carried out by importing the libraries that the collector already has. It's a test, don't take it as a final result.


r/numerical • • Dec 26 '25

TT/QTT

1 Upvotes

r/numerical • • Nov 22 '25

Need clarification: CFD or PINN

Thumbnail reddit.com
1 Upvotes

r/numerical • • Nov 03 '25

What makes research valuable in scientific computing today?

Thumbnail reddit.com
2 Upvotes

r/numerical • • Oct 12 '25

What branch of mathematics formally describes operations like converting FP32 ↔ FP64?

Thumbnail reddit.com
3 Upvotes

r/numerical • • Oct 01 '25

Compact and efficient approximation with composition of polynomial

Thumbnail reddit.com
0 Upvotes

r/numerical • • Sep 28 '25

Historical origin of polar decomposition and Newton–Schulz iteration — how were they actually founded?

3 Upvotes

I’d like to know the historical process behind two mathematical/numerical methods:

  • Polar decomposition (factorizing a matrix).
  • Newton–Schulz iteration.

My question isn’t just who first wrote them down, but how they were invented:

  • What problems or contexts led Autonne (or others) to polar decomposition? Was it geometric (analogy to complex polar form), mechanical (deformation gradient = rotation × stretch), or theoretical?
  • How did Schulz’s idea emerge? Was it a response to early computational limitations, or a mathematical curiosity later applied to matrices?

I’d love to understand what kind of analogies, problems, or constraints guided these mathematicians — essentially, how they thought their way into discovering these methods, not just the final result. I’d appreciate a timeline, the key figures/papers, and especially what the inventors were trying to achieve at the time.


r/numerical • • Aug 27 '25

For real-world QR factorisations, which factor matters more? Q, R, or both?

Thumbnail reddit.com
1 Upvotes

r/numerical • • Aug 18 '25

QR in practice: Q & R or tau & v?

Thumbnail reddit.com
3 Upvotes

r/numerical • • Aug 15 '25

QR algorithm in 2025 — where does it stand?

Thumbnail reddit.com
6 Upvotes