Computer generation of network functions

advertisement
Computer generation of network
functions
We want to obtain a network function in the
semisymbolic form
N ( s)
F ( s) 
D( s )
This will be useful for direct evaluation of F (s ) at
different frequencies (instead of using n 3 / 3
operations for each time) or inverse Laplace
transform to obtain time domain solution.
Assume we know LU factorization of Frequency s i
and assume that T  LU has all entries with s in the
number. Deferminant D( s i ) can be found as
n
D( si )  det T ( si )  det L( si )   Lii
j 1
Solving LUX   We can get X and then
numerator N ( si ) can be found as
N ( si )  D( si ) F ( si )
F ( Si ) ,The
Changing s i We can get sets of pairs ( si , N ( si ) ) and
( si , D( si ) ) ,and we seek the coefficients of N and
D.This is well known problem of Polynomial
interpolation.
Unit Enterpolation
Assume we have (n  1) distinct points ( xi , f ( xi )  yi ).
We want to find coefficients of the polynomial
f ( x) 
n
a
j 0
j
xj
We have
a0  a1 xi  a2 xi2  ...  an xin  yi
i  0,1,2,...n
or in the matrix form
1x 0 x 02 ... x 0n

2
n
1x1 x1 ... x1
.

.
.

2
n

1x n x n ... x n
 a 0

  a1
 .

 .
 .


 a n

 y0 

y 

 1 

.





.




.




y

 n
or
Xa  Y

a  X 1Y
where
X  [ xi j ]
The most numerically stable selection of xi ix on the
unit circle.
Let us define
w  exp
2  1
n 1
and
xk  w k
so
   
X  xij  wij
and
X 1 
1
X *( transpose&conjug.)
n 1
Therefore the solution
a  X 1 y 
or
 
1
1
X *y 
w ij y
n 1
n 1
1 n
aj 
y k w  jk

n  1 k 0
Using this equation all coefficients of the
approximating polynomial can be explicitly
calculated .Each coefficient requires addition of n+1
complex numbers-each one easily obtained from the
approximated function values y k .In addition the
polynomial interpolation on the unit circle is the
most numerically stable algorithm.
Condition numbers for interpolation:
Condition number
K X 
 ~
for the matrix
X is
~

K x   max /  min
~
where max, min are the largest and smallest
eigenvalues of XX*.
K(X) is a measure of perturbations in y.
In our case
XX *  XX 1 n  1  n  1I
So all the eigenvalues of XX* are equal to (n + 1) and
K(x) = 1.
So the selection of all points on the unit circle is the
best possible. Note that K(x)  1 always.
Example
Numerical value of the numerator and denominator
are
Ns p  1  3
Ns 0  t1  3
Ds 0  1  11
Ds p  1  7
Find transfer function (first order polynomials N(s)
and D(s)).
n=1
n+1=2
a  a 1s
T 0
b 0  b1s
so
  exp
2F1
 1
2
1 1
1
0k
a 0    1 Ns k   3  3  0
2 k 0
2
1 1
1
1k
a 1    1 Ns k   3  3  3
2 k 0
2
1 1
1
0k
b 0    1 Ds k   11  7   2
2 k 0
2
1 1
1
1k
b1    1 Ds k   11  7   9
2 k 0
2
So
T
3s
2  9s
Roots of Functions and Polynomials
The transfer function obtained by using polynomial
approximation will be presented in the symbolic
form by the rational function
n
F ( s) 
a
i 0
m
i
si
b s
i 0

i
N ( s)
D( s )
i
In many applications we need to know zeros and
roots of this function , so the following form is
desired
n
F ( s)  k
 (s  z
i 1
m
i
)
 (s  p )
i 1
i
where zi are roots (zeros) of N(s) and pi are roots of
D (s ) . The best know general method for finding roots
is the Newton-Raphson method . This is iterative
method which uses function and its derivation
values. We start initial point X 0 and expand the
function f (x ) around this point:
f ( x1 )  f ( x0 )  f ' ( x0 )( x1  x0 )  ...
If we neglect higher order terms and want to find
x such that f ( x1 )  0 then
1
( x1  x0 ) f ' ( x0 )   f ( x0 )
and
f ( x0 )
f ' ( x0 )
x1  x0 
Because this is an approximated solution we have to
iterate.
The iterations can be illustrated as shown on the
following figure
fx
fx
tg  f ' ( x0 )

0
x1
x0
The Newton-Raphson method is defined by the
following algorithm:
1. Set k=0 and select x 0
'

x


f
(
x
)
/
f
( xk )
2. Calculate k
k
3. Calculate xk 1  xk  xk
4. If xk   stop , else set k=k+1 and go to step2.
The method converges quickly to the solution ,
provided that initial point x 0 was correctly chosen.
The method which always converges to a root of
polynomial P0 ( x) is called Laguerre’s method and is
defined by
x
where
k 1

x 
npn ( x k )
k
pn1 ( x k )  H k

H  (n  1) (n  1)p ( x )  npn ( x k ) pn'' ( x k )
and Pn (x ) is a polynomial of degree n.It is
advantageous to first compute roots with small
absolute values,thus initial estimate should start with
x0  0 .
k
1
n
k
2
Example (Laguerre’s method)
Find one root of the polynomial
P5  8 x 5  12 x 4  14 x 3  13x 2  6 x  1
We have P51 x   40 x 4  48 x 3  42 x 2  26 x  6
and
P 11 x   160 x 3  144 x 2  84 x  26
5
Start at
x0  0
Calculate P5 x 0   1 , P51 x 0   6 , P511 x 0   26


H 0  4 4  6 2  5  1  26  56 , H 0  7.48
x x 
1
 
5P5 x 0
0
 
P51 x 0  H 0

 5 1
 0.37
6  7.48
1
0
x

x
Selected to have
small.
1
1
1
Second iteration: P5 x   0.02 , P5 x   0.45 ,
 
 44  0.45
P511 x 1  6.5
H1
2
x x 
2
1

 5  0.02  6.53  0.628 ,
5P5 x1 
P51 x1   H 1
 0.37 
 5  0.02
 0.45
0.45  0.79
2
Third iteration: P5 x   0.0012 ,
 
P511 x 2  2.78

H 1  0.79
 
P51 x 2  0.0.71 ,

H 2  4 4  0.071  5  0.0012  2.78  0.014 ,
H 2  0.118
2
x x 
3
2
 
5P5 x 2
 
P51 x 2  H 2
 5  0.0012
 0.48
0.071  0.118
 0.45 
Solution is: x1  x2  x3  0.5 , x4   j , x5  j
Solution of a nonlinear equation by
Taylor expansion and local inverse.
I.
Assume that we are solving f x   0 , we know that
'
a local inverse x f  can be determined if f x   0 .
Then
x 'f 0 
 
1
'

f
x0
f x'0
1
.
If we differentiate this equation we can get higher
order derivative. So
 
x "f 0   f x'0
also
2
and
dx
df
 
  f x'0
' 5
x0
3
f0
  f   f 
x 3 f
'''
f0
f x"0 
" 2
x0
' 4
x0
f x'0''
f x"0
   f   6 f 
 15 f   f   10 f  f
x  15 f
IV
f0
' 7
x0
' 7
x0
' 6
x0
" 3
x0
' 6
x0
'' 3
x0
"
x0
 
 f  f
f f 9 f
' '' ' '
x0 x 0
f xIII0
' 6
x0
' 5
x0
 
f f  f
''
x0
'' '
x0
' 5
x0
IV
x0
etc.
Using local inverse we can approximate
1 " 2 1 ''' 3 1 IV 4
x f   x f 0   x f  x f0 f  x f0 f  x f0 f  
2
6
4
'
f0
Now, assume that at a given x 0 we evaluated
'
'''
f  x0   f x and derivatives f x0 , f x" , f x0 , f xIV , …
0
0
f
0
x
x0
f x0
0
x̂
x0
x

x
0
f x0
f
f xIV0
In order to solve
f x   0

which gives x̂ we will simply find value x f  f 0  x .
*
If the x f  is a true inverse of f x  then x  xˆ , and
we get solution without iterations. Since all
derivatives of x f  are calculated at the nominal
point f 0 , then to change argument f to zero we use
f   f 0 .
So for instance if we limit expansion to 1st derivative
we get Newton-Raphon method
x  x0  xf  x0 
f
f
f
 x  x  x0 
  0'
f
f
f0
For the first 2 derivatives we have
2
f 0 f 0 
f 0 
x 2
x  x0  xf  f  x0  ' 

2
2  f 0' 3 
f0
 
So
f 0 
f 0 f 0" 
x   ' 1 
2 f 0' 2 
f 0 
 
For the first 3 derivatives we have
f 0  f 0 f 0"  f 0  3 f 0
x 2 x 3
x  x0  xf  f  f  x0  ' 1 
1
2 

'
2
6
2 f0
3  f 0' 2
f0


 
 
  



A modification of the root finding
method may be obtained if we use general
terms of Taylor expansion. To find x * , such that
II.
 
f x *  0 use expansion around given x 0
f   x0  *
f n   x0  *
2
n
f x  0  f x0   f x0  x  x0 
x  x0   
x  x0  
2
n!


*
*





We know that f x0   0 (otherwise x 0  x ) therefore
dividing by f x0  we get
f x0  *
f  x0  *
f n  x0  *
2
n
1 
x  x0 
x  x0   
x  x0  
f x 0 
2 f x0 
n! f x0 
*






if any of the terms say kth dominates over the sum
then we have
f  k   x0  *
1 
x  x0
k! f x0 


k
 x *  x0  k
k! f x0 
f k  x0 
k 
x0  is also not zero, in general
f
Since
(I)
1
x *  x0 
f k  x0 
k! f x0 
k
f x0 
 x0 
k
f k  x0  f k 1 x0 
k!
Denominator of (I) indicates how important an effect
of a particular derivative is. Generalized result
combines effect of various derivatives
x  x0 
f  x0 
*
f x0  
f n  f n 1
n!
f f 3 f f 2


2
3!
and the roots are chosen to maximize the magnitude
of denominator.
Noniterative method based on Taylor
expansion at x 0
fx
fx
tg  f0'
f0

0
x1

f0
f0'
x1  x0  
x0
fx


F  f0,, f0' , f0''...
0 x*

x0
  0 ,  ,  ,...
'
0
''
0
k
0

where
d i f ( x0 )
 
dx i
i
0
This algorithm uses derivatives at x 0 to find
1. Count=0
2. Formulate equation
x*
k
2
k 
( )  0     
 ...0
0
2
2
'
0
''
0
3. Find
 0i! 2
 min (
)
i
0
i
1
 count
(Delta(i) in the algorithm )
4. Find derivatives (precompute elements of the
expansion)
0i   i (  count )
(function Psi in the algorithm)
5. Increase count by 1 and repeat 2, 3, and 4 until
 count   ps
6. Solution
   0 (1  1 (1   2 (1  ..(1   count ))))
x *  x0  
function x = solve-2(F,x0)
% Nonlinear Equations Solver
% Janusz Starzyk
% F is a vector of a function and its
derivatives
computed at x0
Psi(:)=F;
eps=le-14;
count=0;
deltak=l;
% the main loop
while abs(deltak)>eps
count=count+l;
% solve for delta
for i=l:(size(F)-l)
Delta(i)=(Psi(l)/(Psi(i+l)/fact(i)))^(1/i);
end
deltak=min(Delta(:));
delta(count)=deltak,
% precompute elements of the
expansion
for i=l:size(F)
FnDeln(i)=Psi(i)*deltak^(i-1);
end
% find functions psi
for i=l:size(F)
Psi(i)=0;
for j=i:size(F)
Psi(i)=Psi(i)+FnDeln(j)/fact(j-i);
end
end
end % delta converged
del=l;
for i=count:-1:1
del=l+delta(i)*del;
end
x=x0+del-1;
function y=fact(i)
% this function evaluates factorial of i
y=1;
for ii=l:i
y=y*ii;
end
The above functions are stored as solve-2.m and
fact.m respectively
Download