Questions tagged [numerical-methods]
Algorithms which solve mathematical problems by means of numerical approximation (as opposed to symbolic computation).
1,916
questions
0
votes
1
answer
38
views
Generate Positive Definite Matrix in Julia?
In Julia, is there any function or way to generate a positive definite matrix of arbitrary size/dimensions? I know the package PSDMatrices can technically do this, but it returns an object that is not ...
0
votes
0
answers
17
views
Bisection method for two-variable functions
I am looking for some source that could teach me how bisection method algorithm work in two-variable functions. I found some videos on youtube that didn't really help me understand clear.
I would ...
2
votes
1
answer
51
views
Create random matrix with orthonormal columns?
In Julia, is there any function or way to generate a random matrix with orthonormal columns of arbitrary dimensions (not necessarily square, could be rectangular/tall matrix)?
1
vote
1
answer
74
views
Why does my solution for the quantum harmonic oscillator blow up?
I am using odeint to solve for the energy levels of the QHO (Griffiths problem 2.55).
I am integrating from x=0 to x=3. When I plot the results, I expect to see half of a gaussian with a tail that ...
-4
votes
0
answers
44
views
Create dynamic variables and use them in function in python without repeating [closed]
Suppose I want to create variables which are type of lists with fixed size. And I want to repeat the same task for 5 times. Let's say C, K and H are lists/arrays with size 400 and I want to create ...
0
votes
1
answer
45
views
Rank r matrix approximation via SVD in Julia?
Suppose we have computed the svd of a matrix A in Julia via svd(A). How would we compute a rank r approximation of that matrix A in Julia, given we already have its singular value decomposition?
2
votes
2
answers
35
views
Is there a method to check for convergence when using newon's method?
I have a function that I want to solve using newton's method. The problem is that the convergence depends on the initial guess.
I want to write an if statement. If the function converges then to store ...
-2
votes
0
answers
13
views
Enquiry about the formula derivation below [closed]
I'm having some confusion about the below derivation especially the step 1. Omitting irrelevant variables, the paper suppose the $L_y$ Lipschitz continuous of $l(y)$, which should give us:
$|l(y_i^) - ...
-2
votes
1
answer
65
views
Intersection of two matrices in Julia?
Is there any function or method in Julia that would allow one to compute the intersection of two matrices A and B?
0
votes
1
answer
27
views
Gaussian Matrix?
Does a "Gaussian Matrix" refer to a matrix that has undergone gaussian elimination to become an upper triangular matrix (the U in lu factorization), or instead to the elimination matrix that ...
1
vote
3
answers
113
views
How to distinguish odd and even for big numbers more efficiently?
Please let me know by comments if there are already some similar questions.
When we usually try to distinguish odd and even numbers we can try the following code,
in C++.
int main() {
int ...
0
votes
1
answer
36
views
Finding the roots of a system of non-linear equations that has multiple roots with python fsolve
I have the following system of non-linear equations which I want to find its roots:
x - exp(a x + b y) = 0
y - exp(c x + d y) = 0
The code I'm using to find its roots is:
equations = lambda x, ...
-1
votes
0
answers
59
views
Python float to numpy array gives numerical error
If I do the following computation, I get a non-zero number:
> import numpy as np
> np.array([(1.2/0.1)**2]) - (np.array([1.2])/0.1)**2
-2.842171e-14
Where does this error come from? Why does ...
0
votes
1
answer
31
views
How can I improve the lindep function's applicability in Pari/GP for integral approximations?
While doing certain computations involving the Rogers L-function, the following result was generated by Wolfram Alpha:
I wanted to verify this result in Pari/GP by ...
0
votes
1
answer
28
views
Basis Functions in Polynomial regression?
Given a set of data points (x1,y1),...(xn,yn), suppose we wish to approximate these data points with a polynomial function. However, what would be the highest degree of the polynomial that we could ...
2
votes
2
answers
66
views
Round to next largest integer in Julia?
If I have some number in Julia like 1.1, is there any function/way to round this Float64 to the next largest integer? For example, what function/method could round 1.1 to 2?
0
votes
0
answers
41
views
Error in implementation of Crank-Nicolson method applied to 1D TDSE?
This is more of a computational physics problem, and I've asked it on physics stack exchange, but no answers on there. This is, I suppose, a mix of the disciplines on here and there (and maybe even ...
0
votes
1
answer
58
views
How I use numerical methods to calculate roots in R
A machine learning model predicted probability p using input x. It is unknown how model calculates the probability.
In the example below,
We have 100 xand p values.
Can someone please show an ...
0
votes
1
answer
45
views
Pivoted QR in Julia?
In Julia, the function qr(A) will perform a QR decomposition on a given matrix A. However, is there any function/way in Julia to do a "pivoted" QR decomposition on a given matrix?
-1
votes
0
answers
64
views
How I use numerical methods to calculate roots in R
Edit - The question was modified and asked again. Here is the link -
How I use numerical methods to calculate roots in R
Some machine learning model was used to predict probability p using input x.
...
0
votes
0
answers
27
views
SIRK schemes and Lokta-Volterra test
I'm aiming at making a 2D compressible Euler equations numerical model, and to do so I need to implement a so-called "semi-implicit fourth order runge-kutta scheme" in order to integrate an ...
0
votes
0
answers
24
views
Convergence rate adaptive Runge Kutta methods
I have a system of ODEs and I solve them with two different algorithms:
A normal, constant stepsize, Runge Kutta 4 implementation
A modified Runge Kutta 4, with variable stepsize control
My ...
0
votes
1
answer
49
views
Octave eigs() function bugged?
Running Octave 6.3.0 for Windows. I need to get the smallest eigenvalue of some matrix.eigs(A,1,"sm") is supposed to do that, but I often get wrong results with singular matrices.
eigs(A) (...
1
vote
0
answers
54
views
How to do a bisection search in python (MIT 6.0001)
I have tried to function for part c of the MIT 6.0001 PSET 1, but this function always prints zero for the saving rate. What is wrong with the function I have written such that it always prints zero? ...
0
votes
0
answers
22
views
How would I change my df.append to concat, pandas keeps on saying that df.append is deprecated and is not printing my database?
I am trying to create a database in pandas where I would have 2 functions, there composition as well as the hill coefficient of all three values. Additionally I have two other rows that find the ...
2
votes
1
answer
61
views
QR Factorization of Rank Deficient Matrix in Julia?
If (in Julia) we compute the QR factorization of a rank deficient matrix like A=[1 2 3;4 5 6;7 8 9], some of the diagonal entries of the R matrix will be very small. However, when doing this ...
3
votes
1
answer
68
views
Convert a vector of positive/negative elements to all positive elements in Julia?
Given a one dimensional vector in Julia with positive and negative entries, like A=[1;-3;5;-7], is there any function or command that can alter this vector so that its elements all become positive, so ...
0
votes
1
answer
31
views
Keep getting a only size-1 arrays can be converted to Python scalars
Ive looked multiple times on google as well as on this website as well and I am still unable to solve my problem.
I have taken feedback from a previous question and decided to use a numerical ...
3
votes
2
answers
93
views
How to extract an array of diagonal entries from a diagonal matrix in Julia?
Given some diagonal matrix in Julia like A = Diagonal(rand(3,3)), is there any way I can create a one-dimensional array whose elements are the diagonal entries of this Diagonal matrix A?
2
votes
1
answer
67
views
How to print/show an matrix in matrix format?
I would like to print an 2d array or matrix like A=[1 1;2 2;3 3] in matrix format, but when I do println(A), it prints in the format [1 1;2 2;3 3]. Is there any function or macro like @show that can ...
1
vote
1
answer
51
views
Orbit of the Earth - numerical methods leapfrog
edit:
I get these plots now from earths orbit. However, total energy looks not right. Should it not be oscillating between 0?
Thanks again!
I am attempting this numerical methods homework exercise ...
0
votes
1
answer
45
views
Orbit of the Earth - leapfrog Python
I am trying to do this homework exercise:
Orbit of the Earth
My plot does not show the whole trajectory. I don't know if it is something wrong with my equations or if it is a plotting matter.
Cheers!
...
0
votes
2
answers
61
views
Why is 1e100 not exactly representable as 64 bit float?
I have been told that 1e100 is not exactly representable as a 64 bit floating point number. With a 64 bit floating point number, we can have 16 significant digits in the significand, and manipulate ...
0
votes
1
answer
31
views
How to plot a graph for a function having a singularity point
I am trying to plot a solution curve (u~v) for the following first-order differential equation:
(u/v)(dv/du) = (1-u)/(u+v-3)
which has boundary condition as:
v=0 at u=3
and
dv/du= -5/3 at (3,0)
I am ...
0
votes
1
answer
79
views
Numerical double integrals using Gauss–Legendre Quadrature in python
I'm trying to solve double integrals through Gauss–Legendre Quadrature numeric method in python without using any library that has numeric methods. But i can't make the algorithm work when I have ...
1
vote
1
answer
63
views
How to get thin QR decomposition in Julia?
When I perform QR decomposition on a 3x2 matrix A in Julia, it gives a 3x3 matrix Q. Is there any way I can get a "thin" version of this QR, where it returns a Q that is 3x2 (same dimensions ...
0
votes
3
answers
61
views
How to generate random matrix of arbitrary rank in Julia?
Is there any way in Julia to generate a random matrix that has some arbitrary/specified rank? For example, is there any function that would allow generating a random 3x3 matrix of rank 2?
1
vote
1
answer
71
views
How to generate symmetric matrices in Julia?
Functions like rand(m,n) generate a random matrix of m rows and n columns. Is there any function in Julia that can generate a Symmetric matrix of arbitrary dimensions?
0
votes
1
answer
53
views
Find unknown parameters of the function, if f(x) and x are given
I need some help.
I have an equation:
f(x) = acos(x) + (bsqrt(x) + ctg(x))^2,
where a, b, c are unknown parameters.
Also I have a few pairs of x -> f(x) like in Supervised ML problem.
How can I ...
-1
votes
1
answer
39
views
Applying runge kutta for coupled equations
so I have 2 second order nonlinear ODE and after applying the state-space theorm I have 4 first order ODE.
I'm trying to apply RK4 but I think I'm doing it wrong because the graphs diverge.
I'm ...
0
votes
0
answers
61
views
Reduce error and finding convergence with numerical integration in R
I am trying to carry out a 1D numerical integration of the probability2DBox_free_t function here below:
prob1Dbox<-function(invL, t, invtau, x0, x, n_lim) {
c = pi * (pi/4) * (t * invtau)
...
2
votes
1
answer
73
views
Why does Clang add extra FMA instructions?
#include <immintrin.h>
__m256 mult(__m256 num) {
return 278*num/(num+1400);
}
.LCPI0_0:
.long 0x438b0000 # float 278
.LCPI0_1:
.long 0x44af0000 ...
0
votes
0
answers
23
views
How to manage multiple simulations that continually create large datasets
my work is related to mathematical modelling and running computer simulations in fluid mechanics. I have a mathematical model that has, say, has 5 parameters. Each of them have some range defined by ...
0
votes
0
answers
30
views
Python: Solve BVP with boundary conditions inside domain, not just on edges
I am trying to solve a boundary value problem (in python) with multiple boundary conditions throughout the domain.
In MATLAB I have found the following tutorial on how to do this, but as far as I can ...
0
votes
1
answer
58
views
Overflow when working with exponentials (Fortran)
I'm having problems regarding the calculation of some exponentials. The problem is, i have a sum of exponentials that each one gives me overflow, so i didn't found a way to use logarithm to free ...
0
votes
0
answers
13
views
Numerical accuracy of 5 stenciles vs 9 stencils domain decomposition compared to single domain
I was wondering if there are any numerical accuracy sacrifice when it comes to the domain decomposition schemes between 5 stencils (using the boundary information of north, south, west and east ...
1
vote
0
answers
24
views
Are the matrix operations in R programming optimized for the matrices of specific shapes (e.g. banded matrices)? [closed]
Theoretically, certain matrix operations (e.g., multiplication, inverse, eigendecomposition) are more efficient when they are applied to some special matrices (e.g. banded matrix). Hence, I wonder ...
2
votes
0
answers
53
views
Diagonal Matrix of Sigma Values in Julia
If I compute the SVD of a matrix A in Julia, it will give the sigma values of the matrix, BUT NOT in matrix form. However, if I want to assemble the sigma values of a matrix A into a diagonal matrix, ...
1
vote
0
answers
90
views
Algorithm for Gram Schmidt in Julia
How would one write a function that performs gram-schmidt orthogonalization on the columns of some matrix A? I am not sure how to write an algorithm or function in the Julia language that performs ...
1
vote
3
answers
102
views
What is the meaning of unsigned u = *(unsigned*)&x; in c++ where x is a float variable? [duplicate]
Since my Numerical Analysis course exam is near, I was searching for a implementation code to to represent floating point numbers in C/C++? Then I found a line from one the codes in github. Can you ...