numerical-methods

Bounding this program to determine the sum of reciprocal integers not containing zero

。_饼干妹妹 提交于 2019-12-06 01:07:43
问题 Let A denote the set of positive integers whose decimal representation does not contain the digit 0. The sum of the reciprocals of the elements in A is known to be 23.10345. Ex. 1,2,3,4,5,6,7,8,9,11-19,21-29,31-39,41-49,51-59,61-69,71-79,81-89,91-99,111-119, ... Then take the reciprocal of each number, and sum the total. How can this be verified numerically? Write a computer program to verify this number. Here is what I have written so far, I need help bounding this problem as this currently

Multiprocessing with Screen and Bash

≯℡__Kan透↙ 提交于 2019-12-05 15:00:58
Running a python script on different nodes at school using SSH. Each node has 8 cores. I use GNU Screen to be able to detach from a single process. Is it more desirable to: Run several different sessions of screen. Run a single screen process and use & in a bash terminal. Are they equivalent? I am not sure if my experiments are poorly coded and taking an inordinate amount of time (very possible) OR my choice to use 1. is slowing the process down considerably. Thank you! With bash I imagine you're doing something like this (assuming /home is under network mount): #!/bin/bash for i in {1..$NUM

Using boost geometry to check if two lines have an intersection

不想你离开。 提交于 2019-12-05 11:13:32
Is it possible to use boost::geometry to check whether two line segments (each given by two points in 2D) intersect each other? If this is possible, does boost::geometry allow to check also for special cases such as that only one point is (numerically) on the other line, or that both lines are equal? If you are talking specifically about Boost.Geometry API to it is, of course, possible. Your code should look roughly like this #include <boost/geometry/geometries/segment.hpp> #include <boost/geometry/algorithms/intersection.hpp> typedef boost::geometry::model::segment<Point> Segment; Segment AB(

Algorithm of boost::math::erf

别来无恙 提交于 2019-12-05 09:30:21
are there any details available for the algorithm behind the erf-function of boost? The documentation of the module is not very precise. All I found out is that several methods are mixed. For me it looks like variations of Abramowitz and Stegun. Which methods are mixed? How are the methods mixed? What is the complexity of the erf-function (constant time)? Sebastian The docs for Boost Math Toolkit has a long list of references , among which Abramowitz and Stegun. The erf-function interface contains a policy template parameter that can be used to control the numerical precision (and hence its

Problem with arithmetic using logarithms to avoid numerical underflow (take 2)

不羁的心 提交于 2019-12-05 05:59:33
I have two lists of fractions; say A = [ 1/212, 5/212, 3/212, ... ] and B = [ 4/143, 7/143, 2/143, ... ] . If we define A' = a[0] * a[1] * a[2] * ... and B' = b[0] * b[1] * b[2] * ... I want to calculate a normalised value of A' and B' ie specifically the values of A' / (A'+B') and B' / (A'+B') My trouble is A are B are both quite long and each value is small so calculating the product causes numerical underflow very quickly... I understand turning the product into a sum through logarithms can help me determine which of A' or B' is greater ie max( log(a[0])+log(a[1])+..., log(b[0])+log(b[1])+.

Python Numerical Integration for Volume of Region

好久不见. 提交于 2019-12-05 05:10:48
For a program, I need an algorithm to very quickly compute the volume of a solid. This shape is specified by a function that, given a point P(x,y,z), returns 1 if P is a point of the solid and 0 if P is not a point of the solid. I have tried using numpy using the following test: import numpy from scipy.integrate import * def integrand(x,y,z): if x**2. + y**2. + z**2. <=1.: return 1. else: return 0. g=lambda x: -2. f=lambda x: 2. q=lambda x,y: -2. r=lambda x,y: 2. I=tplquad(integrand,-2.,2.,g,f,q,r) print I but it fails giving me the following errors: Warning (from warnings module): File "C:

C++ Bessel function for complex numbers

喜夏-厌秋 提交于 2019-12-05 05:02:27
问题 I want to implement the Bessel functions of first and second kindDescription of bessel functions for complex numbers in C++. Now I am looking for possibilities to introduce them in my source code. Since math.h only contains bessel functions for real numbers, I would be interested in seeing any kind of possibility. 回答1: The Boost library implements ordinary Bessel functions of the first and second kind and modified Bessel functions of the first and second kind for both real and complex numbers

What algorithms do FPUs use to compute transcendental functions?

半腔热情 提交于 2019-12-05 04:19:25
What methods would a modern FPU use to compute transcendental functions ? For example, Intel CPUs provide instructions such as FSIN , FCOS , FYL2X , etc. I am curious as to what algorithms would be used to actually implement these in hardware. My naïve guess would be Taylor series perhaps combined with some lookup tables, but that's nothing more than a wild guess. Please enlighten me. P.S. This question is more general than just Intel hardware. One place to start could be " New Algorithms for Improved Transcendental Functions on IA-64 " by Shane Story and Ping Tak Peter Tang, both from Intel.

Python - Implementing a numerical equation solver (Newton-Raphson)

戏子无情 提交于 2019-12-05 02:30:54
问题 I am warning you, this could be confusing, and the code i have written is more of a mindmap than finished code.. I am trying to implement the Newton-Raphson method to solve equations. What I can't figure out is how to write this equation in Python, to calculate the next approximation (xn+1) from the last approximation (xn). I have to use a loop, to get closer and closer to the real answer, and the loop should terminate when the change between approximations is less than the variable h. How do

Vertical line fit using polyfit

半城伤御伤魂 提交于 2019-12-05 01:58:01
Its just a basic question. I am fitting lines to scatter points using polyfit . I have some cases where my scatter points have same X values and polyfit cant fit a line to it. There has to be something that can handle this situation. After all, its just a line fit. I can try swapping X and Y and then fir a line. Any easier method because I have lots of sets of scatter points and want a general method to check lines. Main goal is to find good-fit lines and drop non-linear features. Andrey Rubshtein First of all, this happens due to the method of fitting that you are using. When doing polyfit ,