#numerical-analysis
1 messages · Page 6 of 1
What
I just invert it inside my outer CG everytime.
So now there is an outer CG and an inner CG. Thanks anyway.
for each x_i you are given multiple values called y_i?
Sounds like hermitian interpolation, in which case, just lagrange won't cut it there
I think there's like a weird concept of parametric interpolation using lagrange interpolation, which fits a parametric curve, I never really understood how it works though
I am a bit confused by trigonometric interpolation:
We've shown how the FFT takes y0, ... y_n (where n+1 is a power of 2) and returns c_0, ... , c_n. From those I get coefficients a_i = c_i + c_-i and b_i = i(c_i-c_-i) for i between 0 and m=(n-1)/2... but that would only require 2m+1 = n values c, but I am given n+1 values of c
Is y_n at the endpoint of the interval?
In our case it is the interpolant evaluated at $2\pi\frac{k}{n+1}$ with k=n
Kerr
Yah
hermite interpolation is when you have the derivatives though
yes, but multiple y values associated to a single x isnt even a function. Hermite interpolation sometimes uses the notation $y^{(k)}{i}$ for k-th derivative of f at $x{i}$ so thats what I assume they meant
Kerr
Here is task itself it says that there is given the closed curve. Idk what interpolation they mean by second task.
Also one more thing they told me right now is to do the interpolation in range by range. But how do i find this ranges?
am solving the 1-D advection-diffusion equation, but I am stuck on how to implement the formula into my code. I understand how to the the next time step when the advection term and diffusion term are separate, but I am stuck now when they are both together. I am using Crank-Nicolson for the Advection term and RK4 for the diffusion term. I am Able to get this far but i realize that RK4 is a multi-step method with 4 steps. What I have solved by mistake is RK2. How do I advance further than this? What i am trying to find the the next timestep U^n+1. In this image D1 is a derivative matrix for the 1st derivative and D2 is one for the 2nd derivative. (error i spotted in my writing its supposed to be dt/2 not dt/4)
(if someone comes around who is able to help feel free to dm me. i am off to bed 😴 )
who knows , why do deflate the matrix , eliminating the last row and column will not cause the final answer wrong?
because i think keep last row and column will take effect to other eigenvalues's calculation , and i think it should consider whole matrix ,not only sub matrix
you can view a matrix of the form B=[A 0;0 a] where A is a matrix and "a" is a scalar as a block diagonal matrix (where A is one block and "a" is the second block) The eigenvalue "a" of B is independent of the the rest of the matrix (and can thus be "discarded"
example: ```julia> B
5×5 Matrix{Float64}:
0.18417 0.95633 1.57871 0.635951 0.0
0.95633 0.42293 1.14073 1.01519 0.0
1.57871 1.14073 0.222519 0.649137 0.0
0.635951 1.01519 0.649137 1.9075 0.0
0.0 0.0 0.0 0.0 5.0
julia> eigen(B)
Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
5-element Vector{Float64}:
-1.3899812449001656
-0.5821905848859844
0.9999619656168435
3.7093277956206867
5.0
vectors:
5×5 Matrix{Float64}:
0.670541 0.421714 -0.416131 -0.446506 0.0
0.119093 -0.855552 -0.163937 -0.476416 0.0
-0.731924 0.24181 -0.431349 -0.468778 0.0
-0.0218994 0.178089 0.783516 -0.594901 0.0
0.0 0.0 0.0 0.0 1.0```
thank you sverek , let me check it
Why are you using crank nicolson for advection
but the actually the B is $\begin{bmatrix} A & X \ 0 & \lambda_1 \end{bmatrix}$ ? because the iteration only check last row (except last column) are all zero
cache-missing
julia> B
5×5 Matrix{Float64}:
0.614101 1.09511 1.20847 0.630836 0.773735
1.09511 1.84073 1.53124 0.856159 0.716563
1.20847 1.53124 0.114145 1.41037 0.0239439
0.630836 0.856159 1.41037 1.46599 0.263584
0.0 0.0 0.0 0.0 5.0
julia> eigen(B)
Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
5-element Vector{Float64}:
-1.2403034786581852
-0.015204498399530662
0.822681140496317
4.467783661371424
5.0
vectors:
5×5 Matrix{Float64}:
0.325097 -0.834671 -0.186815 0.403405 0.386012
0.230702 0.509684 -0.563801 0.607559 0.539833
-0.865804 -0.117312 0.059875 0.482739 0.379609
0.302443 0.172579 0.802274 0.484871 0.389487
0.0 0.0 0.0 0.0 0.513587
julia> eigen(B[1:4,1:4])
Eigen{Float64, Float64, Matrix{Float64}, Vector{Float64}}
values:
4-element Vector{Float64}:
-1.2403034786581866
-0.015204498399531197
0.8226811404963139
4.467783661371417
vectors:
4×4 Matrix{Float64}:
-0.325097 0.834671 -0.186815 -0.403405
-0.230702 -0.509684 -0.563801 -0.607559
0.865804 0.117312 0.059875 -0.482739
-0.302443 -0.172579 0.802274 -0.484871```
thanks !
It's what was required to use
hello , who knows ,why power iteration can evaluation the eigenvalue, the rayleigh quotient has a condition that is x is close to eigenvector ,but in the algorithm, u_j is only unit vector ,not promise close to the eigenvector
The key is that it is an iterative method
u_j is a unit vector that is changing direction
u_j is only close to the direction of eigenvector , but not in value ,
so i don't understand how can calculate the \lambda use u_j
As you iterate, u_j gets closer and closer to an eigenvector
Eventually, it will be machine precision away from an eigenvector and the corresponding lambda_j will be machine precision away from the corresponding eigenvalue
after iterate many times, the $u_j$ still an unit vector , becuase it's definition is $u_{j-1} = x_{j-1} / ||x{_j1}||_2$
but!
the eigenvector of A is may not unit vector , so ,the u_j is close to the eigenvector only in direction , but not value , this is what am confuse, why in the algorithm ,use $u_jT$ to evaluate $\lambda$ , that is $\lambda_j = u^{T}{j-1}Au{j-1}$
cache-missing
Compile Error! Click the
reaction for more information.
(You may edit your message to recompile.)
it's hard to read
wait a second
i meant due to the handwriting 😂
the u is the J and the v is the i.
use linearity to get the stiffness matrix
exactly, that should be the last step right
oh wow thank you criver 🙂 i am shocked i did this properly to this point 🙂
yes, i was going to ask, thats the correct assumption to make right
since the nodes should equal to the values right?
the correct is v(0)=v(L)=0
yes, i wrote incorrectly
that is what i meant
okay i got it into a matrix form and written all out, thank you criver 🙂
I really appreciate it! 🙂
if you prescribe derivatives this is not the case anymore
but there you just substitute the derivative with whatever is prescribed
well if its a dervative dont you do something similar?
say the that function equals zero? Also wouldnt you drop it out of A?
and thank you btw criver, my teacher really wanted to go over why that problem that i showed you previously was singular. he thought i was a genious because i knew the answer. Thank you for helping me 😛
no
you have essential/stable and natural BCs
there's a discussion of that in Evans and Gazzola
essentially if I have something like Au = f, where A is a differential operator
then you integrate by parts (i.e. use Green's theorem) enough times to transfer half of the derivatives to the test function
this produces as many boundary terms as steps you do
e.g. if A = (-\Delta)^{2q}
then you would transfer (-\Delta)^q to the test function
and that would pop out terms like \Delta^m v d_n \Delta^{l} and d_n \Delta^m v \Delta^l u
in either case ones with order >=2q-1/2 would be termed natural
the rest are stable
the stable ones can be zeroed out
maybe that's a bit too advanced though
im lost 😛 i wont lie, i understand greens theorm and how its igbp. i guess you can do it multiple times and it evenly splits the dervative out. if it meets some condition its stable if not i guess its unstable.
that has somethign to do with BC right? so like dirchlet conditions are stable while neumann arent?
stable just refers to one that are within the Sobolev space, i.e. which you can zero out
natural ones are outside the Sobolev space and you need to substitute
e.g. Delta u = f
Sobolev space is H^1
but on the boundary you are allowed only 1-1/2 = 1/2
so v d_n u must disappear because d_n u isn't in the spsce
if you prescribed Dirichlet conditions v=0
if you prescribed derivatives d_n u = g, then just substitute to get int v d_n u = int v g
you have to separately enforce stable/essential BCs
natural ones appear "naturally" in your formulation
for A = Delta, stable is Dirichlet and natural is derivative (at least for H^1)
for A = Delta^2, stable is u(x) =..., d_n u(x) =...
and natural are Delta u(x) = ..., d_n Delta u(x) = ...
wait
no
now it's correct
the first two are of order 0,1 which is smaller that 2-1/2 = 3/2
the natural ones are of order 2 and 3
i see, haha, is this advanced math?
you have an example of a book that woudl teach this?
what kind of math is this even?
here it is: https://www.math.ovgu.de/grunau.html
the monograph under pubkications
polyharmonic boundary value problems
evans has it shortly in his pde book too
the book im using is by some swedes named larson and bengzon
i must say its quite a good book, it read very well
thank you for the knowledge 🙂
No, a norwegian university haha 🙂
can i ask a question on finite difference method here or is that too basic for this room?
it's fine
im using the central differnce method for this.
its (U_j+1 - 2U_j + U_j-1) / h^2
and then im going to use the implicit to get the ax = b right?
well, discretise the domain in space, then approximate the second derivative yes
careful at U1 and Un
you have to account for the bcs
yes, im unsure what to do. since its not dervatives here its not ghost points
so would it be that A would be something like this?
sGhost are fine
e.g. study dxx U1, and see that U0 is included, just substitute in the bc for it
similarly for Un, check Un+1 there
for the first ghost point would it be u_j-1 = u_j+1 ?
you can pick equidistant grid with xi = i/(n+1)
just expand this with what you wrote
assume 1,...,n are on the interior and 0,n+1 are at the bcs
alright i think i got it ill get to work now. So I can use the explicit method with this and ghost points
you can use ghost points yes
that's incorrect btw
note that u0 = u(0) and un+1 = u(1) and just use that
im gonna sleep on it and try tommorow, im a little scared. this is a practice exam and i can do like 70% of it it seems.
im a bit stuck on this one though. thanks for the help criver gonna call it a night 🙂
What kind of convergence should I expect with the discrete fourier transform? That is building a sum of sine and cosine waves from the fourier coefficients a la FFT
What limit are you taking?
Adding interpolation points, specifically in powers of two
So you fix a domain and make the grid spacing finer?
Yeah
The DFT will converge to the continuous fourier transform
You can see this by viewing the DFT as a discretization of the fourier transform integral
0 to 2 pi, points of the form 2pi k/N
Right, this in the context of interpolating periodic functions but the error so far has been terrible
Error in an implementation?
Could be. But I am not alone in getting errors of that magnitude. Do you maybe know of a source that describes such an implementation?
In mathematics, trigonometric interpolation is interpolation with trigonometric polynomials. Interpolation is the process of finding a function which goes through some given data points. For trigonometric interpolation, this function has to be a trigonometric polynomial, that is, a sum of sines and cosines of given periods. This form is especial...
That's wildly different way of going about it. Hm...
What is your way of doing it?
The wiki way is constructing a certain basis, our way was finding the a_i and b_i's explicitely
So far, given an even number of points n and m=n/2 taking a_1 = c_1/2 and c_m/2=a_m+1 and finding the a_i = c_k+c_k+m and b_i = i(c_k - c_k+m)
that way of finding the b_i is seemingly the only way to do it, since only that way do the actual outputs pair up to have equal imaginery or real parts
in other words, taking this https://en.wikipedia.org/wiki/Discrete_Fourier_transform#Inverse_transform
and trying to figure which things cancel to real valued cosine and sine terms
In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency. The interval at which the DTFT is sampled is the reciprocal of the duration o...
uh.... I am not sure how applicable the method in your article is on my machine
?
it's sin(pi x)/(pi x) instead of sin(x)/x
that was unexpected, but thanks 👍
julia> sinc(pi)
-0.04359862862918775
?
standard definition
How do I go about solving for my new value in adam moulton order 2 or above
Given it is implicit
I was told that I should use like newtons method but I don't see how I am to use it in this example . Do I perform a taylor approximation about f(tk,yk) ?
i might just need to look more into it but I am not sure how I am suppose to go about solving for a yk+1
You are solving y_k+1-h/2*f(t_k+1,y_k+1)=y_k+h/2*f(t_k,y_k) right
Or how about this
We have that [y_{k+1}=y_k+\frac{h}{2}\qty(f(t_k,y_k)+f(t_{k+1},y_{k+1}))] so then [y_{k+1}-\frac{h}{2}f(t_{k+1},y_{k+1})=y_k+\frac{h}{2}f(t_k,y_k)] so we set $C=y_k+\frac{h}{2}f(t_k,y_k)$ and then [F(x)=x-\frac{h}{2}f(t_{k+1},x)-C] so then we want to solve for $F(x)=0$ which we do using Newton's method
守沢千秋
see my concern is do we use x = y_k? I understand how to solve F(x) but I was confused as to where we evaluate the partial derivatives from about what point
like you might do
$F(x) \approx F(x_1) + F_x(x_1)(x-x_1)+ F_t(t_1)(t-t_1)$
wait nvm...
Brandon7716
y_{k+1} is a number
but I don't know that number
That's whay you're using Newton's method for
oh okay. I see
so as far as a "guess" to initiate the method I can just throw in my previous y_k and see where it converges?
Yes
okay I think I got it now, thanks 
function [G3_x, G3_v] = G3_Scheme(t, G3_x, G3_v, u, h, x_p, v_p, i)
if i <= 2
[G3_x, G3_v] = RK4_Scheme(t,G3_x, G3_v,u,h,x_p,v_p,i);
else
syms x v;
A = (18/11)*(G3_x(i))-(9/11)*(G3_x(i-1))+(2/11)*(G3_x(i-2));
B = (18/11)*(G3_v(i))-(9/11)*(G3_v(i-1))+(2/11)*(G3_v(i-2));
f1 = x-(6*h/11)*x_p(t(i+1),x,v,u)- A;
f2 = v-(6*h/11)*v_p(t(i+1),x,v,u) - B;
% Create a vector of symbolic variables
vars = [x; v];
% Create a vector to store the functions
F = [f1; f2];
% Compute the Jacobian matrix
J = jacobian(F, vars);
%Initial Guess
x0 = [G3_x(i); G3_v(i)];
%Newton-Rapson
for j=1:10
J_x0 = subs(J, vars, x0);
F_x0 = subs(F, vars, x0);
deltaVec = linsolve(J_x0,-1*F_x0);
x0 = x0 + deltaVec;
if norm(deltaVec) < 10e-6
%disp('Norm condition met');
break
end
end
G3_x(i + 1) = x0(1);
G3_v(i + 1) = x0(2);
end
end
so I think I implemented it correctly
and it did graph
x_p and v_p are the ode system for van der pol
🙏 it seems linsolve can be slow or maybe it can't solve it and isn't tell me. I should look into this
just write it out in terms of the explicit definition
but this isn't #numerical-analysis
does anyone know how to do this problem?
i've made a basis {e^(ik(n1xp+n2xp)} and a matrix A with this basis for all my datapoints x
so A = { e^(ik(n1 * x + n2 * y)), ... , e^(ik(n1 * x + n2 * y))}, for different points of n1 and n2
now, how do you use the least square method here?
I've been stuck on this problem for hours and I am not progressing
v(xp) = v(x,y)
if you have min_x |Bz-f|^2 then B^*B z = B^* f is the solution
however your basis should be orthogonal here I believe, or is it not?
in either case B_pl = exp(ik(n1(l) * xp + n2(l) * yp))
1<=p<=M and 1<= l <= (2N+1)^2
you can use the map l(n1,n2) = (n1+N) * (2N+1) + (n2+N), then l(-N,-N) = 0, l(N,N) = 2N(2N+1) + 2N = (2N+1)(2N+1) - 1
then the inverse maos are n2 = l % (2N+1) - N and n1 = floor(l/(2N+1)) - N (or just integer division withoit floor)
this map is known as https://en.wikipedia.org/wiki/Vectorization_(mathematics)
so now fp = v2(xp)
and zl = hat{v2}(n1(l), n2(l))
@river thicket
it should be orthogonal, but the points are random generated for n1, n2
but why is v(n1,n2) mentioned here if you just use BB^{*} = B^{*}*v_1(x,y)
because your formulation has hat{v2}(n1(l), n2(l))
i just name this vector z with the vectorization discussed
then that double sum can be written as a single sum
and thus as a matrix vector product Bz
then you're in the standard setting |Bz-f|^2
So we're solving all the v_1(n1,n2):s here?
the coefficients or the amplitude for v_1(x,y)
A\v_1(x,y) in matlab code
where A is our basis matrix
So we're solving all the v_c:s
v_1(x,y) = v_c1(n11,n21) e{ik(n11x+n21)} + ... v_cr(n1r,n2r) e{ik(n1rx+n2r)}
@scarlet spruce
zl = v(n1(l),n2(l)) is just a vector z of unknown coefficients
B^* B z = B^* f
you don't need backslash or to even form matrices if this is orthogonal
What is the minimum flops needed for the solution of a 3x3 linear system?
What's the number to beat? Plain Gaussian elimination takes 30, not counting comparisons to guide pivot choices.
Well I guess 30 is the number to beat
Actually how many flops is it for the explicit solution
Like
My best idea for that one (that is, under the constraint that the only divisions are by the complete determinant) is 50.
Computing a determinant as (col1 × col2) · col3 takes 14 flops, but the common denominator can reuse the cross product from one of the numerator calculations and then only takes 5 extra.
Could somebody help me gauge what extrapolation is?
We have given a dataset [xi] and [F(xi)]. We also have given that a(h) = centralised differentialquotient of F.
What we want to calculate is f(1) (the derivative at place 1). Also to be considered is that F is analytical.
I dont quite understand it and have been reading through the lecture notes for like 2 hours
say you have data points (x,y): (1,3) (2.1, 7) (4,5) . then, interpolation would be if you want to get a value y for some x in [1,4] extrapolation would be to get a value y for some x smaller than 1 or larger than 4
So first thing to do is calculate the Polynomial?
And sorry but just for understandings sake: I would need 2k+1 different datapoints if I plan to use a centralised differentialquotient right?
however you want to interpolate. you differentiate your interpolant with central differences at the point you are interested in the derivate, you use 2 adjacent equispaced points for that.
it is a bit unclear what your whole "setup" is, are you given points, arbitrary, or given analytic expression of f
QR decomposition is messed up. Do you actually have to do the matrix multiplication $R_{i,n} A$ in order to figure out the next rotational matrix $R_{i+1,n}$?
edwardborn
That's going to result in like $\mathcal{O}(n^2)$ number of matrix multiplications!
edwardborn
Are you doing this with Givens rotations?
Yeah
I made a mistake. It should say R_{i,i+1} and not R{i,n}
Goddammit man. Not looking forward to do this by hand
This shid will be cheesed as hard as possible with permutation matrices
2 = c_0 + c_1,
0 = c_0 \cdot x_o + c_1 \cdot x_1,
2/3 = c_0 \cdot (x_o)^2 + c_1 \cdot (x_1)^2,
0 = c_0 \cdot (x_o)^3 + c_1 \cdot (x_1)^3
im trying to setup a simpsons rule looking evaluation for the following integral:
int -1 to 1 f(x)dx approx c_0x_0 + c_1x_1
and i came up with the system above by using 1 ,x, x^2, x^3 for f(x). I tried solving it by hand and got x_1 = 0. 1/3, +/- i/sqrt3 . and a classmate got x_0 = 1/sqrt3 , x_1 = -1/sqrt3 , c_0 = c_1 = 1. She got it with matlab so i just assume i mustve made a mistake somewhere.
But what i really wanna know is can i solve that system in a less annoying way than just solving for each variable and plugging in somewhere else like i originally did?
The original wording for the homework problem:
Find nodes x0, x1 and coefficients c0, c1 such that:
int -1 to 1 f(x)dx approx c_0x_0 + c_1x_1
has the highest degree of accuracy possible.
That's the usual way to do it
And is applicable to a wide range of problems
However, there is a specialization known as Gauss-Legendre quadrature where the x_i will be the roots of the Legendre polynomials
This is about Haar spaces and that looks… clearly wrong?
Hello guys, is this the right place to discuss the Galerkin method? 😄
epic
Like, let lambda_1 = 3, lambda_2 = 1. Then I would need to represent e^-x \times e^3x = e^2x as e^x times some a plus some b.
my understanding is that the Galerkin method is quite good
I dont see how your example demonstrates what’s described in the question
in your example f is e^x
What about lambda_n+1?
I guess correct me if I am wrong but f in $W_n$ means $f=\sum_{i=1}^n a_ie^{\lambda_i x}$ where $a_i\in\mathbb{R}$
cofe prpl
So using your examples for lambda we can take n=1 so n+1=2 and we can let f be ae^3x +be^x and e^-\lambda_2 be e^-x
So then we want to find c such that
$e^{-x}(ae^{3x} +be^x)-c= ne^{3x}$ for some n
cofe prpl
Nah im confused
I see what its saying though
I think I see what its trying to say
Yeah cus this is clearly false
Because lhs has slower growth than rhs
Give me any updates about what the correct statement was
Taking lambda_1 as 3, then e^3x is still an element in W_2.
Then I shifted c to the other side which gets me e^2x=ae^3x+c, which is pretty clearly not the same looking at the derivative of it's log (2 vs ae^3x/(ae^3x+b), the namely converges to 1)
Or just intuitively cursed
Your lamda_1=1 and lambda_2=3 no?
It looks like you have two separate lambda_2s
nah the order is right. Its e^-lambda_2 times f - c, where f is a general element from W_2
Oh wait my bad I misread
Good point though
Ive heard assumptions for indexed lambdas being ordered in numerical linear algebra
I dont think ordering does shit here though
Yeah, no.
The LHS can always be constant times e^(lambda_1-lambda_2)x. The RHS can be cleared up by differentiating once until you have something like:
e^(difference in lambda)x = constant times e^(lambda 1)x
So like, this necessitates lambda 2 being 0 💀
ooh update
"Where $\widetilde{W}{n}$ is of the same type as $W{n}$ (meaning with potentially distinct lambda tilde)"
Kerr
I would love some feedback on this attempted solution to the problem in attached screenshot:
For Helmholtz equation:
For Helmholtz equation:
$$
u''(x) + \alpha^2 u(x) = f(x), x\in [-1,1]
$$
With bcs = $u(\pm 1) = 0$.
We define $L(u) = u''(x) + \alpha^2 u(x)$, and $R = L(u) - f$ and $R_N = L(u_N) - f$.
We seek to find an approximation solution $u_n \in V_n$ where $V_n$ is the span of $\psi_i$, for $\psi_i (\pm 1) = 0$. By Galerkin's method we find $u_N \in V_N$ such that $(R_N,v)=0 \forall v \in V_n$.
Expressing as linear algebra problem:
$$
(u_N'' + \alpha^2 u_N - f, \psi_i) = 0, i \in 0,1,\dots,N
$$
With some manipulation we get:
$$
\Rightarrow \sum_{j=0}^N \hat{u}_j ((\psi_j'',\psi_i) + \alpha^2(\psi_j, \psi_i)) = (f,\psi_i), i \in 0,1,\dots,N
$$
We define $\mathbf{x}$ such that $x_i = \hat{u}j$, $\mathbf{b}$ such that $b_i = (f, \psi_i)$, and $A$ such that $a{ij} = \alpha^2(\psi_j, \psi_i) - (\psi_j',\psi_i')$.
As such, $u_N$ may be found by solving $A\mathbf{x} = \mathbf{b}$ for $\mathbf{x}$.
madlor
i used ChatGPT to check my answer, but it would be naive to blindly trust it to detect if i made an error
Where did the u hat j come from
madlor
its the coefficients in $u_N$ polynomial thingy
madlor
$u_N$ is the approximation to the sol for the PDE
madlor
When you write x i equals u hat j, should that be x j
You should probably write this somewhere
Hmm, i agree
i will make sure to mention that next time
does the rest look reasonable ?
For an exam, you should be clear about what part is the solution to 2a
Nice
This statement seems to useless then
Well, it is useful in proving that these functions actually form a Haar space. Induct on the number of lambdas
But it itself is a non proof
I never heard of a haar space. What are some interesting things about them?
I looked on wikipedia and it looks like a space with the property that there exist unique element that best approximate any desired real valued function
Yeah
Hello guys.
I'm currеntly studying Rombеrg Intеgration in numеrical mеthods and havе a quеstion rеgarding its application. In Rombеrg's mеthod, wе intеgratе using tеchniquеs likе thе trapеzoidal rulе and Simpson's 1/3 & 3/8 mеthods. My quеstion is, can wе choosе any of thеsе intеgration mеthods as a basе for Rombеrg Intеgration, or doеs Rombеrg Intеgration rеquirе spеcific mеthods? Additionally, how do wе dеcidе which mеthod to usе in thе contеxt of Rombеrg Intеgration?
you can use most basic left/right rectangles, trapezoid or midpoint rules
since romberg allows you to achieve arbitrarily high accuracy there's hardly any reason to use more complicated integration methods
Hi, sorry for double posting. I didnt realize university-level questions were meant to be posted in specific topic channels.
My question is, I am working with Lagrange, Hermite and Chebyshev interpolation schemes. I have verified that, when performing Lagrange interpolation, it is OK to first transform the X domain to the [-1, 1] interval for maximum precision. Same applies to interpolation with Chebyshev basis. Of course, for values of derivatives, there would be scaling constants.
However, I am now testing Hermite interpolation, and I do not get the same results if I first normalize the X values to [-1, 1]. Any idea why? thanks a lot in advance!
One thing to note, I am using the following formula for Hermite interpolation polynomial:
Could it be that normalization of X to [-1, 1] does not work because there are two terms being added (the 2 sums), and the effect of the normalization will be different in each term, so it leads to non-linear effects?
Thank you for your rеsponsе. To clarify, wе'll bе adhеring to thе standard rulеs and mеthods. Additionally, I'd likе to inquirе about thе origins of thе formula wе'rе discussing. Is it dеrivеd from thе trapеzoidal formula? I undеrstand its purposе is to approximatе thе arеa undеr a curvе, but I'm curious about its foundational dеrivation. Could you plеasе еlaboratе on this?
well I don't know about that particular formula, but another one is derived based purely on considering integral's exact value and it's approximation, regardless of how the approximation was computed
$U = \int_a^b u(x) \dd x = U_N + O(h^p)$ where $U_N$ is approximate value of the integral computed on the grid with $N$ line segments, $h$ segment length and $p-th$ order of accuracy
then you can compute the same approximation on two grids - original one and one that has $r$ times more line segments $\ U = U_N + c h^p + O(h^{p+q}) \ U = U_{rN} + c\left( \frac{h}{r} \right)^p + O\left( \left( \frac{h}{r}\right)^{p+q} \right) \$ where $q = 1$ in the case of left/right rectangles and $q=2$ in the case of trapezoid/midpoint rule
Transparent Elemental
now you can just subtract first equation from second and express the unknown constant $c = \frac{U_{rN}-U_N}{r^p - 1} \cdot \frac{r^p}{h^p} + O(h^q)$ and substitute it in the second equation $\ U = U_{rN} + \frac{U_{rN} - U_N}{r^p - 1} + O(h^{p+q}) \$ so now you have an approximation to $U$ with $(p+q)$ order of accuracy instead of $p$
Transparent Elemental
then you can compute U_{r^2N} and compute the new estimate with p+q order of accuracy by using previous value U_{rN} (not the higher accuracy estimate), and knowing estimates for U_{rN} and U_{r^2N} both with (p+q) order of accuracy you can compute new estimate for U_{r^2N} with p+2q order of accuracy by applying the same formula and replacing p with p+q
Okay Thank you for your detailed explanation on the technique,
but I have noticed that the step size is halved at each iteration (h to h/2, then h/4, etc.). Could you explain why the step size is specifically halved each time instead of being divided by three or another number?
How doеs this particular halving contributе to thе mеthod's accuracy?
Thanks for the Insight, so its the refinement of the grid whats important to improve the accuracy rather then the factor by which the step size is reduced;
these are the same thing since step size and number of grid points are inversely related
h = (b-a)/N where N is the number of line segments over [a;b] and h is step size
by dividing h/r you get that it's the same as (b-a) / (rN), so the number of line segments grew by factor of r
to get the number of grid points you just need to replace N with N+1
When implementing periodic boundary conditions, are the first and last points considered adjacent, or to be the same point?
It depends on how you're discretizing
My problem is just Poissons equation in 1D
2nd-order central difference
So, I have the governing equations at the endpoints,
$$
\begin{align}
&\phi_{-1} - 2\phi_{0} + \phi_{1} = \Delta x ^{2} \rho_{0} \
&\phi_{N_{x} - 2} - 2\phi_{N_{x}-1} + \phi_{N_{x}} = \Delta x^{2} \rho_{N_{x}-1}
\end{align}
$$
where $j \in [0, N_{x}-1]$
Quantumfluxcapacitor
Compile Error! Click the
reaction for more information.
(You may edit your message to recompile.)
Where are the x_i located
They are coincident with the \phi_{j}, meaning the \phi are defined at the gridpoints
What is the coordinate of x_i
Ok so because it's periodic, phi(-pi)=phi(pi) right
x_0=-pi but your indices only go up to N_x-1 which is at (N_x-1)/N_x*pi
So the last and first point are adjacent in your case
Wouldn't this imply that they are the same, however?
You don't have a point at pi
If your j indexed from 0 to N_x then x_(N_x) would be at pi
\Delta x = L / (N_x - 1)
Oh in that case then your first and last point are the same point
which means that x_{Nx-1} = pi
Yes
Okay, I understand, thank you
So, this means that \phi_{-1} = \phi_{Nx-2}?
Yes
Hello guys, I have a question on Gauss-legendre quadrature interval of integration.
I understand that the standard interval for a two point Gauss legendre is from [-1,1], but what if the integral was from [a,b] and its not from [-1,1]? How do I transform my integral to fit the [-1,1] interval?
How do you map the interval [-1,1] to [a,b]?
Well we have to use change the variables using the x= ( ( (b+a)+(b-a) ) xd ) /2
Oh ok
apparently this is how we got this equation for finding x
Well I understand that guass-quadrature is for polynomials, but i dont understand why is it only for the intervals of [-1,1]
It isn't
You first define it for [-1,1] then use these transforms to define it on intervals [a,b]
Oh okay, so we transform the interval [-1,1] to our given polynomial integral interval [a,b]
but how do we transform the intervals from [-1,1] to [a,b]?
?
Like for example here we are given a function from [0,0.8],
we are gonna integrate this function from [-1,1], and then we need to transform the interval [-1,1] to [a,b] right
Yes
What part are you confused by
You could just use vandermonde matrix for interpolation in part a)
Do you just use divided differences
You can use whatever you want to find the interpolating quadratic
I have the following 3rd-Order Runga-Kutta method for autonomous equations (t-independent) that I stole from sciencedirect.com/science/article/abs/pii/002199919190238G?via%3Dihub
$$ f(u) = \frac{du}{dt} $$
$$ u_{i + s_1} = u_i + \Delta t \left( \frac{8}{15} f(u_i) \right) $$
$$ u_{i + s_2} = u_{i + s_1} + \Delta t \left(-\frac{17}{60} f(u_i) + \frac{5}{12} f(u_{i + s_1}) \right) $$
$$ u_{i + 1} = u_{i + s_2} + \Delta t \left(-\frac{5}{12} f(u_{i + s_1}) + \frac{3}{4} f(u_{i + s_2}) \right) $$
jacobjivanov
I need to expand this to be applicable to non-autonomous equations. Would the following Butcher Table represent it?
No
This is not correct at any rate
How so?
u_{i+1} should equal u_i + some stuff
Maybe my notation is a little wierd, but I've confirmed this with my own convergence tests
Where is the 3rd order convergence line
If fully expanded out:
$$ u_{i+1} = u_u + \Delta t \left( \frac{3}{4} f(u_{i+s_2}) + \frac{1}{4} f(u_i) \right) $$
jacobjivanov
Probably something I should include. I guess I should say, I proved convergence, not necessarily 3rd order convergence
I'm also not completely sure how to find the nth order convergence line.
Plot 1/N^3
The longer one with N going as high as 10^6 takes a minute or two to run so I just cut it off
You also generally don't need so many data points
Is it this simple for any order?
You can usually just take dt=0.1, 0.05, 0.025, 0.001, etc...
Yes
You can multiply by a constant to make your graph look nicer as well
Fair. I'm defining G = np.arange(5, 100) ** 2, and then for each point, N = G[i]
What do you mean?
But back to my original question, would this Butcher Table be representative of this Runga-Kutta method and work for non-autonomous equations?
You can plot any constant/N^order
The RK scheme presented has no information about the c_i you would have along the left side of the table
Is there a reason you want to use this RK3 scheme
I used the following to determine the $c_i$ values:
$$ \sum_{j = 1}^{i - 1} a_{ij} = c_i \quad \mathrm{for} \quad i = 2, \dots, s $$
jacobjivanov
This came from the Wikipedia page for Runga-Kutta methods, with the caveat that this is "neither sufficient, nor necessary for consistency", which is why I wanted to double check here.
I am using the RK method for an incompressible flow simulation for my research. Previously, my RK method relied on the fact that my equations, namely, the following, were autonomous.
Initially, our Vorticity-Evolution Equation is as follows:
$$ \frac{\partial \omega}{\partial t} = \nu \left( \frac{\partial^2 \omega}{\partial x^2} + \frac{\partial^2 \omega}{\partial y^2} \right) - \left( u \frac{\partial \omega}{\partial x} + v \frac{\partial \omega}{\partial y} \right) $$
By using discrete spectral methods, i.e $\Omega_{\mathrm{pq}} = \mathrm{fft2}(\omega_{\mathrm{ij}})$, our equation becomes:$$ \frac{\partial \Omega_{\mathrm{pq}}}{\partial t} = \nu \left( \frac{\partial^2 \Omega_{\mathrm{pq}}}{\partial x^2} + \frac{\partial^2 \Omega_{\mathrm{pq}}}{\partial y^2} \right) - \mathrm{fft2}\left( u \frac{\partial \omega_{\mathrm{ij}}}{\partial x} + v \frac{\partial \omega_{\mathrm{ij}}}{\partial y} \right) $$By using an integrating factor $\mu_{\mathrm{pq}}(t) = \exp \Big[\nu \left(k_p^2 + k_q^2\right)t \Big]$, our equation becomes:$$\frac{\partial}{\partial t} \Big[ \mu_{\mathrm{pq} }(t) \Omega_{\mathrm{pq}} \Big] = - \underline{i} \mu_{\mathrm{pq}}(t) \Big[ k_p \cdot \mathrm{fft2}(u_{\mathrm{ij}} \omega_{\mathrm{ij}}) + k_q \cdot \mathrm{fft2}(v_{\mathrm{ij}} \omega_{\mathrm{ij}}) \Big]$$As a result, our time derivative $\Big[ \mu_{\mathrm{pq} }(t) \Omega_{\mathrm{pq}} \Big]_t$ is no longer autonomous.
jacobjivanov
Unfortunately, I take a numerical/computational methods course next semester, so I'm kind of running blind, though my middle equation has been successfully integrated over time
Problem being it is slow
Is it in python
RK3 is the minimum required for stability
You could totally do the normal RK4
It is, but it is JIT compiled with numba. Additionally, the goal is to translate this to C eventually
This method is also low-storage. You don't need three seperate k variables, and can overwrite the first with the third
I'm not entirely sure yet, if I'm being honest
It almost certainly is not
But if I have 512x512 arrays for vorticity, x velocity, y velocity, streamfunction, various partial derivatives, ... etc, then why not?
512x512 is not very much
512x512 runs on my laptop. I have access to an HPC, but have not done anything with it yet
That's actually quite small
Let's say you have 10 different 512x512 arrays of doubles
That's only 5 megabytes
Hold up, I need to go. Do you mind if I ping you when I get back. No issue if you don't respond immediately.
Ok
My time derivative routine has 11 intermediate variables, all the same size. The RK method will have 4 additional intermediate variables, or 6 if you don't overwrite.
But even if low-storage isn't necessarily a huge selling point, wouldn't the RK4 be more computationally expensive?
What advantage would I get if RK3 is stable?
Smaller error
Not necessarily, the intermediate steps are simpler as well
How so?
If you look at the butcher tableau for RK4, it's diagonal
But, back to my original question, did I correctly represent the auto-RK3 in this Butcher Table, and is it consistent?
Someone know a good treatment of generalized gauss quadrature? As in, finding a choice of points and weights that can exactly integrate functions with weight ($ \int^{1}_{-1} w(x)f(x) dx$)
Im looking for a comprehensive guide of on how to apply either an rk4 method or adams-moulton 4th order predictor-corrector to a system of two ordinary differential equations, and if possible how to translate that to python?
What are your conceptual questions?
Once all of those are answered, #computing-software for the implementation
ig conceptually kinda ties into what i need help with implementing as well, when applying either of those methods to a series of odes, do you just apply them both separately and then just plot them both next to each other because thats kinda what some of these implementations have been doing more or less but i dont think thats right
Sir John
Why do you need to divide by u?
i need to somehow express the ghost value outside the domain to get the diffusion at boundary
when i apply this bc, the only ghost componend in discretization comes from the first derivative in advection term dV/dx using central difference, expressinng it divides by u, which can become zero at some point, due to flow in both directions
You don't need a ghost value outside to compute the second derivative
keep scheme low order?
You can use an asymmetric finite difference
im trying to keep it second
There is an asymmetric finite difference of second order
you mean one-sided derivative backwards into the domain?
Yes
it messes up my Mass matrix which normalizes the system and makes it symmetric
since my grid is non-uniform, hence L matrix is assymetric,
then i need to somehow normalize it, i multiply whole momentum by diagonal mass matrix M, which also normalizes the gradient operator for pressure, which has to be integer
it's a bit complicated, lemme show some typeset notes
this hat M together with inv(R) make laplacian symmetric and nice
also its inverse helps to express the gradient matrix in a nice form with integer coefficients
sorry for so much info 😦
this thing i didnt check exactly, but looking at the denominators of Gradient, using one-sided difference will indeed mess up the symmetrization process for Laplacian 😦
example i used to construct Gradient from the above system
i think the workaround might be using uniform grid in the direction of the outlet, and only refine the grid in direction parallel to outlet, then i think using one-sided derivative could be an option
i checked the algebra, if i use one-sided then matrix becomes assymetric. maybe this can be a trade-off idk :\
I'm a bit rusty on RK but what is it supposed to do exactly?
I seem to remember that you might start getting the initial nodes with RK but then once you have enough to run predictor corrector then you run that. I'm not sure if that's what you're referring to and I hardly remember the algorithms
I DONT UNDERSTAND QUSTION
Do you know what the nonlinear finite difference method is
YES BUT I DONT UNDER STAND 🥹
I have never heard of a linear and non linear version of finite differences. Got a link/book that explains this?
I haven’t either lol
linear is when the function is approximated by a line, non-linear - by polynomial ?
Derivatives are linear though
maybe there is some strange non-linear apxmation? D:
The derivative is the best linear approximation to a function
Just like
By definition
there is no such thing (as far as I know) and google only gives sporadic msc theses of people who just solve nonlinear systems discretized with fdm and newton
i downloaded the book, indeed it is just fdm + newton
Well today I have to finish my fft report and give a presentation on it
Hope it turns out OK 🫥
Hello, for LU decomposition when we say
Solve linear systems Ax_i = e_i, (1 ≤ i ≤ 4) where e_i is the ith vector of the canonical basis of R4
What does that mean ? I certainly know how to do it, but I don't know how to formulate the question like this
How is LU decomposition useful in this question?
You use LU decomp to solve systems of linear equations
Yes I know
But what is e_i and x_i here ?
can you write it in vector please?
like (.., ... , ..., ...)
?
The exercise does not require solving the linear system for 4 different vectors, that makes no sense
I do not understand what you are saying
It's like doing the LU decomposition for 4 different vectors in same exercise , what's the point?
And
I have other question about an exercise
Discrete Laplacian matrix : How to show that det(A_n) = 1 for all n, here ?
And they say "Deduce, using the profile of the matrix A_n, the LU decomposition of An = L_n U_n.""
What do they mean by profile
Probably they mean "structure"
hint L and U will both be Toeplitz
use https://en.wikipedia.org/wiki/Leibniz_formula_for_determinants + look at the determinant for n=1, 2, 3 of the pure Toeplitz with -1 2 -1 and notice the pattern
It's an algorithm for finding the inverse of the matrix A, the x_i are the columns of inv(A), if you solve for each e_i.
You find the LU decomposition of a matrix A, not an LU decomposition for one or four vectors. The exercise tests if you know the point of an LU decomposition and that you can use back-substitution to solve the matrix equations. If you carry out four LU decompositions, the teacher can see you don't understand the point of (a).
(b) does seem to ask you to do what you think it is not asking you to do. If your belief contradicts the plain wording of the question, you are blocked.
I agree profile is synonymous with structure here. In particular, the structure is tri-diagonal so a simple structure to work with.
I don't understand how they got to the formula I highlighted in blue. Can someone explain to me please?
Multiply the inequalities at the end of the previous line together, then rearrange
ok thank you
Hey
Numerical interpolation and integration : Calculate in two ways (by solving a linear system or integrating polynomials
of Lagrange interpolation) the weights α, β, γ of the following quadrature methods:
Do you have f(x) ?
No in this type of exercise, it does not give f(x)
but if you ask the question, I think you are not familiar with numerical interpolation/integration
Are you looking for values for alpha and beta?
for the first one set up the system and get the linear equation (since you have 2 nodes), extrapolate to x=0 and 1 and use trapezoidal rule? Once you have done that you will see that the solutions is rather obvious. For second one use a quadratic, and do the same but use simpsons
For the system method we do that :
But I don't understand how the ingral of t² dt is alpha / 16 + beta / 4 + 9theta/16
I don't understand how they determine the integrals
just evaluate t^2 for t=1/4 2/4 3/4
2/4 ?
2/4=1/2
I make three separate integrals with three values of t different?
why do they add?
or t_0, t_1, and t_2
t = t_0 + t_1 + t_2 ?
f(t)=t^2 int(f(t))=alphaf(1/4)+betaf(1/2)+gammaf(3/4)
ok I will do that, thank you
so it is just alpha(1/4)^2+beta(1/2)^2+gamma(3/4)^2
just setup the vandermonde matrix and solve the system
He ask the order
of the method
They say that it is at least 1 for the system method and at least 2 for the Lagrange method
first one is 2nd order and the second one is 4th order
just like trapezoid and simpsons
it is just simpsons with slightly different coefficients and evaluation points
and simpsons is 4th order
You can't know that just by calculating the values? Do you have to remember that this is the Simpson method?
i used another way to find the coefficients by using simpsons 🙂
you can derive the order the same way as you do with simpsosn
I do not know how to do
i did: ```>> ceffs=[1 1/4 1/16;1 1/2 1/4; 1 3/4 9/16][f1;f2;f3]
ceffs =
3*f1 - 3*f2 + f3
16f2 - 10f1 - 6f3
8f1 - 16f2 + 8f3```
and evaluated simpsons (so x=0, 1/2 and 1)
and tat gave the correct alpha, beta, gamma
(same as you)
You use another method to determine alpha, beta, theta, this is not asking here
the questions are related and they ask us to deduce from what we did
h =
(8*f1 - 16*f2 + 8*f3)*x^2 + (16*f2 - 10*f1 - 6*f3)*x + 3*f1 - 3*f2 + f3
>> (subs(h,x,0)+4*f2+subs(h,x,1))/6
ans =
(2*f1)/3 - f2/3 + (2*f3)/3```
bn I don't understand anything, I don't know that it represents all that, it doesn't help me to understand
no matter
thank you for your help for first question!
you have 3 data points, you have a quadratic equations approximating f(x), then you can do a standard way to show what order it is (will be like simpsons but some other constant term, worse than for simpsons)
the course tell us :
We say that a quadrature formula has a degree of precision n if the formula is
exact for f(x) = x^k (0 ≤ k ≤ n), but not exact for f(x) = x^(n+1)
one usually say that trapezoidal rule is of "order" 2 since the error term is O(h^2) "degree of precision" is not the same thing
trapezoidal rule will exactly integrate f(x)=c0+c1x
We have that with Lagrange method, we know the value of alpha, beta, theta. How to know the order?
and simpsons f(x)=x0+c1x+c2x^2
simpson is Newton-cote method
Newton-cote for n= 2 is simpson
here we talk about Lagrange
you can derive one from the other assuming f(x) is quadratic in this case
how do we derive this?
the error? google proof error bound quadrature rule
the order of the method is given by the bound of the error
if error is O(h^2) then the method is second order
here you have an example of a proof for right riemann https://math.stackexchange.com/questions/3074180/right-riemann-sum-error-bound-proof
but they maybe ask you for "degree of precision" and not the order. then it is 2 for the second one
since it will exactly approximate a quadratic equation f(x)
(by construction)
I don't want the proof
but you didn't tell me that the error was that, I was able to find it
remains to understand how to use it
in this case
Claymore
You will probably get better answers in the physics server, linked in #old-network
Quadrature method using derivative_
Let f ∈ C^1([0, 1]). We consider the elementary quadrature formula:
where ξ ∈ [0, 1] and w0, w1, w2 are real numbers. We pose
Questions
- Determine the parameters ξ, w0, w1, w2 so that the quadrature formula is exact if f is a polynomial of degree less than or equal to 3
-> It's done. no problem
- The parameters ξ, w0, w1, w2 being thus fixed, calculate E(x → x^4) and deduce the order of the method
We deduce the order of the method
E(x -> x^4) = 1/30 which is not equal to 0 so the method is of order at most 3.
My Question
Why did finding something different from 0 mean that the method is at most of order 3?
Where does this 0 come from, what is the comparison with?
In this case the order is defined as the highest degree polynomial that the scheme can exactly integrate
You want to integrate something exactly
So you compare the exact value with the approximated value
And want that to be 0
yes but the exact value and the approximated value, is not 0
I don't have a 0 in either
I followed the chatgpt method but gives me nonsense
this annoys me
The difference should be 0
ok thank you
If I am given the following Butcher tables, how do I determine the writing of the Runge-Kutta scheme ?
I will take the example of the first
On the internet I see they say :
I found (in my case I consider x_n = t_n) :
k_1 = hf ( t_n + h/4 , y_n + k_1 / 4)
k_2 = hf (t_n + 3h/4 , y_n + k_1 / 2 + k_2 / 4)
y_(n+1) = y_n + 1/2 (k_1 + k_2)
I compare that to what they find in the solution to my correction:
It's completely different..........
@warped heath what would be easiest or most helpful here
i wonder if we should just start from your table and work forward
I have already done everything, I followed the theoretical formulas
I don't find the same thing as in my correction
are you certain they are different and not just a slightly different way of writing the same thing
i guess yea
i really think its easiest to just start over
Did I make a mistake in the calculations?
if not, even if I start again I will not write different lines
im going to have to do it myself to figure out if yours is wrong im too dumb to look at it and spot the error between the table and 2 different answers
so if im gonna do it we might as well both do it
unless its helpful to you if i disappear for 10 minutes then come back and say i got the answer here
As you wish
I have the impression that my K1 and my K2 and their K1 and their K2 are different formulas...
for K2 they have two f(....)
in this formula, only one f
well I don't understand where the differences come from, why and how to find the same results
maybe @wide spear if you know
damn it makes me sad it makes me waste so much time on my revisions...
Which message should I reply to?
.
For this table, your equation is going to be as follows:
Well actually this Butcher Table isn't correct
Either you need an additional row of zeros on top and right edge, or it doesn't make sense
Ok that's good I understood how they did it
Impossible that it is not correct
So I calculated the relative condition number of $\frac{x^4}{x^2-1}-x^2$
for $\x > 1$
adonhs
which is $k_{rel} = \frac{2}{x^2-1}$ and also calculated when it's bad/good conditioned.
So it's good conditioned for $k_{rel} < 1$ so i got $x \geq $\sqrt{3}$ and othwise $1<x<\sqrt{3}$ but looking at the graph it kinda doesn't make sense to me how it's good conditioned for $x \geq \sqrt{3}$ than for $1<x<\sqrt{3}$ as the functions are more close for $1<x<\sqrt{3}$
adonhs
Compile Error! Click the
reaction for more information.
(You may edit your message to recompile.)
** ~ ~ ~ TAYLOR-TYPE SCHEMES ~ ~ ~**
We propose to study the following new scheme (called Mixed Runge-Kutta Taylor)
Question 1 : Show that G_3(t, y, h) = T_3(t, y, h) + o(h^3) where T3 is the function associated with a Taylor scheme of order 3 (yn+1 = yn + hT_3(tn, yn, h))
Answer
Let's apply Taylor's formula to f 1(t + h / 3, y + h / 3 f (t, y)):
-> What I don't understand is why in the penultimate line we do the Taylor expansion up to order 2 and not up to order 3 and I don't understand how they go from order 2 to order 3 as in magic?
**Question 2 : Under good assumptions about f, show that the Mixed Runge-Kutta scheme Taylor is stable. What is its order of convergence ? **
Answer
-> Here I don't understand how by making the difference how they find this, I have the impression that some steps are missing... I don't see where this result comes from
Not many people on this channel 😦
I'm here, but I can't answer any of the questions. 😦
@warped heath h/2 is being multiplied with f^1 (t + h/3, y + h/3 f(t,y)), so after expansion of f^1 (t + h/3, y + h/3 f(t,y)) upto O(h^2), multiplication by h/2 gives O(h^3)
help me with 3a) ...
i can't understand what they are trying to say via that "Hints"
thank you
Hey Sorry
I've been at this for several days, I don't understand
Gauss-Legendre quadrature method
Question 1 : Show that there exist unique reals α, β and γ (and explain them) such as the method quadrature is exact for polynomials of degree ≤ 2
For this question, no difficulty, I answered. We have α = β = 5/9 and γ = 8/9
Question 2 : Show that this quadrature method is in fact exact for polynomials until degree 5. We can carry out a Euclidean division by the polynomial 5X^3 −
3X and calculate ∫ (5x^3 - 3x) x^j dx from -1 to 1 for j ∈ {0, 1, 2}.
For this question, no problem here too. We see that ∫ (5x^3 − 3x)P(x)dx = 0 from - 1 to 1 for any polynomial P of degree ≤ 2
Let Π be a polynomial of degree ≤ 5. By performing a Euclidean division, we can write : Π = (5X^3 − 3X) × P + R where P and R are polynomials of degree ≤ 2. We then have
(Q = R here, is the same) Moreover :
But, J((5x^3 − 3x)P) = 0, because the polynomial 5X^3 − 3X cancel at the three points 0 and ± sqrt(3/5), and J(Q) = ∫ Q(x)dx from - 1 to 1 because Q is of degree ≤ 2. We finally have
-> This last result I understand a little less but it doesn't matter
Question 3: **Using a Taylor formula, show that there exists a constant C > 0 such that if f is of class C^6 then **
Here several things I don't understand in the correction, already in the development of the Taylor formula, I am not familiar with the last term "sup". I saw in Taylor's formulation with integral remainder and it's not written like that, so I'm a little difficult to understand. And I don't understand why K(x) ?? What is that ..
Second thing I don't understand, why it is lower than these terms. Where does this expression of J(R) come from, where does this expression of the integral of R(x)
Question 4 : ** Give a quadrature formula J[a,b] derived from J allowing us to approximate ∫ f(x) dx from a to b and show **
here the answer, the last line I don't understand also
Sup stands for supremum, which is generally introduced in real analysis. https://en.m.wikipedia.org/wiki/Infimum_and_supremum#:~:text=The supremum (abbreviated%20sup%3B%20plural
In mathematics, the infimum (abbreviated inf; plural infima) of a subset
S
{\displaystyle S}
of a partially ordered set
P
{\displaystyle P}
is the greatest element in
P
{\displaystyle P}
that is less than or equal to e...
Ok, then I don't understand the confusion
I said that its presence in Taylor's formula is not familiar to me
but I understand this point, now
All I need is to understand the other 4... 😒
What is your question?
I want to build a Butcher table with this scheme. The correction says that:
intermediate states:
intermediate times:
I need to understand, the coefficients in bold, why in y{n, 2} there are 1/2 before f (t( {n,1}, y{n,1}) and not 0 and we can put 1/2 before f (t( {n,2}, y{n,2}) ? Why in this order ?
$y_{n,2}$ is the y value plugged into the recursion you sent first
Xenophon
You can see that it's being estimated by a Euler step with h/2
So that 1/2 and 0 just lead to the scheme you wanted
i.e. $y_{n+1}=y_{n, 1}+hf(t_{n,2}, y_{n, 2})$
Xenophon
You could change the order, and put the 1/2 in front of the $f(t_{n,2}, y_{n, 2})$, but that would lead to a different Butcher tableau
Xenophon
It would be an implicit method, for one
That's not the question I asked...
this is not true
you did not understand the exercise and the solution they give
andfrom this last line b_1 = 0 , b_2 = 1 which gives the formula
Anyway, these are numerical methods, It's a bit boring to explain, these are methods to follow that you need to know
I renew my request, since the question has not been answered
I want to build a Butcher table with this scheme y_{n+1} up. The correction says that:
intermediate states:
intermediate times:
I need to understand, the coefficients in bold, why in y{n, 2} there are 1/2 before f (t( {n,1}, y{n,1}) and not 0 and we can put 1/2 before f (t( {n,2}, y{n,2}) ? Why in this order ?
Yes, it literally is true from the equations you sent.
The recursive update you sent first is the explicit midpoint method
Here's the butcher tableau
This is literally the equation I sent you
You may need to make the question more clear
Everything you've sent is just the midpoint method with nothing really confusing about it
These coefficients in bold are the entries of your A matrix
These coefficients are the entries in your c column
These coefficients are the entries of your b row
You don't need to explain. I know about butcher tables and RK methods. You might want to read the answers you get more carefully. You had a similar problem when you asked about integrating a taylor polynomial. Riemann tried several times to explain it, but you didn't take the time to try to understand the explanation
I'll try a different approach. I think you're saying that the equation should/could be $y_{n,2}=y_n+(h/2)f(t_{n,2}, y_{n, 2})$
Xenophon
But you can see that this equation involves $y_{n,2}$ on both sides. This would be a implicit RK method, and you would have to solve for $y_{n,2}$.
Xenophon
This is not the equation you sent because you wrote that in the $y_{n+1}$, the fact that there was $y_{n}$ came from $y_{n,1}$ when it is literally false. Besides, that's not even the question I'm asking.
I appreciate your willingness to want to help me, but if you don't know something, I prefer to wait and even not having an answer, it doesn't matter
Bueno
$y_{n,1}=y_n$
Xenophon
from this
compare this to what I sent
I'll explain to you why
They are the same
It's just luck, because in this case y_{n,1} = y_{n}, and you cooked the thing, but that's not why we found this result, I'll explain to you why
It's not luck
...
I knew that one of the intermediate states was y_n
Yes, that's the general equation
That's specific to your question
Do you see how my equation comes from the butcher tableau for the midpoint method?
I do understand dude.
If my use of this confused you, then I'm sorry
But you're asking for help and being combative. You haven't actually asked a question
Just a vague sense of confusion about the coefficients
But it's not confusing, the equation that is written there is false, and what's more, it's not even my question and with this discussion we drown out my questions and I will still be left with an unanswered question because the others will not see the statement
It is not false. It is the same recursion relation that you said you wanted to reproduce
You haven't actually asked a coherent question in english
The order is simply read from the butcher tableau
It's all by definition
I will explain more simply, the y_{n} that you see outside the function f(...) is not y_{n,1} if you assume the opposite it is because you are pretending to understand
and here is what you write
What is $y_{n,1}$ in terms of $y_n$ then?
Xenophon
I will explain a second simpler thing
I took a completely random example from a website, you see there is a y_n here too
and is not kn1
Yeah? and? I wasn't making a general claim
In your case, in this method, $y_n=y_{n,1}$
Xenophon
That may have been confusing to you, but it's not false
I give up
I have read that website, btw, and those k values are not equivalent to the intermediate y values you are using in any context
I'll try one more time with this. I simply used the fact from the first equation here that $y_{n,1}=y_n+h*0=y_n$ and put the recurrence relation in terms of the intermediate values. If that's confusing, don't worry about it
Xenophon
Since they are equal in this case, you can just as easily use y_n
I found another very good example
don't waste your time with this guy
In this example, y_{n,1} is not = y_{n}
and you find the term y_{n} in y_{n+1}. The formula you give y_{ n+1} = y_{n,1} + h..... is not true. Yes y_{n,1} = y_{n} in the case of my exercise, but pure "luck" because let's admit that y_{n,1} is equal to another value, well we wouldn't write y_{n+1} = another value + h .... we would always write y_{n+1} = y_{n} + h... It is not because y{n,1} = y_{n] that we write y_{n+1} = y_{n} + h....
This is exactly what I'm trying to explain, but apparently I'm the one talking nonsense
Yes, because in this example the butcher tableau is different
It's not really important for the method you started with because, as I've said, they happen to be the same.
This one, for example, is implicit.
And y_{n,1} is not the same as y_n. It would have been more conventional to use the standard notation, and I'm sorry for causing confusion
But it's not a big deal
This kinda looks like TSP (right?).
In this problem, 1 and 20 are hospitals. Each green node is a city.
I was asked to find the shortest route possible for each hospital to each city, and also back.
For example, if I'm an ambulance guy in hospital 1 and I want to take patients from city 2, I'd go from hospital 1 - city 2 - hospital 1, using the same route twice, since that's the shortest route possible for this case (not hospital 1 - city 2 - city 3 - hospital 1).
How do I approach this problem?
(Note that if a route from hospital 1 to an arbitrary city and back to hospital 1, if and only if hospital 20 is in the route back to the hospital 1, the patients are put in hospital 20 instead of hospital 1)
You could compute the minimum distance from each hospital to each node using the directly connected nodes first, then the ones connected to those nodes, etc. The problem also appears to be symmetric (return route same as route out) since the edges appear to bidirectional
is it okay if I post a quick question in here?
can't seem to get help in the help section
I have a problem iterating this
since f(xL).f(xM) = 0 and that means I should stop the iterations
Do you know the error bound for the bisection method
error bound?
Yes
what's that
Are these the same thing? I'll be studying scientific computing next year (computer science major), I was thinking about taking numerical analysis as an elective as I want to study data science & AI next. But I'm not sure if the two courses are on the same topics or not.
SCIENTIFIC COMPUTING
Machine numbers and arithmetic, error analysis. Nonlinear equations. Review of linear algebra: norms of vectors and matrices, scalar product. Solving linear systems of equations with direct methods. Approximation of data and functions: polynomial, piecewise polynomial, trigonometric and FFT interpolation, spline functions; Parametric splines and Bezier curves and B-splines. Solution of overdetermined linear systems and least squares: the normal equations, the QR method and the SVD singular value decomposition. Some applications of SVD.
**
NUMERICAL ANALYSIS**
Analysis of errors in computational processes: inherent and algorithmic error, conditioning of computational problems, machine numbers and operations, algorithmic error analysis, forward stable, backward stable, unstable algorithms.
Numerical linear algebra: vector and matrix norms, matrix calculus.
Notable algorithms for solving linear systems. Remarkable matrix factorizations. Spectral and singular value decomposition. Iterative methods based on stationary linear iterations. Least squares problems.
Numerical resolution of nonlinear equations and systems.
Numerical Analysis is not the same thing as Scientific Computing. I can see the confusion as the descriptions suggest a lot of overlap. Typically, I expect to see more scientific applications mentioned in Scientific Computing.
do you think it's worth to take as an elective or should i pick something else since there seems to be some overlap?
because if they're just slightly different, i could just study the extra stuff on my own
what is your end goal. a phd and more theory or go into industry?
Generally speaking, I would recommend to direct your learning according to the topics you are interested in (because you will find success easier in topics you like) and considering the lecturers teaching the modules (as you will learn more easily from a person who teaches in a way suited to you as an individual, and you may be able to collaborate professionally on projects in the future).
I also agree it's useful to have in mind what you may do in the future, although some people don't have a good idea of that at certain points of their life and career (indeed, it's good to reflect and reevaluate at all stages and ages).
If you end up liking both topics, it's fine to do both. If you find too much overlap and redundancy, it's also fine to drop the one you find less useful overall.
Well, i'm still just in my first year of my bachelor so i don't really know. I think I'd like to get a masters in AI & Data Science as I love math and they involve much of it compared to other career paths such as software engineering. I've read on the internet that useful topics to study for Machine Learning are Probability, Statistics, Analysis I, Diff Eq, Linear Algebra, Graph Theory, Num Analysis, and Optimization. All of these except the last two are already in my program curriculum, and I can choose up to two courses for a max of 12 credits from other degrees to do as electives. I was thinking about numerical analysis (6 credits) and optimization (6 credits) but I'm not sure. Analysis II and Abstract Algebra also seem interesting but they're both 12 credits each so I can only choose one of them
I think in the future I will study all of these for pleasure on my own anyway but right now I want to optimize my chances to enroll at a good masters program and know the math that is required
if you're in your first year, you have way too much time to be worried about this imo... go meet with the two profs and see which one you like more (for scicomp and numanal). aside from the least squares stuff, most of the material covered from those two classes aren't used by the majority of data sci/ml people. both will help with mathematical/programming maturity and 'applied' problem solving though, which is great
Sadly once I pick the electives I want to do I can't drop them, and I can only choose up to two of them. I want to study Data Science & AI in the future.Thanks for your comment!
I must choose within september of this year, anyway, what would you say are the most relevant math topics in ML?
great, so you can go talk to your profs next time you're in the department. and i could just regurgitate the standard "calc, LA, stats", but then i feel you'd only take those classes. you should take any modeling/scicomp/opimization classes offered throughout your ug, in addition to that calc/LA/stats core
also, it depends on whether you want to be in a more research heavy job or not. the more researchy the role, the more mathematical foundation you need
I think it would be cool, but still, I'm just in my first year, so I don't know yet. Although I might not directly use it in the future, studying math can always be useful 😄 , so idk, I've still got some time to choose... thank you by the way!
All I know is that I like math and I like studying so I wanna continue my studies, and do atleast a masters. I don't wanna end my bachelor and go do a generic software engineer job
I have a problem to deal with:
Given constant $s$, $N+1$ interpolation points (I'm not quite familiar with the English terms) $(t_j,y_j),j=0,1,\cdots,N$ with $t_j=\frac{j}{N}$, $0=y_0<\cdots<y_N=s$, and $y_{j+1}-y_j<K/N$, I need to find a $C^5$ (smooth if possible) function $f:[0,1]\to[0,s]$, with boundary condition $f^{(m)}(0)=f^{(m)}(1),m=1,2,3,4,5$, while also satisfying the data points above, and has its first five orders of derivatives bounded by a constant independent of $N$.
CollinGao-Original
K is another constant btw
ignore this problem, i proved the converse
okay just a quick something, when i'm using the bisection method, I index the iterations right? I write the iteration number in the table I'm doing, well I've seen some people start with the iteration indexed 1, while I start with the iteration indexed 0, because in my head I'm thinking that I already have the initial values and since I'm using the bisection method I'm already gonna be doing at least one iteration so the initial should be 0, but then a friend of mine said well we're searching for the root, which can turn out to be found through the initial values if f(xM) = 0 so it would make sense to start from index 1, so I'm here to ask about which index I should start with
I don't think this matters, but it seems more conventional/common for the index/iteration counter to start at 0.
yes thank you very much
If anyone could point me to a basic example of an Exponential Integrator that "only requires evaluating your integrating factor and related functions at times on the order of the integration step size", I would greatly appreciate it.
ould someone please help me understand how to do the following questions? thanks
I understand a, however b and c are confusing me
what is confusing you about them
i think i understand a bit better, however t he following question is confusing me
what does it mean by the "true values"
Does someone study computer science and has survived numerical from the first time?
because it's really difficult
Idk if this is more physics than math but,
Suppose I did an experiment where I measured current in response to voltage changes.
I now have the values for the current and their uncertainties (different for each point), and also the voltage (neglectable uncertainty). I used a linear regression. How do the uncertainties of the current propagate to the slope and the intercept estimates?
Page 13 is the most relevant to your question
This is more of a statistics question than numerical analysis though
Explicit formulas for the errors in the intercept and slope are given in equations 6.61 and 6.62
Thank you!
You're right, I should have asked in a different channel. But thanks~
i got 678.5--- ,hence 678.6 by adding the approx values .
now i don't know if it is correct,i might get the problem wrong .
correct me and tell me how to proceed forward .
helpers ping is not meant for use outside of help channels
elementary questions are intended for the help channels
The advanced channels are intended for high undergraduate and graduate level material, not pre-uni stuff that may happen to have a similar name
(This is not meant to be rude btw, just indicating that this isn't quite intended for it and isn't where you'll get an answer quickly)
Yep if you add the values given you will get 678.568, which should round to 678.6 (the answer key has this written incorrectly). The absolute error is the difference between the two which is +0.032, as written in the answer key
thanks for the verification.
i actually did that for 3 days ,but no one cared to answer ....so i did it .Nevermind ,sorry .
would be careful ☮️
A quick question, does gauss seidel method require the system of linear equations be always diagonally dominant?
this is when you can guarantee convergence
Ok
Ah, this place is not for programming side of things, right
Like optimizing a mathematical computation
Hi i have a question regarding the finite element method
We have the theorem that says error is bounded by h^2. I'm testing my own implementation on the Poisson equation in 2D using the error measure
E=max |u_hat-u(x,y)|
i.e im just taking the difference in my nodes
this gives a proper convergence factor of 2 for the case of the function u=x^2y^2, however for u=x^3-x^2*y+y^2-1
i get very small error no matter the size of h
can someone help explain why this happens?
An error bound can be pessimistic for a particular problem, if that's what you're confused by. If you're asking why that particular function has such small errors for your implementation, that's beyond my paygrade.
The explanation would depend on how you have discretized your domain, the elements you have selected, the nature of the solution, and how the error is calculated.
You've specified the max of the error is low for the nodes but it might be very bad everywhere else and using other ways of evaluating the error (e.g. involving integrals).
It sounds like the chosen elements are able to interpolate the true solution well at the chosen nodes but this might not be true for all node distributions, all elements used, or all error measurements.
The derivatives of the solution might also compare badly to the derivatives of the true solution.
Off the top of my head, I think the error bounds should specify the general behaviour as h varies but may not explicitly indicate what the constant of proportionality is, so the error should be looked at with regards to how it varies with h, and absolute values of the error measure are less important.
Yeah my thought was also that it just interpolates well in my nodes and that there’s a large error somewhere else. The exact reason is probably too specific for a discord chat. Thank you for the help
in the finite element method, can you extrapolate from known values to reduce error?
i.e, if you know 2 "answers" for a first order finite difference approach (in calculating a differential, for seperate spacings) or 3 "answers" for a second order approach, can you then fit a linear or quadratic curve and use it to extrapolate to a more accurate answer?
oh perfect, thanks a lot
How is asymptotic growth about trigonometric functions viewed
Isn’t by definition of theta sin x in theta(cos x)?
Hello
Can I ask my question here?
About simpson's 3/8 rule
The general formula
Can somebody explain to me how to use the general formula of simpson's 3/8 in a simple way? Like why did we put y3 there and why the rest there....
should be clear from here https://en.wikipedia.org/wiki/Simpson's_rule#Composite_Simpson's_3/8_rule
you see the terms with 2 in front
Thank you this explains everything
Is it bad if your lecturer in numerical methods has not heard of the book on numerical analysis by burden & faires
I don't know, I have never heard of it. Should I?
Seems to be published by 2 unknown people from an unknown university by an unknown publisher, so I would answer no?
Oh. I thought that was the standard and most recognized text on the subject
there are many introductory books in numerical analysis/scientific computing. I used heath when I studied my first course myself, now when I teach I do not use any book (but recommend a couple for people who are interested, doesn't really matter which, then all cover pretty much the same stuff)
I see. I’m really looking for a numerical analysis book that is rigorous and does not skip out on the theory
then focus on some subset 🙂 what are you interested in? PDE ODE Approximation?
I don’t have any particular field of interest. And I think, I need to study more analysis first, before heading too much into PDE and ODE theory
I don't there exist any rigorous book covering everything 🙂
Like if you want to solve PDEs numerically you realy need to choose the problem and appropriate method and study that
I see alright. Thanks for your insight 🙏
Hello community, I'm trying to compute the discrete laplacian (upside down triangle squared symbol) for each cell of my 2d array, but I'm seeing two kinds of kernels (to use as convolution filters on the image). Could you please give me some guidance?
- not sure if this is correct, but people are using it
0.05 0.2 0.05
0.2 -1 0.2
0.05 0.2 0.05 - from wikipedia
0.25 0.5 0.25
0.5 -3 0.5
0.25 0.5 0.25
There seem to be multiple versions of this 9-point stencil (if I'm using the right name), and I'm not sure which one is the best
I'm trying to make calculations with lots of matrix powering and multiplying, so I need the values to not suddenly go super big
So as I understand it, the relative sizes of the numbers don’t matter for stability as much as all the entries should all sum to zero. I think the larger numbers will give you a more pronounced or shaper image than the smoother smaller numbers. I don’t think one is better / more ‘right’ than the other, but they’ll give slightly different results
Thanks very much Pixelius! Your explanation helped me understand!
Why after 5.998 value directly shoots above 6?
what technique would someone use to numerically integrate a function such as 1/sqrt(x) (sorry if this question isn't correct for this channel)?
from 0 to 1
$\int_0^1 \frac{1}{\sqrt{x}}dx$
Brandon7716
or more generally computing integrals for a function such that 1/x^p, 0<p<1
guess i was just curious how numerical integration techniques for improper integrals
you can make substitution 1/x = u, then this is improper integral with infinite upper bound, which you can integrate using quasi-uniform grids
You might want to look at this 1986 paper on nonsysmmetric sparse system. I think it’s neat
https://www.sciencedirect.com/science/article/pii/0377042786902256
thanks I'll check it out
Order of convergence of Newton rapshon method when zero is not simple ??
locally linear convergence with rate 1 - 1/m, where m is the multiplicity of the zero
Thanks
I am performing riemannian gradient descent, which involves having to invert positive-definite matrices each iteration. The one's i'm dealing with are of the order 100x100, sometimes larger. Could someone direct me towards any algorithms made for inverting large PD matrices?
by inverting do you mean you’re solving some linear system?
Inverting the coordinate matrix of the Riemannian metric at a point.
I.e. computing g^{ij}.
I’m not familiar with Riemannian gradient descent. Maybe I can give a better advice if I know ow how exactly the inverse plays out in the algorithm but with PD matrix, you can use LU factorization and then multiply the inverses of the factors which would be n^3 + n^2 complexity, or use Gauss-Seidel which is also n^3 flops. If the matrix is spd, Cholesky would be best.
So, every point x in the domain is mapped smoothly to a PD matrix G(x). In each step of RGD, you have to invert G(x). However, in my case, G(x) is a pretty large matrix.
if the algorithm doesn't use the inverse matrix itself, but merely a matrix-vector product, then it's more efficient to solve linear system than explicitly invert the matrix
Yeah do you need the full inverse? In most cases, you won’t. This is why I asked if you are solving a linear system. When you invert G(x) what are you using the inverse for?
Is the matrix sparse or dense?
I think I get it

