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
31
votes
6 answers

What's the relative speed of floating point add vs. floating point multiply

A decade or two ago, it was worthwhile to write numerical code to avoid using multiplies and divides and use addition and subtraction instead. A good example is using forward differences to evaluate a polynomial curve instead of computing the…
J. Peterson
  • 1,996
  • 1
  • 24
  • 21
20
votes
5 answers

Why is Elixir slowest among Ruby and Go in solving Project Euler #5?

Update: Elixir isn't slow, my algorithm was. My algorithms weren't even apples to apples comparison. See Roman's answers below for Ruby and Go equivalent algorithms. Also thanks to José, my slow algorithm can be significantly sped up by just…
Abs
  • 2,234
  • 1
  • 19
  • 27
20
votes
2 answers

Fast complex number arithmetic in Clojure

I was implementing some basic complex number arithmetic in Clojure, and noticed that it was about 10 times slower than roughly equivalent Java code, even with type hints. Compare: (defn plus [[^double x1 ^double y1] [^double x2 ^double y2]] [(+…
OpenSauce
  • 8,533
  • 1
  • 24
  • 29
19
votes
1 answer

why does numpy matrix multiply computation time increase by an order of magnitude at 100x100?

When computing A @ a where A is a random N by N matrix and a is a vector with N random elements using numpy the computation time jumps by an order of magnitude at N=100. Is there any particular reason for this? As a comparison the same operation…
Linus
  • 400
  • 2
  • 9
15
votes
3 answers

Avoid Overflow when Calculating π by Evaluating a Series Using 16-bit Arithmetic?

I'm trying to write a program that calculates decimal digits of π to 1000 digits or more. To practice low-level programming for fun, the final program will be written in assembly, on a 8-bit CPU that has no multiplication or division, and only…
10
votes
2 answers

Solving non-square linear system with R

How to solve a non-square linear system with R : A X = B ? (in the case the system has no solution or infinitely many solutions) Example : A=matrix(c(0,1,-2,3,5,-3,1,-2,5,-2,-1,1),3,4,T) B=matrix(c(-17,28,11),3,1,T) A [,1] [,2] [,3] [,4] [1,] …
Basj
  • 41,386
  • 99
  • 383
  • 673
8
votes
2 answers

Best way to check if double equals negative infinity in C++

I found this: http://en.cppreference.com/w/cpp/numeric/math/isinf but it appears to check for either positive or negative infinity. I just want to check if a value is equal to exactly negative infinity, or in otherwords is log(0) Thanks for answer!…
evolvedmicrobe
  • 2,672
  • 2
  • 22
  • 30
7
votes
3 answers

What are the advantages of using Ruby NArray over Array?

I just came across the NArray library for Ruby -- please excuse my ignorance when asking this question :) What are the advantages of using the NArray library over the standard Ruby Array implementation? I've seen that NArray is geared towards…
Tilo
  • 33,354
  • 5
  • 79
  • 106
7
votes
4 answers

C++ Numerical truncation error

sorry if dumb but could not find an answer. #include using namespace std; int main() { double a(0); double b(0.001); cout << a - 0.0 << endl; for (;a<1.0;a+=b); cout << a - 1.0 << endl; for (;a<10.0;a+=b); cout << a - 10.0 << endl; cout…
Andrew
  • 2,309
  • 4
  • 27
  • 42
7
votes
3 answers

Python takes more time to print a calculation than to perform it

I wrote a script in python, and it surprised me. Basically, it takes five 20 digit numbers, multiplies them and then raises them to the power of 3000. The timeit module is used to find the time required to compute the calculation. Well, when I run…
Aayush Mahajan
  • 3,856
  • 6
  • 25
  • 32
7
votes
4 answers

How to do numerical simulation with immutable data in Clojure?

I'm using Clojure and I need to run a small simulation. I have a vector of length n (n is usually between 10 and 100) that holds values. On each simulation round (maybe 1000 rounds together), one of the values in the vector is updated randomly. I…
6
votes
1 answer

Can I use rounding to ensure determinism of atomic floating point operations?

I am developing a C application which needs floating-point determinism. I would also like the floating-point operations to be fairly fast. This includes standard transcendental functions not specified by IEEE754 like sine and logarithm. The…
6
votes
2 answers

Numeric function for log of sum in Python

Given log(a) and log(b), I want to compute log(a+b) (in a numerically stable way). I wrote a little function for this: def log_add(logA,logB): if logA == log(0): return logB if logA
user
  • 7,123
  • 7
  • 48
  • 90
6
votes
1 answer

Numpy dtype=int

In the below code .I get the expected results of x1 import numpy as np x1 = np.arange(0.5, 10.4, 0.8) print(x1) [ 0.5 1.3 2.1 2.9 3.7 4.5 5.3 6.1 6.9 7.7 8.5 9.3 10.1] But in the code below, when i set dtype=int why the result of x2 is…
6
votes
2 answers

Symbolic vs Numeric Math - Performance

Do symbolic math calculations (especially for solving nonlinear polynomial systems) cause huge performance (calculation speed) disadvantage compared to numeric calculations? Are there any benchmark/data about this? Found a related question: Symbolic…
1
2 3
9 10