jcrist / Old-Control.jl

Development has been moved to https://github.com/JuliaControl/Control.jl
8 stars 0 forks source link

TransferFunction simplification is unstable #5

Open jcrist opened 10 years ago

jcrist commented 10 years ago

For some transfer functions, the built in simplification correctly removes the common factors without a problem. For others, small numerical errors accumulate, eventually leading the routine not to simplify properly. Example:

J = 0.01
b = 0.1
K = 0.01
R = 1
L = 0.5

s = tf([1, 0],[1])
P_motor = K/((J*s + b)*(L*s +R) + K^2)

Running:

P_motor*P_motor/P_motor

outputs:

TransferFunction:
                                               4.0000001788139405
--------------------------------------------------------------------------------------------
s^4 + 24.000000447034846s^3 + 184.04000625938198s^2 + 480.480019689203s + 400.80041791717474

When it should output:

TransferFunction:
              2.0000000447034845
---------------------------------------------
s^2 + 12.000000223517421s + 20.02000044748188

This is most likely due to accumulated error in the recursive division in gcd.

elsuizo commented 10 years ago

Hi maybe for this: in Polynomial,jl

num = Poly([1,0])
den = Poly([1])
#division
num / den
#output
Poly(x)

the promotion rule in tf() is always float is this correct?