# About stability in system with loop gain AB>1 in negative feedback

I have been reading about stability and feedback systems, and a very silly issue has appeared. We can describe a negative feedback system as what can be seen in the following picture:

Image source: Electronics Tutorials - Negative Feedback Systems

So here we will have that Vout = (Vin-B*Vout)*G

We can find the transfer function as Vout/Vin = G/(1+B*G)

The issue is... I know for a fact that a system with negative feedback should be stable, regardless of AB>1 or AB<1. But I've tried to simulate that in Python, and my signal oscillates and tends to infinity. The loop is running correctly, meaning if you perform the calculations by hand it gives those results.

For the Python simulation, I assumed an input of vin = 1, an initial state of vout=0, and G=105 and B = 0.01, which is over unity. At this point I tried to do some calculations to find how can I make the system not oscillate (and thus avoid positive feedback), but I obtained a result saying that GB<1, which I know for a fact isn't a requirement. I'll leave the calculations:

(This also includes the image, copied from Electronics Tutorials - Negative Feedback Systems)

I know I'm making a mistake somewhere, because if a perform the simulation in Matlab Simulink I get the results that I expect to obtain. For example, in the following image, you have first a system with positive feedback with GB>1 (which should be stable), secondly a positive feedback system with AB>1 (which should be unstable), and finally a positive feedback system with GB<1 (which should be stable). The results are attached and are exactly what I expected.

The question remains... Where is my mistake? Why isn't my Python script correct?

• Simulink diagram has $$1/s$$. Where is it in the python code? Is $$G=105/s$$ or $$G=105$$. Both are different.
– AJN
Commented Mar 29 at 16:41
• I didn't check the link in the question, but I hope you are familiar with the topics of complex numbers, representation of signals and (linear, time invariant) systems, Laplace transforms, continuous time and discrete time systems before taking a dive into feedback systems. There are other, better, criteria for stability than AB<=>1 .
– AJN
Commented Mar 29 at 16:54

The Python code, the handwritten notes, and the body of the question say that $$G=105$$. But Simulink diagram says that $$G=105 \cdot \frac{1}{s}$$.
Moreover, the Python actually does not implement either of the above situation. It appears to implement $$x_n = vin_n - B \cdot vout_{n-1}\\ vout_{n} = x_n \cdot G = G \cdot vin_n - G \cdot B \cdot vout_{n-1}\\$$ where n represents sample number or (discrete) time variable.
Tf = G/(1+GB) only if it was implemented as $$x_n = vin_n - B \cdot vout_{\color{red}{n}}\\ vout_{n} = x_n \cdot G = G \cdot vin_n - G \cdot B \cdot vout_{\color{red}{n}}\\ \implies \left(1 + G \cdot B\right) vout_{n} = G \cdot vin_{n}\\ \implies \frac{vout_n}{vin_n} = \frac{G}{1 + G \cdot B}$$