instruction
stringlengths
43
28.1k
I got an assignment where it asked to implement (in MATLAB) the gradient descent algorithm in order to resolve an ill posed least square problem: $$ \min_u \Vert Gu - f \Vert $$ where $u$ is the reconstructed image, $G$ is the blur applied to $u$ and $f$ is the blurred image. I have successfully implemented it with MAT...
I'm solving two-dimensional four-component compressible Navier-Stokes equations with finite-difference WENO approach. The equations are pretty standard: $$ \frac{\partial U}{\partial t} + \frac{\partial F}{\partial x} + \frac{\partial G}{\partial y} = 0; $$ $$ U = \left( \begin{array} {c} \rho \\ \rho u \\ \rho v \\ E...
I'm doing CFD simulations for blood flow in unstructured grids. My boundary condition at the outlets is called three-element Windkessel which basically calculates the pressure by solving this ODE: $$R_{2}C\frac{dP}{dt} + P(t) = C R_{1}R_{2}\frac{dQ}{dt} + (R_{1}+R_{2})Q(t)$$ Where $P(t)$ is the pressure at the outlet, ...
I am writing a simulation for a discrete stochastic dynamical system. Since the simulation is stochastic, I need to run the simulation multiple times and then average the values of each timestep. I have some simple julia code below to demonstrate the process. My question was really about numerical stability when averag...
I have a set of points $(x_i,y_i,u(x_i,y_i))\in\mathbb{R}^3$, $i=1,\dots N$, over a surface $S$ (from experimental data). I need to calculate the integral of a function $F$ over that surface. If the points were points over a volume I could use some mesh software (tetgen, for example) and build a mesh, and after that ca...
I'm trying to solve Unsteady Stokes equations on a moving domain, using an ALE formulation, that is $$\frac{\partial \mathbf{u}}{\partial t} - \mathbf{w}\cdot \nabla\mathbf{u} = \nu\Delta\mathbf{u} - \nabla p$$ where $\mathbf{w}$ is the velocity of the mesh. I'm starting from the simple case of a rigid sphere translati...
Language: Python3 Problem: I have a matrix Q of shape [51200 rows x 51200 cols] stored in a binary file, each of the element in this matrix has a data type of complex64. To load the data into memory I therefore need ~20GB of RAM, checked from getsizeof(Q). I do have access to a server with 120GB of RAM in a LINUX machi...
I have a linear system $$ \dot x(t) = Ax(t), \quad x(0)=x_0 \tag{*} $$ with $A$ being Hurwitz (i.e. the solutions may oscillate but will eventually tend to zero) but really stiff. $A$ might be large, but I can do explicit solves. I want to integrate it in time. Since it is coupled with a flow solver, stability is my pr...
Is there any book or site available with Finite element Method for partial differential equations with python code apart from Fenics?
I'm currently looking at the PDE \begin{align*} u_t + \left[x(1-y) - (1-x)\right]u_x - (1-y) u_y + (z-xy) u_z = (z-xy) u_{xy} - (1-x)u& \\ \end{align*} with \begin{align*} u(x,y,z,0) = 1& \\ (x,y,z) \in [0,1]\times [0,1] \times [0,1]&, \end{align*} which I found via the conversion of a chemical master equation. The s...
I'm trying to simulate the motion of a projectile taking into account aerodynamic drag. The code works perfectly if the aerodynamic drag is zero. However, if the drag coefficient or velocity is too high, the trajectory starts to bend towards the negative x axis. I used this source to help me create the simulation. Here...
Suppose I have a linear inverse problem of the form: \begin{align} Ax=b \end{align} I would like to reconstruct $x$ from the measurement $b$ via the objective $$\min_x\{\vert\vert Ax-b\vert\vert^2_2+\lambda\mathcal{R}(x)\}$$ With $\mathcal{R}(x)$ being the regularizer and $\lambda$ being the regularization parameter. I...
Please let me know if this is not the appropriate site for this question. I found questions regarding EFIE/MFIE/CFIE on this site, so I thought my question might fit. I am studying the paper by Putnam & Medgyesi on the CFIE method for BoR targets with junctions. In Section V (second paragraph) of the paper, the authors...
I am struggling with a rather basic numerical integration task: Using Python's scipy.integrate.solve_ivp module to integrate an ODE sytem backwards in time. As a test, I am using the following ODE system (an SEIR model for an infectious disease): \begin{align*} \frac{dS}{dt} &= - \beta SI \\[4pt] \frac{dE}{dt} &= \beta...
Does anyone know of any strategies for creating a preconditioner $P^{-1}_\sigma \approx (A+\sigma I)^{-1}$ given a preconditioner $P^{-1} \approx A^{-1}$, preferably such that the precomputation doesn't depend on the value of $\sigma$?
I have a simple graph $G=(V,E)$ that is not necessarily a complete graph. If I compute the shortest distance between every pair of vertices (let say with Floyd-Warshall algorithm) I get a complete graph $G_c=(V,E_c)$. Considering that the distance between two vertices in a simple graph is the number of edges in its sho...
It is required to solve a linear system $Ax=b$, where the matrix $A$ is symmetric, all the variables and coefficients are real. The structure of $A$ is \begin{equation} A = \begin{pmatrix} A_{11} & A_{12} \\ A_{12}^T & A_{22} \end{pmatrix}, \end{equation} where $A_{11}$, $A_{12}$ and $A_{22}$ are banded square blocks o...
I am looking for references, pointers to CUDA code that runs particle simulation in parallel, calculating particle trajectories, handling collisions, etc. I've seen some in NVidia source base, but was curious if any parallel code experts know more. Thanks,
I have a mesh of a 3D surface composed by triangles, and I have the value of a function $u(x,y,z)$ in every vertex of the mesh (every vertex of each triangle). I need to calculate the following integral: $\iint_S u_{xx}dA$ Normally, I calculate this integral as a sum over each triangle supposing that $u$ is linear on e...
I want to compare the field of two electrical currents and compare the resulting field to a magnetic dipol field and find magnetic momentum that minimizes the difference of the two fields. My current approach is to calculate the field of the two currents (by superimposing the fields of the two individual currents) and ...
I need to (computationally) solve a system of equations, for the purposes of an interior point method, of the form $$ \left[\begin{array}{cc}B & A^T \\ A & 0\end{array}\right] \left[\begin{array}{c}x\\y\end{array}\right] = \left[\begin{array}{c}c_x \\ c_y\end{array}\right] $$ where $A$ and $B$ are large and sparse, and...
So currently I am studying about the Runge Kutta Second Order Method used to estimate first order ordinary differential equations. The following show the formulas. $$ y_{i+1} = y_i + (a_1k_1+a_2k_2)h $$ $$ k_1 = f(x_i,y_i) $$ $$ k_2 = f(x_i + p,y_i + q_{11}k_1h) $$ $$ a_1 + a_2 = 1 $$ $$ a_2p_1 = \frac{1}{2} $$ $$ a_2q...
I was wondering if anyone could recommend a good book or resource on numerical methods for solving integro-differential equations? Of course I am familiar with the methods for solving ODEs and PDEs numerically, so no problem there. But I don't have any frame of reference on the stability of numerical schemes when solvi...
I have a mesh already partitioned into disjoint groups of cells. What I want to achieve is the following. Obtain the adjacency graph for the cell groups. Partition the mesh, i.e. generate submeshes from the cell groups in such a way that cells among the interfaces (boundaries of the cell groups) are no longer connecte...
I have a C++ code performing some Armadillo computations in a loop. I'd like to parallelize this loop with OpenMP. But Armadillo automatically uses OpenMP for some computations. So, would the OpenMP parallelized loop cause an issue if I don't disable the automatic Armadillo parallelization ? Or can I safely use the par...
If I wanted to perform an optimization using a Newton-based solver where the Hessian and gradient of a function are known analytically, and then use a package such as Adept to compute a Jacobian matrix ("reverse mode") with respect to the optimization parameters, would that be possible? Would there be excessive memory...
By using the Legendre-Gauss-Lobatto (LGL) quadrature formula (QF) and LGL nodal points one achives a diagonal mass-matrix for finite element problems. (More specifically, the spectral element method.) Setting the $n$ quadrature points as nodal points, the polynomials of the ansatz and test space are of degree $n-1$. Th...
I'm trying to implement a C++ code for the evaluation of the solution of an N-body system of ODE. I've started with a 2-body problem just to set the methods properly. I'm comparing the results of a 4 stages Runge-Kutta (RK4), a 4 steps Adams-Bashforth (AB4) and velocity Verlet method. The solutions I get have the corre...
I have a curve fitting problem of the form: $$ \textbf{y} = f(\textbf{x}, a,b,c,d) + \varepsilon $$ $$ f(x, a,b,c,d) = \frac{b}{e^{x\cdot a}+c}+d $$ with the constraint \begin{equation} \begin{aligned} \arg\min_{a,b,c,d} \quad & \sum_{i=1}^{n}{(f(\text{x})_i-\text{y}_i)^2}\\ \textrm{s.t.} \quad & -c-\frac{b}{d}-1 =...
I am trying to solve 6 ODE equations coupled with 1 DAE one. The ODE equations have been discritized in space domain and ode15s MATLAB solver is used to solve the equations in time domain. I have defined a diagonal mass matrix including unity elements for ODEs and zero values for DAE equation. Assuming that "n" is the ...
I'm trying to solve a system of ODEs using the BDF order 4 method. I find the first 3 points using RK4, then for the implicit part of the BDF, I use Newton-Raphson iteration. Unfortunately my solution blows up but I can't figure what I'm doing wrong. I assume it's something to do with the Newton iteration since I'm not...
I am interested in numerical solutions of a linear, time-dependent ODE of the form $$ \dot y = A(t)y - Ry, $$ A good model is the following problem in $\mathbb R^2$: $$ A(t) = \begin{bmatrix}0 & -\omega(t)\\ \omega(t) & 0\end{bmatrix} \\ R = \begin{bmatrix}R_1 & 0\\ 0 & R_2\end{bmatrix}, \\ $$ The full problem is in $\...
I need to simulate a 3D fluid-structure problem where the obstacle is an elastic and very thin structure (then I want to consider this structure as a surface). I need to solve this problem using numerical methods, like finite volume or finite element method. But if I try to generate a mesh of the obstacle, it has too t...
I have a kind of general question about approximation schemes in nonlinear functional analysis. Given a nonlinear map $\Phi$ from an open set (in an infinite dimensional Banach space) of functions to itself, I try to find fixed points of this map $\Phi(f)=f$, or equivalently to solve the roots of of $\Phi'=\Phi-{\bf 1}...
I don't have a background in numerical modeling so this question is rather broad. What I am interested in is modeling the propagation of an ultrasonic acoustic wave in 3d space. The basic 3d wave equation is tractable to me but I don't understand how boundary interaction is computed or how to get accurate simulations o...
To simulate the physical process necessary to solve the arising systems of linear algebraic equations. The SLE matrix has a highly sparse form. There are a couple dozen non-zero elements in the string, including the diagonal. And all unknown a couple of million. During the simulation, the matrix retains its portrait, b...
I'm looking for an open-source automatic meshing tool or library able to generate full or dominant hexahedral mesh starting from a provided arbitrary model i.e. a surface triangular mesh stored in STL file. What I have found is snappyHexMesh embedded in OpenFOAM. Are there some other tools that fit my purpose? Someone ...
I'm quite new to GPU or in general parallel programming. I am working on a Lattice-Boltzmann simulation that should be parallelized on GPU's. I wanted to asked more experienced people how to attack such a project. Would it be more beneficial to first implement all necessary features (basic algorithm with some extension...
I'm numerically modelling flows around various geometric 2D shapes. Is there a good source/cookbook of equations that approximate these? Some examples are Rectangle: $(x-a)^n+(y-b)^n < r^n$ where $r$ is side length and $n$ is even. The larger $n$, the sharper the corners. Also e.g. $\text{max}(500 (x-a), 55 (y-b)) < ...
I need to implement a numerical scheme for the solution of the one-dimensional advection equation $$\\\frac{\partial u}{\partial t} + C(x, t) \frac{\partial u}{\partial x} = 0 \\\\$$ $$ \\ C(x,t) = \frac{\pi\cos(2 \pi t) + 3.5}{2\pi - \pi\sin(\pi x)} \\\\$$ $$\\ 0 \leq x \leq 1, \quad 0 \leq t \leq 1\\\\$$ with Crank–N...
I work on computational geometry. A huge number of two-dimensional and three-dimensional data are found in my project. Coordinates of polygon and polyhedrons vertices consisted of two-dimensional and three-dimensional data, respectively. Indeed, polyhedrons face data are also founded. Storing and retrieving them is nes...
Imagine we have a simple 2D FEM solver (we are dealing with solid mechanics) and we would like to develop it to a 3D FEM solver (let's say for the same solid mechanics problem) in this case what are the inevitable changes/modifications to be made in the code? I understand that some might answer "It depends on the type ...
I was messing around with some numerical integration functions. I wrote an arbitrary differential equation to test my understanding, the code is as follows: import numpy as np from scipy.integrate import odeint intT = np.array([0,1,2,3,4,6,8,10,13,16,19,20,21,22,27,40,80]) def dydt(y,t): dydt = np.random.choice(...
I know that, in general, finite volume (FV) methods are more (numerically) diffusive than spectral methods. However, I can't find any information on how the advection scheme changes that. For example, WENO schemes are supposed to decrease numerical diffusion and presumably would get numerical diffusion of FV methods cl...
Let us suppose that I have a full cycle LCG, following the standard equation Hence, as it has a full cycle, it will have a period of m, and will output values ranging from 0 to m. However, I want to limit the output values to somewhere between 0 to some arbitrary constant a, where a is less than m. All the while main...
I need to generate an image with 11x11 pixels having in the center of the image a square of 5x5 pixels, with the gray level of the background 0 and the gray level of the square is 50. I need to compute the gradient of the image given by the compass operator, taking into account that the image is not noisy(simple deriva...
Inspired by this answer, I tried to understand when floating point errors come into visibility and to check it also comparing the plot of the numerical solution with Explicit Euler with the analytical one for this simple problem. \begin{cases} y'(x)= L \sin(x) \\ y(0)= 0 \end{cases} where $L$ is a number. The Solution ...
I want to solve the following Cauchy problem \begin{equation} y' = y^2 + \frac{t^4 - 6t^3 + 12t^2 - 14t + 9}{(1+t)^2} \end{equation} with initial condition: $y(0) = 2$ for $t \in [0,1.6]$ using a 3 steps Adam-Moulton method implemented in Matlab as follows: function [t,u] = AM3(fun,t0,T,y0,N) h = (T-t0)/N; % integrat...
I am modelling a problem that is "driven", not by typical boundary conditions but, by contractions in its interior. In a finite element analysis, I can specify the new lengths (not displacement vectors) of a set, $\mathscr{S}$, of element edges. I do not know the final positions of the vertexes that make up edges in $\...
Given the location of $n$ points on a 2D plane ($P_1, P_2, \ldots, P_n$); and the location of a special point $X$. Find three points $P_i,P_j,P_k$ ($i \neq j \neq k$) such that point $X$ is inside the triangle $P_iP_jP_k$, and the minimum distance between point $X$ and the three sides of the triangle is the largest. In...
I want to approximate $uu'$ with a finite difference. On the one hand, it seems to be $$(uu')_i=u_i\frac{u_{i+1}-u_{i-1}}{2\Delta t}=\frac{u_iu_{i+1}-u_iu_{i-1}}{2\Delta t}$$ On the other hand, $$(uu')_i=\left(\frac{d}{dx}\frac{u^2}{2}\right)_i=\frac{u^2_{i+1}-u^2_{i-1}}{4\Delta x}$$ I might be wrong but I think that t...
I have a problem with computing gradient of each node in finite element method. I can get the value of each node. But how can I get the gradient? I know $u = \sum u_i \phi_i$ where $\phi_i$ are the test functions. So $\frac{\partial u}{\partial x} = \sum u_i \frac{\partial \phi_i}{\partial x}$. But if it is one-dimensi...
I realized an usual way to scale an N-body problem for an N-body simulation is by choosing units such that gravitational constant $G = 1$, but I'm probably doing it the wrong way. Suppose I simply have a planet moving around the Sun (which I consider as the center of my reference frame). For example I choose \begin{equ...
I would like to have an algorithm that interpolates the values attached to nodes in a concave mesh mesh. To be me precise, assume we have a point cloud P (e.g. in 3 dimensions) and a list of edges E connecting it with form a concave mesh in the form $E=[[i_1,i_2],[j_,j_2],...]$, where $i,j$ are nodes. Further assume th...
Let $A \in \mathbb{R}^{m \times n}$ where $m \geq n$. Let $B$ and $\tau$ be the result of applying LAPACK's dgeqrfp method (R on the upper right triangle, and the Householders reflectors below the diagonal). How would you use the reflectors and $\tau$ to perform a projection of any matrix on the space orthogonal to the...
I need to do a simulation for my thesis project involving some piezoelectric nanoparticles in a fluid beamed with ultrasounds. I'm looking for a software for such simulation and for now it seems me only COMSOL Multiphysics has acoustic and electrostatic modules for finite element analysis. Do you recommend it? Can you ...
I have been trying to figure out what I did wrong for the last two days. I do not know if I actually did something wrong or if the error is supposed to be this large in usual leapfrog problems. I tried checking my numerical solution with an exact one. Specifically, where the initial condition of the string is $$y(x,0) ...
I have read different approaches on how to solve pdes in parallel which are discretized using finite element method. For example: Non-overlapping domain decomposition approach as mentioned in https://imsc.uni-graz.at/haasegu/Papers/Douglas-Haase-Langer/textbook.pdf at chapter 5.2 . Each process works on each own domai...
I believe, I have a parametric nonlinear optimization problem. The non-convex constraints depend on some parameters, and I seek a solution that satisfies these constraints for all parameters in a specified continuous range. Let $ {\bf A}(\vec{x},\vec{\theta}) := {\bf A} \in\mathbb{R}^{n\times n}$ be a matrix-valued fun...
Say you have a tensor $T$ and the components are represented by a 3 by 3 by 3 matrix. And you want to use that tensor to map a vector $u$ into a new vector $s$, both of which are 3 by 1 column vectors. How do I know how to convert the 3 by 3 by 3 matrix into a matrix that is compatible with multiplication with my vecto...
I want to construct a gauss integration for the weight function $w(x) = x^{1/2}$ for $$\int_{0}^{1}x^{1/2}f(x)dx = a_{1}f(x_{1})+a_{2}f(x_{2})$$ Solving \begin{align*} a_{1}+a_{2} =& \int_{0}^{1}x^{1/2} dx = \frac{2}{3} \\ a_{1}x_{1}+a_{2}x_{2}=&\int_{0}^{1}x^{1/2}x dx =\frac{2}{5}\\ \end{align*} Solving this s...
I am trying to numerically solve the following equation: $\frac{\partial^{2} \phi}{\partial t^{2}}-\frac{\partial^{2} \phi}{\partial x^{2}}+V(x) \phi(x, t)=0$ On some domain, with: $\phi(x, 0) = I(x)$ $\frac{\partial \phi(x, 0)}{\partial t} = 0$ And with non-reflecting (absorbing) boundary conditions. I am using finite...
Original Stack Overflow Question: https://stackoverflow.com/questions/65683788/indexerror-index-31-is-out-of-bounds-for-axis-1-with-size-31?noredirect=1#comment116218335_65683788 PDE: u_t = u_xx + u(u_x)^2 The backward difference was used the time derivative meanwhile a central difference was used for the first space d...
I am using the Galerkin method (Discontinuous to be precise) to discretize in space the scalar linear wave equation and the explicit second order centered finite difference scheme to discretize in time, resulting in a semi-discrete system of the kind: $M\ddot{U} + KU=0, \quad U(0)=U_0, \quad \dot{U}(0) = U_1,$ where $M...
I am looking for finding or rather building common eigenvectors matrix X between 2 matrices A and B such as : AX=aX with "a" the diagonal matrix corresponding to the eigenvalues BX=bX with "b" the diagonal matrix corresponding to the eigenvalues where A and B are square and diagonalizable matrices. I took a look in a...
I am trying to write a function to compute 1st derivative with backward difference approximation. $ u'(x_i) = \frac{u(x_i) - u(x_i - \Delta_x)}{\Delta x} \equiv D_- u(x_i).$ And for the first point, I use the forward difference approximation that mirrors the one I just found. My problem is the function is not accurate...
I am puzzled by the Wikipedia entry discussing many online algorithms for computing the sample variance, including the Welford's online algorithm. In particular, the sample variance $s_n^2$ can be computed from the sample $\{X_1,..,X_n\}$ as: $$ x_n = \frac{n-1}n x_{n-1} + \frac 1n X_n $$ $$ s_n^2=\frac{n-2}{n-1}s_{n-1...
Following the advise of @Federico Polonion a previous post, one suggested, to find a basis of common eigen vectors between 2 matrices, to simply do : Generate 2 random scalars x and y Compute the eigen vectors and values of the quantity x*A + b*Y by doing in Matlab : eig(x * A + y * B) But I would have thought that...
A MATLAB library seems to overcomplicate a computation: exp( (log(a) - log(b))/b ) which is mathematically equivalent (assuming real & positive a, b) to (a/b).^(1/b) Another computation in log-exp cancellation makes sense for greater numeric stability, but I can't see any advantages here. What could be the motivation...
Hi I am trying to solve a set of pde converted into ODE and DAE using central finite difference method. I have used the MATLAB 'solve' command to determine the coefficients of fictitious nodes for boundary conditions. I am using the ode15s solver and getting "This DAE appears to be of index greater than 1" daeic12 (lin...
i am implementing a Matlab code to solve the following equation numerically : $$ (\frac{\partial c}{\partial t} =-D_{e} \frac{\partial^2 c}{\partial z^2} +U_{z}\frac{\partial c}{\partial z}) $$ with the folllowing boundary conditions: $$ at \ \ z = 0 \ ; \ c= c_{i0} \\ \\ at \ \ z = L \ ; \ \frac{\part...
I am new to Fortran and I am trying to write a code using random data instead of binned data in x, y, z as shown in my sample code. implicit real*8(a-h,o-z) dimension rm(4),rp1(4),rip1(4),rp2(4),rip2(4),rp3(4),rip3(4), d rn(4),u1(4),u2(4),u3(4) do ix= 1000,25000,1000 x = ix/1000000. do iy = 1000,25000,1000 ...
I am trying to self-learn SciPy and evaluate the following quadruple integral using scipy.integrate.nquad: $$\int_{0}^{1} \int_{0}^{1} \int_{0}^{1} \int_{0}^{1-x} (w+y) \:dz \:dy \:dx \:dw $$ I wrote the following code: from scipy import integrate def f(z, y, x, w): return w + y def bounds(z): return [0, 1-z]...
I am struggling with implementing an algorithm that does one simple thing: Consider two polygons (one can just draw any two polygons and number their vertices), whose connectivities in a node list are: A = [1, 2, 3, 4, 5] B = [1, 6, 7, 8, 3, 2] These two polygons share 2 faces (1, 2) and (2, 3). What I want to do is to...
I'm in search for a library for solving large systems of non-linear equations, similar to MINPACK, but unlike MINPACK, can accept a Jacobian in band-storage. My Jacobian is sometimes not invertible, so a method like the Levenberg-Marquardt algorithm in MINPACK, which can deal with singular Jacobians is important. Also,...
I am trying to use CVXPY to optimise signal-to-noise-plus interference ratio (SINR) for a visible light communication (VLC) system. I have one of my SINR constraints stated as \begin{equation} \mathbf{h}^{\textsf{T}}_{l,u}\mathbf{p}_{l} \geq \sqrt{\gamma_{u}\sum_{j\in \mathcal{L}\backslash\lbrace l\rbrace}\left(\ma...
How frequently scientific code uses comparisons NaN == NaN? Reason of asking: from time to time compilers / software floating-point library implementations have bugs w.r.t. comparisons with NaN. For instance, NaN == NaN incorrectly returns true, which is a bug. The end user may face with this bug if the end user relies...
In my research, I need to invert a Fisher matrix in order to get a covariance matrix for me to do parameter estimation. Unfortunately, the values of Fisher matrix vary by many orders of magnitude, and the numerical errors are significant (see image at end). I first attempted this in python using scipy.linalg.inv, and i...
The version of Fortran used comes from Montreal Ecole Polytechnique in 1980. I need a compiler for Fortran for Windows 7 or Windows 8.
i trying to solve this integral $$\int_{-\infty}^{\infty} e^{-x^2}dx$$ I'm using this CODE from scipy.integrate import quad def integrand(x): return exp(-x**2) I = quad(integrand, -np.inf, np.inf, args=()) >>>I = (1.7724538509055159, 1.4202636780944923e-08) Can i use any other numerical method to solve it?
The model is $$y_i=\beta\big(x_{i1}^\alpha+x_{i2}^\alpha+...+x_{im_i}^\alpha\big)+\epsilon_i\textrm{ for }i=1, 2, ..., n$$ I want to minimize the MAE, i.e. $$\Sigma_{i=1}^n{\big|y_i-\beta\big(x_{i1}^\alpha+x_{i2}^\alpha+...+x_{im_i}^\alpha\big)\big|}$$ I tried gradient descent, but I'm worried that the solution is no...
My question is around the efficiency of AMG. In which case AMG can perform better,as solver or as a preconditioner(for example a Krylov space method as CG)? Assume the case of elliptic pdes.
I want to try simulation-(and not experimental)-driven approach to design custom fireplace fuel burners. What software applications, libraries, code and model templates can I use to model and visualise a combustion process on a 3D object? I want to design a 3D model of a static solid object, assign properties to it (e....
I'm trying to verify the order of convergence for implicit Euler method to numerically solve Black-Scholes PDE. Theory says that it should be $O(\Delta t + \Delta S^2).$ My code is working absolutely fine. I'm getting almost zero error when I compare my solution to the one obtained by Black-Scholes formula. However, I'...
How to solve/assess the following problem? Given: $N$ ingredients like apples, bread etc. Mass of an ingredient $j$ is in this simplified model a sum of macro nutrients carbohydrates, proteins and fats in proportions $c_j$, $p_j$ and $f_j$: $(1)\ M_j = (c_j + p_j + f_j) * x_j $ (in grams) $(2) \ c_j + p_j + f_j = 1$ Al...
I am a newbie to convex optimisation and I am learning with the aid of CVXPY. I am requesting for clarity on the illumination problem as described in Boyd & Vandenberghe lecture 1 slides here. I have adapted the code from here and tried to visualise what the illuminance from within a room would look like. I have insert...
I have N matrices that are positive definite, and I have to solve for a M vectors. As M is large in my case, doing all solves simultaneously using np.linalg.solve burdens my RAM and sometimes not possible. However, splitting to batches using and solving on them unnecessarily performs the factorization step multiple tim...
I am quite new in this field. For my university I prepared a stiffness matrix to solve for a project group. This matrix consists of 450 equations with 450 unknows (it's a Matlab script) and I have the associated load vector $\{L\}$ of 450 rows. since I need to calculate the displacements would you advice me to simply d...
Lately, I have encountered the following problem, namely how to recognize the shapes of particular polygons. I have realized that quite straightforward to do so when the polygons are separated by using OpenCV library as shown in the following topics example 1 example 2 My question, however, is quite more complex and co...
I'm trying to integrate a function which is defined as func in my code below, a cumulative distribution function is inside: from scipy.stats import norm from scipy.integrate import quad import math import numpy as np def func(v, r): return (1 - norm.cdf(r / math.sqrt(v))) print(quad(lambda x: func(x, 1) , 0, np....
I am looking for references showing how to analytically solve the heat equation with Neumann boundary conditions in two dimensions. So far, I have found the problem solved analytically in one dimension. I have also found analytical solutions to the heat equation in two dimensions, but with Dirichlet boundary conditions...
To explain my problem I'd like to go with an example first. Suppose I have many bills of grocery purchases in the same shop. On the invoices I can only see the total amount of the invoice and which products I have bought and in what quantity. I would like to find out how much a single product actually costs by looking ...
I have a simulation which gives a scalar result depending on the choice of some continuous design variables. I am trying to minimize the output of the simulation. As a first step, I want to study the convexity of the problem. Is there a methodology that allows us to determine whether a black box function (no analytica...
I am attempting to create a conditional statement that compares four (4) true/false conditions. Depending on the state of these four conditions (either true or false) the conditional statement will either pass or fail. I have a table that tells me the outcome (pass/fail) of all possible permutations. 2^4 = 16 possible ...
With the increased popularity of 3D imaging and scanning I thought it would be easy to transform a xyz point cloud into a Height Map (xy matrix of z points), but after a couple of hours searching I found nothing. Maybe I'm looking in the wrong direction, isn't there some C++ library for this type of conversion?
I am currently doing a project in which my aim is to write a program that can be used to calculate single and multi-channel shape resonances. So I'm looking at bound states and quasi-bound states. Specifically, I'm looking at the hydrogen molecule in spherically symmetric potentials. So the method I follow (renormalize...
I am using petsc to solve a linear elasticity problem discretized by finite elements.The initial mesh is read by a mesh file and the distribution in each processor is done using METIS.I am using only the basics routines from petsc in order to create the submatrices and vectors.After solving I want every processor to wr...
I have a system of two coupled differential equations, one is a third-order and the second is second-order. I am looking for a way to solve it in Python. I would be extremely grateful for any advice on how can I do that or simplify this set of equations that define a boundary value problem : Pr is just a constant (Pra...
I am trying to use METIS-5.1.0 edition in order to partion a FE mesh. For demostration purposes I created 2x2 rectangle mesh and tried to partition it. However, I notice a weird behaviour in my code. When i am using 2 parts to partion the mesh everything works file, but if i increase the number of partions at 3 or 4 I...
I tryin to plot the position of electron in the hidrogen atom by Coulomb's law, $F=K \frac{q_1 q_2}{r^3}$ This is mi code import numpy as np import matplotlib.pyplot as plt def coulomb(re, v0): #Set parameters: N = 500 dt = 2.2222222 / N # Time Step: #Create an array, for all variables, of...