New answers tagged

2

Integers can be represented "exactly" in Matlab, however a lot of times Matlab will choose to work with floating point double precision, which may not necessarily represent all integers exactly (IIRC it is exact up to about $2^{53}$). Indeed, even when you try typing an "integer" into matlab, it will tell you that it defaults to doubles: &...


3

MATLAB doesn’t plot where there are NaNs, so you can replace some of your data with NaNs to make a clean jump. I don’t know which is a bigger lie, a clean jump or a strange wiggle. That’s up to your eye and values.


1

Your code does not solve the BVP you posted. Here is the revised version that works well. function bvp(N) [D,x] = cheb(N); % Set up differentiation matrix D2 = D^2; % Insert boundary condition: u(-1) = 0, u(1) = 2 D2(1,:) = zeros(1,N+1); D2(1,1) = 1; D2(N,:) = zeros(1,N+1); D2(N,N) = 1; % right hand side f = zeros(N+1,1); f(1) = 2; ...


1

You are splitting the vector $x$ into its components $(u^Hx)u$ that is parallel to $u$ and its complement $x-(u^Hx)u$ that is orthogonal to $u$. Then the reflected vector is composed by reducing the last one again by the parallel component. The idea being that the reflection on the plane that has $u$ as normal vector changes the sign of the component ...


2

Since it looks like your discretized function is monotonically decreasing, you can calculate an effective upper and lower bound of the numerical integration using left and right Riemann sums. There is a way to compute accurate summations of floats which avoids repeated summation truncation error. I don't know if Matlab has an implementation of this function ...


Top 50 recent answers are included