Questions tagged [numerical-computing]

Is an interconnected combination of computer science and mathematics .

Is an interconnected combination of computer science and mathematics in which we develop and analyze algorithms for solving important problems in science, engineering, medicine, and business, for example, designing a bridge, choosing a stock portfolio, or detecting tumors in medical images

146 questions
2
votes
3 answers

Optimize operations with arrays in numpy

I have to apply some mathematical formula that I've written in python as: for s in range(tdim): sum1 = 0.0 for i in range(dim): for j in range(dim): sum1+=0.5*np.cos(theta[s]*(i-j))* …
user2820579
  • 3,261
  • 7
  • 30
  • 45
2
votes
1 answer

QuickHull worst case

QHull (and perhaps other good implementations of QuickHull) works really well and fast in many cases. However, we know theoretically that its worst case can be O(n^2). In practice I have not seen any numerical example with many dimensions (i.e., 20…
Alef
  • 41
  • 1
  • 7
1
vote
2 answers

Load sparse scipy matrix into existing numpy dense matrix

Say I have a huge numpy matrix A taking up tens of gigabytes. It takes a non-negligible amount of time to allocate this memory. Let's say I also have a collection of scipy sparse matrices with the same dimensions as the numpy matrix. Sometimes I…
conradlee
  • 12,985
  • 17
  • 57
  • 93
1
vote
1 answer

How to tell how small `h` is the in the finite difference?

I'm doing a project required to compute the precise(up to a certain precession N) numerical derivatives of a function. The usual approach was to use the finite difference types of algorithms, i.e. (f(x+h)-f(x))/h However, there's not many document…
1
vote
1 answer

Should one calculate QR decomposition before Least Squares to speed up the process?

I am reading the book "Introduction to linear algebra" by Gilbert Strang. The section is called "Orthonormal Bases and Gram-Schmidt". The author several times emphasised the fact that with orthonormal basis it's very easy and fast to calculate Least…
1
vote
2 answers

How to compute Brjuno function in Maxima CAS?

I try to compute real 1-Brjuno function for real numbers in x in [0, 1] range G(x):= block( [g], if (x=0) then g : 0 else g : float(1/x - floor(1/x)), return( g) )$ bet(j,x) :=…
Adam
  • 1,254
  • 12
  • 25
1
vote
1 answer

fortran : invalid memory reference

I encountered this error while solving the diffusion equation on fortran using alternating directional implicit(ADI) method. Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 …
1
vote
1 answer

Filling pixels under or above some function

Seems like a simple problem, but I just cant wrap my head around it. I have a config file in which I declare a few functions. It looks like this: "bandDefinitions" : [ { "0": ["x^2 + 2*x + 5 - y", "ABOVE"] }, { "0":…
1
vote
4 answers

Accurate sqrt(1 + (x/2)^2) + x/2

I need to compute sqrt(1 + (x/2)^2) + x/2 numerically, for positive x. Using this expression directly fails for very large values of x. How can I rewrite it to obtain a more accurate evaluation?
a06e
  • 18,594
  • 33
  • 93
  • 169
1
vote
1 answer

How to ensure my optimization algorithm has found the solution?

I am performing a numerical optimization where I try to find the parameters of a statistical model that best match certain moments of the data. I have 6 parameters in total I need to find. I have written a matlab function which takes the parameters…
1
vote
1 answer

Numerical Integration - Summations and Functions in Python

Forgive my ignorance, but the function H is actually an infinite sum (including -n terms). I'm hoping to truncate at larger values on the order of the 100s ideally. My code seems to work but I am not sure if it is actually summing over the values of…
1
vote
0 answers

Is Romberg integration method implemented as weighted function values numerically correct?

I have to integrate expression f(x) * g(x) for many different functions f but just one g. I want to integrate it as sum of weighted values of f(x) * g(x) instead of calculating the table. Note that in Python I may write: sum(w[i] * f(x[i]) *…
1
vote
1 answer

Function fzero in Matlab is not converging

I am solving a problem in my Macroeconomics class. Consider the following equation: Here, k is fixed and c(k) was defined through the ```interp1''' function in Matlab. Here is my code: beta = 0.98; delta = 0.13; A = 2; alpha = 1/3; n_grid = 1000; …
1
vote
1 answer

How to solve large nonlinear equations?

I have 3 large nonlinear equations with three unknowns, when I scipy.optimize.fsolve I obtain an answer around 10^85 which is too large. A Runtime warning is thrown as well. import scipy.optimize as opt def func(variables): (A, B, C) =…
1
vote
1 answer

Divide and Conquer SVD in MATLAB

I'm trying to implement Divide and Conquer SVD of an upper bidiagonal matrix B, but my code is not working. The error is: "Unable to perform assignment because the size of the left side is 3-by-3 and the size of the right side is 2-by-2.…