comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: how to solve a equation set automatically in IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: how to solve a equation set automatically in IDL? [message #66679] Fri, 05 June 2009 06:50
Hu is currently offline  Hu
Messages: 35
Registered: January 2009
Member
On Jun 5, 4:07 am, Wox <s...@nomail.com> wrote:
> On Thu, 4 Jun 2009 09:29:12 -0700 (PDT), Hu <jha...@gmail.com> wrote:
>> Hi, there
>
>> I wonder whether there is some automatic method / function in IDL to
>> solve an equation set.
>
>> Supposing that I got an equation like:    A*x+B*y+C*z=E*m+F*n    , and
>> I got five sample points (xi,yi,zi,mi,ni), (1<= i <=5). well, I can
>> solve the equation set (including 5 equations) mathematically and got
>> value for parameter A,B,C,D,E.
>
>> How can I do it automatically without listing the expressions like A=f
>> (x,y,z,m,n), B=f(x,y,z,m,n), C=f(x,y,z,m,n)...?
>
>> Thanks
>
> So you're trying to solve a linear system of equations, right?
>
> In your example, [A,B,C,E,F] are the unknows? Then for one equation:
>            A*x+B*y+C*z = E*m+F*n
> <=>   A*x+B*y+C*z-E*m-F*n = 0
> <=>  [x,y,z,-m,-n]##transpose([A,B,C,E,F])=0
>
> And for several equations:
> M = [[x0,y0,z0,-m0,-n0],$
>         [x1,y1,z1,-m1,-n1],$
>         ...]
> X = transpose([A,B,C,D,E])
> M ## X = 0
>
> You can solve this numerically in many ways (e.g. use SVDC + SVSOL).
> However, this is a homogeneous system of equations, so there are two
> possibilities for the solution X:
> 1. There is only 1 solution: X = 0
> 2. There are an infinite number of solutions, namely the Null space
> (or kernel) of the matrix M
>
> So you find a solution X by finding the Null space of M. You can do
> this using SVD:
>
> ; Decompose M:
> SVDC, M, W, U, V
>
> ; Find the null space of M (i.e. columns of V corresponding with
> zero-valued singular values W)
> pres=(machar(double=double)).eps
> indNull=where(abs(W) le pres,nullity)
> if nullity ne 0 then X = V[indNull,*] $
> else X = V[0,*]*0
>
> When the nullity is not zero, X contains a basis for the infinite set
> of solutions. For example, nullity=2:
> set of solutions = a.X[0,*] + b*X[1,*] (where a and b is any real
> number)
>
> Does this help?

Yes, it's really helpful. thank you.
Re: how to solve a equation set automatically in IDL? [message #66680 is a reply to message #66679] Fri, 05 June 2009 01:07 Go to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Thu, 4 Jun 2009 09:29:12 -0700 (PDT), Hu <jhaohu@gmail.com> wrote:

> Hi, there
>
> I wonder whether there is some automatic method / function in IDL to
> solve an equation set.
>
> Supposing that I got an equation like: A*x+B*y+C*z=E*m+F*n , and
> I got five sample points (xi,yi,zi,mi,ni), (1<= i <=5). well, I can
> solve the equation set (including 5 equations) mathematically and got
> value for parameter A,B,C,D,E.
>
> How can I do it automatically without listing the expressions like A=f
> (x,y,z,m,n), B=f(x,y,z,m,n), C=f(x,y,z,m,n)...?
>
> Thanks

So you're trying to solve a linear system of equations, right?

In your example, [A,B,C,E,F] are the unknows? Then for one equation:
A*x+B*y+C*z = E*m+F*n
<=> A*x+B*y+C*z-E*m-F*n = 0
<=> [x,y,z,-m,-n]##transpose([A,B,C,E,F])=0

And for several equations:
M = [[x0,y0,z0,-m0,-n0],$
[x1,y1,z1,-m1,-n1],$
...]
X = transpose([A,B,C,D,E])
M ## X = 0

You can solve this numerically in many ways (e.g. use SVDC + SVSOL).
However, this is a homogeneous system of equations, so there are two
possibilities for the solution X:
1. There is only 1 solution: X = 0
2. There are an infinite number of solutions, namely the Null space
(or kernel) of the matrix M

So you find a solution X by finding the Null space of M. You can do
this using SVD:

; Decompose M:
SVDC, M, W, U, V

; Find the null space of M (i.e. columns of V corresponding with
zero-valued singular values W)
pres=(machar(double=double)).eps
indNull=where(abs(W) le pres,nullity)
if nullity ne 0 then X = V[indNull,*] $
else X = V[0,*]*0


When the nullity is not zero, X contains a basis for the infinite set
of solutions. For example, nullity=2:
set of solutions = a.X[0,*] + b*X[1,*] (where a and b is any real
number)

Does this help?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: JPEG contour plot without IDL graphics window, can this be done?
Next Topic: Idl virtual machine application

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:37:37 PDT 2025

Total time taken to generate the page: 0.40251 seconds