# How to develop the the Backward Euler method for a State Space

I have been trying to develop to solve a state space model in discrete time. I have the following equation for my state space: $$\dot{x} = Ax + Bu,$$

I am developping the equation, but I do not understand why I don't have the right form as equations 7 and 8 in this website (link): $$\dot{x} = \frac{dx}{dt} = f(x, t) \\ \implies \frac{x_{n} - x_{n-1}}{h} = f(x_n, t_n) \\ \implies \frac{x_{n} - x_{n-1}}{h} = Ax_n + Bu_n \\ \implies x_n - x_{n-1} = hAx_n + hBu_n \\ \implies (I - hA)x_n = x_{n-1} + hBu_n \\ \implies \boxed{x_n = (I-hA)^{-1}x_{n-1} + (I-hA)^{-1}hBu_n}$$

I should obtain $$x_n = (I-hA)^{-1}x_{n-1} + hABu_{n-1}$$ according to equation 8 here.

• Please make the question self contained; perhaps by typing out the right form of the equation from the website or by posting a screenshot containing only the relevant portions.
– AJN
Commented Nov 28, 2022 at 14:47
• In the above derivation, it is not clear how line 3 is obtained from line 2 and how a negative sign appeared in line 6.
– AJN
Commented Nov 28, 2022 at 14:51
• @AJN Oups my bad for line 6 I made a mistake in writing. For line 3 I just took $\dot{x} = Ax + Bu$ from the state space equations. Commented Nov 28, 2022 at 14:59

1. The resource contains two distinct symbols; $$A_c$$ and $$A = (I-hA_c)^{-1}$$. So, $$h \color{red}{A} Bu_{n-1}$$ in equation (8) expands to $$h \color{red}{(I-hA_c)^{-1}} Bu_{n-1}$$
2. Equation (7) in linked page has $$B_c u_{k \color{red}{-1}}$$. You appear to have used $$B u_{n}$$.

These are the only two differences I could find.

• Thank you, what is wrong in my development that leads me to $u_{n}$ instead of $u_{n-1}$ as derived in the linked source ? Commented Nov 28, 2022 at 17:02
• Since that step in the derivation doesn't involve any mathematical logic. From line 2 to 3, it is more of an assumption or definition rather than logic. So nothing wrong per se, I think. If you could have replaced $f$ by $\dots B u_{k-1}$ instead.
– AJN
Commented Nov 29, 2022 at 2:01

The state space model is defined as

$$\dot{x}=A_c\,x +B_c\,u$$ And he is replacing $$\dot{x}=u$$ using the Backward Euler method, that is $$u_k = \frac{x_k - x_{k-1}}{h}$$, where h is the discretization time step. Thus we have:

$$\frac{x_k - x_{k-1}}{h} = A_c\,x +B_c\,u$$

As you noticed he is somehow combining discrete time and continous time, but he claims that an approximation is done through equation (7), i.e.

$$\frac{x_k - x_{k-1}}{h} = A_c\,x +B_c\,u \approx A_c\,x_k + B_c\,u_{k-1}$$

Unfortunately is not clear from where he got this approximation, and personally I would not use that approximation. Anyway, (and doing in his way) the rest is quite easy to solve $$$$x_k - x_{k-1} = h\,Ac\,x_k + h\,B_c\,u_{k-1} \\ x_k =(I-h\,Ac)^{-1}\,x_{k-1} + (I-h\,Ac)^{-1} h B_c\,u_{k-1}\\ x_k =(I-h\,Ac)^{-1}\,x_{k-1} + h\,(I-h\,Ac)^{-1}\,B_c\,u_{k-1}$$$$ Then, we define $$A := (I-h\,Ac)^{-1}$$ and replace, that is $$x_k = A\,x_{k-1} + h\,A\,B_c\,u_{k-1}$$ last step we define $$B:= h\,A\,B_c$$ giving us equation (8), i.e. $$x_k = A\,x_{k-1} + B\,u_{k-1}$$