mathmari
Gold Member
MHB
- 4,984
- 7
I like Serena said:You have measurements at $x_0, x_1, ..., x_J$.
That are $(J+1)$ measurements.
However, you can leave out $x_0$ and $x_J$ since they are both given as boundary conditions: they are 0.
The leaves you with $(J-1)$ measurements.
So your matrix should be $(J-1) \times (J-1)$, your $b$ should have $(J-1)$ entries, and your resulting $w$ should have $(J-1)$ entries.
However, your "fix" gives you $J$ entries instead of $(J-1)$ entries.
That is $1$ off.
If it helps you to get the right answer, it means that later on you are also $1$ off.
So before you were probably calculating with an uninitialized variable.
Yes,you are right!
I looked again my code and realized that I didn't fix that $J$.
I have written the following in a function:
Code:
fun(b,J){
for(j=0; j<J-1; j++)
b[j]=f(X(j,J));
}
At the beginning I called the function fun(b,J-1) and that is wrong, since X is calculated in the function
Code:
X(j,J){
x=(j+1)/J;
}
Last edited by a moderator: