0
  \[\begin{bmatrix}
            $ d_1$ & $e_1$ & $0$ & $\cdots$ & $0$\\
            $ c_1$ & $d_2$ & $e_2$ & $\ddots$ & $\vdots $\\
            $ 0$ & $\ddots$ & $\ddots$ & $\ddots$ & $0 $\\
            $\vdots$ & $\ddots$ & $\ddots$ & $\ddots$ & $e_N$\\
            $0$ & $\cdots$ & $0$ & $0$ & $c_N$ & $d_N$
            \end{bmatrix}\]
            where $c_i = -1-\frac{h}{2}p(x_i),d_i = 2+h^2q(x_i)\;$ and\; $e_i=-1-\frac{h}{2}p(x_i)$ \\
            \[ \textbf{b} = \begin{bmatrix}
            $-h^{2}r(x_1)+(1+\frac{h}{2}p(x_1))y_0$\\
            $-h^{2}r(x_2)$\\
            $\vdots$\\
            $-h^{2}r(x_{N-1})$\\
            $-h^{2}r(x_N)+(1-\frac{h}{2}p(x_N))y_{N+1}$
            \end{bmatrix}\]
1
  • 2
    Welcome to TeX. SE! (i) please always provide MWE (Minimal Working Example), a small but complete document, (ii(matrix had to be used inside math environment (iii) all $ inside matrix had to be removed`, (iv) your problem has nothing with Overleaf.
    – Zarko
    Apr 21, 2021 at 18:04

2 Answers 2

3

There are several errors in your code. Among the serious ones:

  • \[ and \] initiate and terminate an unnumbered displaymath environment. Don't use $ to initiate and terminate inline math mode when you're already in display math mode. Hence, you must remove all $ instances inside both bmatrix environments.

  • $c_i = -1-\frac{h}{2}p(x_i),d_i = 2+h^2q(x_i)\;$ and\; $e_i=-1-\frac{h}{2}p(x_i)$ is wrong; it should be

    $c_i = -1-\frac{h}{2}p(x_i)$, $d_i = 2+h^2q(x_i)$, and $e_i=-1-\frac{h}{2}p(x_i)$
    

    i.e., you should use three separate inline math groups. Why? There are, syntactically speaking, three separate formulas on that line.

  • The final row of the first bmatrix environment has a surplus 0 &.

  • The instance of c_1 in row 2 should be c_2, and the instance of e_N in the second-to-last row should be e_{N-1}, right?

  • Not an outright error, but an inaccuracy: Write \mathbf{b}, not \textbf{b}, while in math mode.

  • To make the material look less cramped, I'd replace all four instances of \frac{h}{2} with it inline-math equivalent, (h/2).

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'bmatrix' environment
\begin{document}
\[
\begin{bmatrix}
    d_1 & e_1 & 0 & \cdots & 0 \\
    c_2 & d_2 & e_2 & \ddots & \vdots \\
    0 & c_3 & \ddots & \ddots & 0 \\
    \vdots & \ddots & \ddots & d_{N-1} & e_{N-1} \\
    0 & \cdots & 0 & c_N & d_N
\end{bmatrix}
\]
where $c_i = -1-(h/2)p(x_i)$, $d_i = 2+h^2q(x_i)$, and $e_i=-1-(h/2)p(x_i)$.
\[ 
\mathbf{b} = 
\begin{bmatrix}
    -h^{2}r(x_1)+(1+(h/2)p(x_1))y_0 \\
    -h^{2}r(x_2) \\
    \vdots\\
    -h^{2}r(x_{N-1}) \\
    -h^{2}r(x_N)+(1-(h/2)p(x_N))y_{N+1}  
\end{bmatrix}
\]
\end{document}
1
  • 1
    Thanks I understand all my mistakes Apr 22, 2021 at 4:51
1

I guessing that you like to achieve the following result:

enter image description here

\documentclass{beamer}
\usepackage[low-sup]{subdepth}

\begin{document}
\begin{frame}
    \[
\begin{bmatrix}
d_1     & e_1    & 0      & \cdots & 0          \\
c_1     & d_2    & e_2    & \ddots & \vdots     \\
0       & c_2    & \ddots & \ddots   & 0        \\
\vdots  & \ddots & \ddots & \d-{N-1} & e_{N-1}  \\
0       & \cdots & 0      & c_N      & d_N      \\
\end{bmatrix}
    \]
where $c_i = -1-\frac{h}{2}p(x_i)$, $d_i = 2+h^2q(x_i)$ and $e_i=-1-\frac{h}{2}p(x_i)$
    \[
\textbf{b} =
\begin{bmatrix}
    -h^{2}r(x_1)+(1+\frac{h}{2}p(x_1))y_0\\ 
    -h^{2}r(x_2)\\ 
    \vdots\\ 
    -h^{2}r(x_{N-1})\\ 
    -h^{2}r(x_N)+(1-\frac{h}{2}p(x_N))y_{N+1}
\end{bmatrix}
    \]
\end{frame}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .