Skip to main content

All Questions

0 votes
0 answers
35 views

Optimizing a numerical integration that involves matrices using sympy

The expression I'm integrating is Where the latent variables are sampled from the a multivariate distribution as following: And the random variables w_n given a latent variable is sampled from a ...
Mea12's user avatar
  • 71
2 votes
1 answer
86 views

How can I approximate 255/sqrt(x) using Newton's method?

I am trying to approximate 255 / sqrt(x) using Newton's method to avoid using division or the sqrt() operation on an architecture where those operations are expensive. My derivation is: y = 255 / sqrt(...
the five states's user avatar
0 votes
0 answers
71 views

Apply Crank-Nicolson method to wave equation with np.linalg.solve

I want to solve a system of equations, where x,y are the vectors which I want the solutions. And c,d are the solutions. A,B are matrix x-y=c+d y-Ax=Bd+c The full problem which I tried to summarize ...
Guillermo Fuentes's user avatar
2 votes
1 answer
420 views

Minimization of a function with constraints in Python

I'm trying to minimize a function of three N-sized arrays that contain the minimization parameters that I want to find. For example, suppose the parameters I want to find in order to minimize the ...
Mateus Forcelini's user avatar
0 votes
1 answer
524 views

Minimization of a function with iterative bounds in Python

I'm trying to minimize a function of N parameters (e.g. x[1],x[2],x[3]...,x[N]) where the boundaries for the minimization depend on the minimized parameters themselves. For instance, assume that all ...
Mateus Forcelini's user avatar
1 vote
0 answers
519 views

Periodic boundary condition and 4th order Runge Kutta method used for solving partial differential equation(1D wave packet propagation)

# RK4 # disp = u0 # initial condition array flag = True #h = 0 timeee = 0.000 timemax = 5001 #ms while(timeee<timemax): predisp = np.zeros(N+4) ddisp = np.zeros(N+2) # derivative ...
Avii's user avatar
  • 164
0 votes
1 answer
679 views

Numerically Solving A Multivariate Differential Equation Without odeint

I am curious. I know this can be solved by using odeint, but I'm trying to do it from scratch, and I've encountered an interesting behaviour. Assume a simple oscillator, of equation m * x_ddot + k * x ...
fallen_one's user avatar
0 votes
2 answers
231 views

Why the the arithmetic of python always return 10 for this function?

The output for this code is always 10. AM I doing something wrong? I also want assistance the negative rational exponent equation for "Vc" let R=10000, C=1e-6, and Vs=10 R= 10000 C= 10*...
Godang's user avatar
  • 3
0 votes
0 answers
118 views

Integrating between two function with simpson rule

I have a numerical problem. I need to calculate the integral between two functions f1 and f2. I already have the simpson rule for one function. I need help how to find the intercepts between the two ...
Or Meiri's user avatar
0 votes
0 answers
105 views

Difference between Eulers and Improved Eulers (Heun) in precision

I'm developing the code below to check the difference between Euler and Enhanced Euler methods for the function y'= y. In this case, I see that the more the iterations advance, the greater the ...
Danilo Perl's user avatar
0 votes
1 answer
304 views

How to compare similarity between two numeric columns

I have two large datasets Df1 & Df2 with numeric variables. I have to match each numeric variable in Df2 with its corresponding one in Df1. The column names are completly different in both ...
yassine's user avatar
  • 75
1 vote
2 answers
469 views

Numerical differentiation: Error does not behave as expected

I want to differentiate a function f(x, y) with respect to x and y numerically using the difference quotient def dfdx_v2(x, y, h): return 0.5 * (f(x+h, y) - f(x-h, y)) / h def dfdy_v2(x, y, h): ...
Gilfoyle's user avatar
  • 3,636
-1 votes
1 answer
283 views

How to stop code once it reaches the tolerance number (for function approximation)

So I have the following code: import numpy as np def g_of_x(x): return ((5/x**2)+3) initial_guess = 3 for i in range(15): solution = g_of_x(initial_guess) initial_guess = solution ...
VoltStatic's user avatar
0 votes
0 answers
328 views

How do i do an error analysis for the numerical approximations of the code?

I want to find the errors that might happen from doing this numerical approximation for the transport equation. I am having a difficult time on calculating the error through programming. I'm pretty ...
mehek's user avatar
  • 27
0 votes
0 answers
22 views

Multiprocessing simple code for numerical calculations

I need to implement multiprocessing on this code. Basically it makes a grid of nxn data in the using numpy linspace, and enters on a while loop checking a condition on the t parameter. On each run ...
eulag's user avatar
  • 11

15 30 50 per page