2,472 questions
3
votes
3
answers
105
views
Numerically finding the minimum value of a variable where a function equals a value
I have a black box function baseball that determines the magnitude of the distance that a baseball travels when launched. It takes the initial speed, the angle of launch and the initial spin. Assuming ...
2
votes
2
answers
120
views
Estrin polynomial evaluation - Intel ICX strange slowdown for lengths 16N-1
Porting what I believe to be working code for a radix-2 Estrin polynomial evaluation scheme to the Intel ICX 2024 compiler I am seeing a slowdown for a handful of polynomial lengths just below 16*N (...
1
vote
0
answers
57
views
Is it possible to reduce the memory requirements for (I)FFT by chunking?
I'm trying to run an IFFT on a very long signal (10^9 data points) and I'm running into RAM constraints. I'd like to be able to chop up the signal and run it in batches (as I am not time constrained ...
-1
votes
2
answers
180
views
Is there a faster method to compute these distance-based sums over a nonuniform grid of cells?
I'm attempting to implement an algorithm to compute an array of values. Unfortunately, I've found the literal implementation of that algorithm to be too slow for my use case. I suspect there's an ...
2
votes
2
answers
117
views
Differentiating OdeSolution object
I would like to compute the residual of the numerical solution to an ordinary differential equation.
Here is the code
import numpy as np
from scipy.integrate import solve_ivp
def f(t, x):
return ...
-2
votes
2
answers
233
views
Taylor Series in Java using float
I am implementing a method berechneCosinus(float x, int ordnung) in Java that should approximate the cosine of x using the Taylor series up to the specified order.
My questions:
Can I optimize the ...
1
vote
0
answers
75
views
LAPACK Inconsistent across multiple different operating systems and devices
Description
I have a deterministic program that uses jax, and is heavy on linear algebra operations.
I ran this code on CPU, using three different CPUs. Two MacOs Systems (one on Sequoia (M1 Pro), ...
1
vote
1
answer
60
views
Reducing to Hessenberg form using Givens rotations
I'm trying to implement a function in Python that reduces a square matrix to upper Hessenberg form using Givens rotations. I know that this should be possible Wiki and sometimes preferred over ...
0
votes
1
answer
162
views
One adaptive-time-step solution for ODE
I want to solve some ODE just for one time step. The time step is decided internally by the solver, not by me. Is there a python adaptive-time-step ode solver which could do this? For illustration the ...
2
votes
1
answer
69
views
Volume preservation in phase space in leapfrog algorithm
Based on the information provided in these lecture notes, the leapfrog integration algorithm should preserve area (for single-body systems) in phase space.
I implemented the algorithm for a Coulomb ...
8
votes
2
answers
735
views
Sine approximation, did i beat Remez?
First, it is most compact sine approximation ever. It seems i can do better than Remez in terms of precision/performance. Here [0,pi/2] approximation range.
double p[] =
-0.0020836519336891552,
-0....
0
votes
0
answers
69
views
Compute Double integral of a function f(x,y) giving its values on a grid with python
For a grid ((xi,yj))i,j, and a function f with well knows values at points (xi,yi). We want to compute the double integral of f according to a measure phi(y)dxdy, where phi is a normalized function.
...
4
votes
5
answers
314
views
Why no floating point error occurs in print(0.1* 100000) vs (Decimal(0.1)*100000) due to FP representation of 0.1?
I am studying numerical analysis and I have come across this dilemma.
Running the following script,
from decimal import Decimal
a = 0.1 ;
N = 100000 ;
# product calculation
P = N*a
# Print product ...
0
votes
0
answers
63
views
Phase Portrait of Coupled ODEs Not Matching Expected Graph in Python (SciPy)
I’m trying to generate a phase portrait for a system of coupled ordinary differential equations (ODEs) using Python’s scipy.integrate.solve_ivp. The system models the frequency of cooperators (x) and ...
0
votes
1
answer
82
views
Difference in output of sympy.binomial vs scipy.special.comb
Why does the following code that calls comb produce the wrong output?
from scipy.special import comb
from sympy import binomial
def coup(n=100, m=10):
expectation = 0
for j in range(1, n + 1):
...
0
votes
0
answers
38
views
Partial derivative of logistic function for Levenberg-Marquardt
I am trying to write code that will fit logistic function to set of data. I am using Levenberg-Marquardt routine (as given in Numerical Recipes 3rd edition) and that requires me to supply a function ...
0
votes
0
answers
62
views
How to simulate in python the superconducting density of states of a BCS superconductor with YSR (yu-shiba-rusinov) with 1D chain tight binding model
I try to simulate the following problem:
Compute the density of states numerically of a BCS superconductor with magnetic impurities using the tight binding model of 1D chain with periodically border ...
0
votes
0
answers
49
views
Simple MD simulation for N atoms with PBC in Python
I'm trying to implement a simple molecular dynamic simulation in Python for N atoms with periodic boundary conditions while allowing coordinate wrapping to visualize the atoms interacting through
...
1
vote
1
answer
66
views
MD simulation using velocity verlet in Python
I'm trying to implement a simple MD simulation in Python (I'm new to this),I'm using LJ potential and force equations along with Verlet method:
def LJ_VF(r):
#r = distance in Å
#Returns V in (...
0
votes
0
answers
30
views
Combining the Adams-Bashforth-Method with Richardson-Extrapolation
I am experimenting with an N-Body-Simulation with the goal to be efficient with a large number of particles. That means, the most costly thing will be calls to the ODE-function. Adams-Bashforth only ...
0
votes
0
answers
39
views
Optimizing a numerical integration that involves matrices using sympy
The expression I'm integrating is
Where the latent variables are sampled from the a multivariate distribution as following:
And the random variables w_n given a latent variable is sampled from a ...
0
votes
2
answers
59
views
Computing an iterated integral by iteratively applying the 1D trapezoidal rule
I have a Python function, called trap_1D, which computes the (approximate) integral of a univariate function f over an interval [a,b] using the composite trapezoidal rule. Now I want to evaluate an ...
0
votes
0
answers
53
views
Solving differential equations with ode solvers and finite difference in Matlab
I have implemented following equations both with the Matlab own ODE solvers and with a very simple finite difference scheme. The latter works properly, while the ODE code does not produce suitable ...
0
votes
1
answer
143
views
Numerical instability in forward-backward algorithm for Hidden Markov Models
I am implementing the forward algorithm for Hidden Markov Models (see below for the algorithm). To prevent over/underflow, I work with log-probabilities instead, and use the log-sum-exp trick to ...
2
votes
2
answers
191
views
Algorithm for calculating fraction from decimal with limits
The algorithm for calculating a fraction from a decimal number is known and there are enough examples for that. In my case I need to find a fraction for a given decimal where A = N/D is optimized but ...