0

This is my attempt at the solution using MuPAD:

$x[1]:=1;\ h:=0.1; \ x[50]-x[49]=h$

eqs:= $[x[i-1]-(2-h^2)x[i]+x[i+1]=0; \ i=2,...,49]$

vars:=$[x[i]; \ i = 1,...,50]$

numeric::linsolve(eqs,vars);

The problem is that $x[50]$ and $x[49]$ are not defined yet. What is the correct approach here? Do I solve the equation generally and then solve for every term $x[1,...,50]$ individually afterwards? Presumably the general solution will be an equation for each term $x[2,...,50]$. How do I pass the variables $h$ and $x[50]-x[49]$ to the general solution?

Lorenzo B.
  • 2,252
Jens
  • 1

1 Answers1

0

For a problem of this size you can simply generate the system of equations and solve it. Here's the Mathematica code to do it:

h = 1/10;
eql[0] = Table[x[i - 1] - (2 - h^2) x[i] + x[i + 1] == 0, {i, 2, 49}];
eql[1] = {x[50] - x[49] == h, x[1] == 1}
Solve[eql[0]~Join~eql[1], Table[x[i], {i, 1, 50}], Reals]