MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Solving linear equations with symbolic RHS

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30173] Re: [mg30141] Solving linear equations with symbolic RHS
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Wed, 1 Aug 2001 02:19:31 -0400 (EDT)
  • References: <200107310827.EAA17582@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Tony MacKenzie wrote:
> 
> Once again I would like to thank everyone who helped with my last post. This
> question is more general and therefore probably much more difficult to
> answer.
> 
> I am trying to solve linear equations of the form  A.x=b.  A is a completely
> numeric matrix but b is a symbolic vector. I have tried Solve and
> LUDecomposition but neither of these seem to work very well when b is a
> symbolic vector.

I can understand LUBacksubstitution possibly causing trouble. But
LUDecomposition knows nothing about b and should behave just fine if A
consists of approximate numbers. It will also handle a matrix of exact
numbers, but not nearly so efficiently.


>  What has worked the best for me is to invert the matrix A
> (There is no problem with ill-conditioning) and to multiply by the symbolic
> vector b.  However, what slows this process down is when I expand the
> result.
> 
> Ainv=Inverse[N[A,16]];

If you want machine arithmetic it is better not to specify a precision
for N[] (16 need not always be the appropriate value). In a future
version N will treat values such as 16 as a request for bignums with
that many digits precision.


> soln=Ainv.N[b,16];

Why use N on b if it is not numeric?

Also, the LU method should work in similar fashion to what you have,
only alot faster. If you do not plan to do further solving with the same
matrix, you could also try LinearSolve. Though in that case the fact
that b is symbolic may matter, depending on the mood of the code
internals at that particular moment.


> Expand[soln];  (This last steps slows down dramatically as the size of the
> problem increases).
> 
> Each element of the symbolic solution vector may have a large number of
> terms.

One possibility is to forego the symbolic rhs case, and write a solver
that fires only once specific numeric values are given. This would be
quite efficient because you can preprocess with LUDecomposition on A,
hence you'd only need to do (much faster) numeric LUBacksubstitution.
This may not be adequate for all purposes, but it does well for the
common use of plugging in numeric values to the symbolic solution.


> I realise this question I am posting is quite vague but if anyone has any
> ideas it would be greatly appreciated.
> 
> Tony MacKenzie


If you really need that symbolic solution and can provide InputForm that
I can cut-and-paste into a standalone kernel, I'll take a look at it.


Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: Lists and speed
  • Next by Date: Re: Lists and speed
  • Previous by thread: Re: Solving linear equations with symbolic RHS
  • Next by thread: Re: non-linear regression