# Tag Info

1

You did nothing wrong, the numbers just are what they are. Plotting the error for the backwards difference gives the plot which is as expected for a method of order one with step size about $h=0.01$. For the second order methods one expects an error of the magnitude $h^2=10^{-4}$, the plot below confirms this

1

If you insist on using quad, a more efficient implementation would calculate the integrals over the segments of the subdivision with quad for best accuracy and then a cumulative sum for the anti-derivative value at each sample point. def f(x): return x*np.sin(1/x) X = np.arange(-0.5,0.5,0.001) DF = [ integrate.quad(f,a,b)[0] for a,b in zip(X[:-1],X[1:])...

2

from scipy.integrate import cumtrapz import numpy as np import matplotlib.pyplot as plt def f(x): return x*np.sin(1/x) if abs(x) > 1e-10 else x f = np.vectorize(f) X = np.arange(-0.5, .5, 0.001) fv = f(X) plt.plot(fv) F = cumtrapz(fv, x=X, initial=0) plt.plot(F);

2

Let's reconstruct this from first principles: Defining the ODE system In the method-of-lines discretization you solve an ODE system $\dot U=F(U)$, $U=(U_0,U_1,...,U_{M+1})$, $U_k(t)=u(x_k,t)$, and similarly $F=(F_0,F_1...,F_{M+1})$. Because of the boundary conditions $$u(x, 0) = 40 · x^2 · (1 - x) / 3 \\ u(0, t) = u(1, t) = 0$$ $U_0=U_{M+1}=0$ and ...

1

I used another variant for the exact solution of the wave equation (which is the same as the series sum), and shortened the computation by transforming loops into numpy array operations. With this changed code I do not observe the numerical errors you got v = 1 def f(x): '''2-periodic odd-symmetric continuation of y(x,0)''' x = (x%2+1)%2-1; ...

2

This use of the numerical solver is completely wrong. The numerical ODE solvers are for problems that have a smooth right side. As long as the existence of an exact solution is ensured, they can also be applied to problems where the right side is piecewise smooth, but that will tend to slow down the integration with very small step sizes at the ...

1

I would suggest Introduction to Numerical Methods for Variational Problems by Langtangen and Mardal. Besides that, you could check: scikit-fem. SfePy. I would also suggest our own course Introductory Finite Elements. It has Notebooks with the material and lecture notes; and our own package SolidsPy.

0

Did you try with Dask ? https://examples.dask.org/machine-learning/svd.html You can manage very large matrices. There is also a nice blog post about it https://blog.dask.org/2020/05/13/large-svds

3

For your first question, constructing the adjacency graph of the "partitions" (what you call "cell groups"): Let's say you have an array $p_K$ in which you store for each cell $K$ which partition $p$ it belongs to. Also assume that you have a (sparse) array $a_{KL}$ whose entries are true if cells $K$ and $L$ are neighbors ("adjacent&...

Top 50 recent answers are included