numerical-methods

How to Solve Linear programming problem using DotNumerics?

北城以北 提交于 2019-12-04 21:07:53
问题 I'm really interested in numerical analysis. I have been using DotNumerics Open Source Application. My linear system is the following: 1 * x + 3 * y <= 150 2 * x + 1 * y <= 100 where x >= 0, y >= 0 z = 10 * x + 15 * y I am trying to solve z (optimization...) I can use Simplex method to solve above problem as found in this link. I have also emailed the author, however he has not replied. using DotNumerics.Optimization; using DotNumerics; namespace App.SimplexCalcLinearProgramming { class

Computing a matrix which transforms a quadrangle to another quadrangle in 2D

谁说胖子不能爱 提交于 2019-12-04 08:59:17
In the figure below the goal is to compute the homography matrix H which transforms the points a1 a2 a3 a4 to their counterparts b1 b2 b3 b4. That is: [b1 b2 b3 b4] = H * [a1 a2 a3 a4] What way would you suggest to be the best way to calculate H(3x3). a1...b4 are points in 2D which are represented in homogeneous coordinate systems ( that is [a1_x a1_y 1]', ...). EDIT : For these types of problems we use SVD, So i would like to see how this can be simply done in Matlab. EDIT : Here is how I initially tried to solve it using svd (H=Q/P) in Maltlab. Cosider the following code for the given

Secant method solving for pipe diameter

試著忘記壹切 提交于 2019-12-04 06:24:31
问题 I am trying to write a program to solve for pipe diameter for a pump system I've designed. I've done this on paper and understand the mechanics of the equations. I would appreciate any guidance. EDIT: I have updated the code with some suggestions from users, still seeing quick divergence. The guesses in there are way too high. If I figure this out I will update it to working. MODULE Sec CONTAINS SUBROUTINE Secant(fx,xold,xnew,xolder) IMPLICIT NONE INTEGER,PARAMETER::DP=selected_real_kind(15)

Finding complex roots from set of non-linear equations in python

北城以北 提交于 2019-12-04 06:11:43
I have been testing an algorithm that has been published in literature that involves solving a set of 'm' non-linear equations in both Matlab and Python. The set of non-linear equations involves input variables that contain complex numbers, and therefore the resulting solutions should also be complex. As of now, I have been able to get pretty good results in Matlab by using the following lines of code: lambdas0 = ones(1,m)*1e-5; options = optimset('Algorithm','levenberg-marquardt',... 'MaxFunEvals',1000000,'MaxIter',10000,'TolX',1e-20,... 'TolFun',1e-20); Eq = @(lambda)maxentfun(lambda,m,h,g);

Trying to simulate a 1-dimensional wave

自作多情 提交于 2019-12-04 05:48:39
I'm trying to make a simplified simulation of a 1-dimensional wave with a chain of harmonic oscillators. The differential equation for the position x[i] of the i-th oscillator (assuming equilibrium at x[i]=0 ) turns out to be - according to textbooks - this one: m*x[i]''=-k(2*x[i]-x[i-1]-x[i+1]) (the derivative is wrt the time) so i tried to numerically compute the dynamics with the following algorithm. Here osc[i] is the i-th oscillator as an object with attributes loc (absolute location), vel (velocity), acc (acceleration) and bloc (equilibrium location), dt is the time increment: for every

Is numpy.sum implemented in such a way that numerical errors are avoided?

こ雲淡風輕ζ 提交于 2019-12-04 05:06:19
It is well known that adding up numbers can result in numerical errors (for example, if the first number is really large, whereas there are many other small numbers). This can be solved adding up the numbers in a non straight-forward way. See for example: https://en.wikipedia.org/wiki/Kahan_summation_algorithm Is numpy.sum implemented in such a way that numerical errors are avoided? hpaulj Searching on numpy kahan turned up a closed bug/issue https://github.com/numpy/numpy/issues/2448 Numerical-stable sum (similar to math.fsum) I haven't read it in detail. Note the reference to math.fsum fsum

How to get binary representation of floating-point number in PHP?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 03:08:36
问题 Is there any way to get the binary representation of a floating point number in PHP? Something like Java's Double.doubleToRawLongBits(). Given a positive floating point number, I'd like to get the largest representable floating-point number which is less than that number. In Java, I can do it like this: double x = Double.longBitsToDouble(Double.doubleToRawLongBits(d) - 1); But I'm not seeing anything similar in PHP. 回答1: This isn't a full answer, but the only way I know of to put a float into

Using odeint function definition

限于喜欢 提交于 2019-12-04 01:44:50
问题 Pretty noob question so please bear with me. I am following the example given here--> http://www.codeproject.com/Articles/268589/odeint-v2-Solving-ordinary-differential-equations In particular, I am looking at this function: void lorenz( state_type &x , state_type &dxdt , double t ) { dxdt[0] = sigma * ( x[1] - x[0] ); dxdt[1] = R * x[0] - x[1] - x[0] * x[2]; dxdt[2] = x[0]*x[1] - b * x[2]; } In my case, R takes on a series of values (vector with 100 doubles). odeint is called as: integrate

efficiently determining if a polynomial has a root in the interval [0,T]

有些话、适合烂在心里 提交于 2019-12-04 00:21:55
I have polynomials of nontrivial degree (4+) and need to robustly and efficiently determine whether or not they have a root in the interval [0,T]. The precise location or number of roots don't concern me, I just need to know if there is at least one. Right now I'm using interval arithmetic as a quick check to see if I can prove that no roots can exist. If I can't, I'm using Jenkins-Traub to solve for all of the polynomial roots. This is obviously inefficient since it's checking for all real roots and finding their exact positions, information I don't end up needing. Is there a standard

C++ Bessel function for complex numbers

无人久伴 提交于 2019-12-03 22:09:20
I want to implement the Bessel functions of first and second kind Description 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. 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 (see documentation about Bessel functions ). Don't try to reinvent the wheel , just use the Boost