[SciPy-user] Schur complement

Nils Wagner nwagner at mecha.uni-stuttgart.de
Wed May 26 09:52:20 CDT 2004

```Pearu Peterson wrote:
>
> On Wed, 26 May 2004, Nils Wagner wrote:
>
>
>>I am trying to solve a transcendental eigenvalue problem via the Schur
>>complement. However, I have some trouble with optimize.fsolve.
>>
>>How can I solve this problem ?
>
>
> In short, use
>
> def func(x):
>    return abs(schur(T(x[0])))
>
> (when using optimize.fsolve then the argument x is rank-1 array and
> fsolve assumes that func is a real-valued function)
>
> Pearu
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>
I have modified my program.

def func2(x):
return abs(schur(T(x)))

r6 = optimize.fsolve(func2,x0)

Now I get

Traceback (most recent call last):
File "fschur.py", line 77, in ?
r6 = optimize.fsolve(func2,x0)
File "/usr/lib/python2.3/site-packages/scipy/optimize/minpack.py",
line 80, in fsolve
check_func(func,x0,args,n,(n,))
File
"/usr/lib/python2.3/site-packages/scipy/optimize/common_routines.py",
line 13, in check_func
res = myasarray(apply(thefunc,args))
File "fschur.py", line 63, in func2
return abs(schur(T(x)))
File "fschur.py", line 8, in T
tmp[0,0] = -sin(x)
ValueError: array too large for destination
>>>

The requirement, i.e. func is real is not mentioned in help
(optimize.fsolve). Am I missing something ?

Nils

fsolve(func, x0, args=(), fprime=None, full_output=0, col_deriv=0,
xtol=1.49012e
-08, maxfev=0, band=None, epsfcn=0.0, factor=100, diag=None)
Find the roots of a function.

Description:

Return the roots of the (non-linear) equations defined by
func(x)=0 given a starting estimate.

Inputs:

func -- A Python function or method which takes at least one
(possibly vector) argument.
x0 -- The starting estimate for the roots of func(x)=0.
args -- Any extra arguments to func are placed in this tuple.
fprime -- A function or method to compute the Jacobian of func with
derivatives across the rows. If this is None, the
Jacobian will be estimated.
full_output -- non-zero to return the optional outputs.
col_deriv -- non-zero to specify that the Jacobian function
computes derivatives down the columns (faster, because
there is no transpose operation).

Outputs: (x, {infodict, ier, mesg})

x -- the solution (or the result of the last iteration for an
unsuccessful call.

infodict -- a dictionary of optional outputs with the keys:
'nfev' : the number of function calls
'njev' : the number of jacobian calls
'fvec' : the function evaluated at the output
'fjac' : the orthogonal matrix, q, produced by the
QR facotrization of the final approximate
Jacobi matrix, stored column wise.
'r'    : upper triangular matrix produced by QR
factorization of same matrix.
'qtf'  : the vector (transpose(q) * fvec).
ier -- an integer flag.  If it is equal to 1 the solution was
found.  If it is not equal to 1, the solution was not
mesg -- a string message giving information about the cause of
failure.

Extended Inputs:

xtol -- The calculation will terminate if the relative error
between two consecutive iterates is at most xtol.
maxfev -- The maximum number of calls to the function. If zero,
then 100*(N+1) is the maximum where N is the number
of elements in x0.
band -- If set to a two-sequence containing the number of sub-
and superdiagonals within the band of the Jacobi matrix,

```