numerical-computing

correctly-rounded double-precision division

拟墨画扇 提交于 2021-02-05 06:46:26
问题 I am using the following algorithm for double-precision division and trying to make it correctly rounded in software emulation of floating-point. Let a be the dividend and b is the divisor. All operations are performed in Q2.62. Initial approximation to the reciprocal is . b/2 is the significand of b with its implicit bit added, and shifted one right. For what follows, when written a or b it is meant by the significand of a or b with its implicit bit added. The is approximated with

How to find coefficients of polynomial equation?

烈酒焚心 提交于 2021-01-28 07:54:54
问题 Given two points in the x, y plane: x, f(x) 1, 3 2, 5 I can interpolate them using Lagrange and find f(1.5) , which result in 4 . Thinking a little I managed to find a way to discover the coefficients of the equation: void l1Coefficients(const vector<double> &x, const vector<double> &y) { double a0 = y[0]/(x[0]-x[1]); double a1 = y[1]/(x[1]-x[0]); double b0 = (-x[1]*y[0])/(x[0]-x[1]); double b1 = (-x[0]*y[1])/(x[1]-x[0]); double a = a0 + a1; double b = b0 + b1; cout << "P1(x) = " << a << "x +

Symbolic vs Numeric Math - Performance

六月ゝ 毕业季﹏ 提交于 2020-01-14 08:10:44
问题 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: https://scicomp.stackexchange.com/questions/21754/symbolic-computation-vs-numerical-computation Another one: Computational Efficiency of Forward Mode Automatic vs Numeric vs Symbolic Differentiation 回答1: I am the individual who answered the Scicomp

Symbolic vs Numeric Math - Performance

北城余情 提交于 2020-01-14 08:09:05
问题 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: https://scicomp.stackexchange.com/questions/21754/symbolic-computation-vs-numerical-computation Another one: Computational Efficiency of Forward Mode Automatic vs Numeric vs Symbolic Differentiation 回答1: I am the individual who answered the Scicomp

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

廉价感情. 提交于 2020-01-11 06:42:26
问题 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! Based on response below, here is some code that shows what works. #include <iostream> #include <cmath> #include <math.h> using namespace std; int main() { double c = std::log(0.0); auto result = c == - INFINITY; cout << result << endl; return 0; }

What are the advantages of using Ruby NArray over Array?

做~自己de王妃 提交于 2019-12-22 05:12:21
问题 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 numerical computing, but looking at the API, it looks like there are only a few extensions over Array geared towards numerical values -- nothing that you couldn't do with Array.. Why not just use Array? Is there a huge speed advantage? Is there a huge

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

时间秒杀一切 提交于 2019-12-13 12:25:33
问题 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 performs 16-bit additions. To ease the implementation, it's desirable to be able to use only 16-bit unsigned integer operations, and use an iterative algorithm. Speed is not a major concern. And fast multiplication and division is beyond the scope of

Given a number series, finding the Check Digit Algorithm…?

纵饮孤独 提交于 2019-12-11 03:35:40
问题 Suppose I have a series of index numbers that consists of a check digit. If I have a fair enough sample (Say 250 sample index numbers), do I have a way to extract the algorithm that has been used to generate the check digit? I think there should be a programmatic approach atleast to find a set of possible algorithms. UPDATE: The length of a index number is 8 Digits including the check digit. 回答1: No, not in the general case, since the number of possible algorithms is far more than what you

Quick and Hassle-free Installation & Usage of IT++ library on Linux/Windows?

懵懂的女人 提交于 2019-12-06 14:46:35
问题 IT++ is a popular GPL library (proposed to be LGPL but no signs as of now) for scientific computation especially in Telecommunications domain. This was recommended to me by my colleagues. It looks hard to install this piece of library on my Linux/Windows system. And the installation guide seems hard. I have a lot more to do other than spending time on this installation. Can anyone save me some time with a few quick installation and if possible, some hello, world! type instructions? 回答1: TL;DR

What are the advantages of using Ruby NArray over Array?

纵然是瞬间 提交于 2019-12-05 05:47:34
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 numerical computing, but looking at the API, it looks like there are only a few extensions over Array geared towards numerical values -- nothing that you couldn't do with Array.. Why not just use Array? Is there a huge speed advantage? Is there a huge memory advantage? Any other advantages over using the regular Ruby Array class? Google didn't really come