help-octave
[Top][All Lists]

## Re: Leasqr matrix singular to machine precision

 From: Archambault Fabien Subject: Re: Leasqr matrix singular to machine precision Date: Thu, 21 Feb 2008 11:29:28 +0100 User-agent: Thunderbird 2.0.0.4 (X11/20070620)

```Hi all,

```
I am again answering at my own mail because I worked on this problem all day long...
```
```
As I could not solve the system I was asking why and found from the example leasqrdemo that I can give more points than the number of unknown (an overestimated system is possible !). So I changed my script with all the values I had.
```
The new problem is that now it looks to work but I find imaginary values.

The new script is :
#!/usr/bin/octave -qf
source "octave.script"
VAL = [ 1.367; 0.224500; 1.768200; -0.120; -0.046000; -0.152100 ];
function y = f(r,x)
y = \
```
+ sqrt(x(4) * x(5)) * ( ( (x(1)+x(2)) ./ r(:,1) ).^12 - 2 * ( (x(1)+x(2)) ./ r(:,1) ).^6) \ + sqrt(x(4) * x(5)) * ( ( (x(1)+x(2)) ./ r(:,2) ).^12 - 2 * ( (x(1)+x(2)) ./ r(:,2) ).^6) \ + sqrt(x(4) * x(6)) * ( ( (x(1)+x(3)) ./ r(:,3) ).^12 - 2 * ( (x(1)+x(3)) ./ r(:,3) ).^6) \
```;
endfunction
[f1,result,kvg,iter] = leasqr(RTEMP(:,:)',DELTA,VAL,"f",0.0001,1000)

With octave.script the same as in the last mail.

```
As I wasn't able to solve this "complicated" system I wanted to know if it was possible to solve on a new system which contains fewer variables.
```
The new system is 0_{2} : O --r-- O
The script :
#!/usr/bin/octave -qf
VAL = [ 1.8; 0.152100 ];
#VAL = [ 1.768200; 0.152100 ];
```
E = [ 250.271836308546, 132.774034082611, 72.1728842353269, 40.020270919924, 22.5347177726909, 12.8206430427006, 7.32587490817311, 4.17183668024339, 2.34120682386917, 1.27118200958098, 0.64439055829548, -0.15147612056423, -0.11058186021102, -0.06321649754989, -0.03569736566569 ]
```R = [ 1.9; 2; 2.1; 2.2; 2.3; 2.4; 2.5; 2.6; 2.7; 2.8; 2.9; 3.5; 4; 4.5; 5 ]
function y = f(r,x)
```
y = sqrt(x(2) * x(2)) * ( ( (x(1)+x(1)) ./ r(:,1) ).^12 - 2 * ( (x(1)+x(1)) ./ r(:,1) ).^6);
```endfunction
z = f(R,VAL)
[f1,result,kvg,iter] = leasqr(R,E,VAL,"f",0.00001)

This works ! And if I change the initial guess it also works !

```
The number of parameters is 2 so I tried to go on a bigger system with 4 unknown.
```
The new system is OH : O--r--H
The script :
#!/usr/bin/octave -qf
VAL = [ 0.224500; 1.768200; -0.046000; -0.152100 ];
```
E = [ -0.07448954353324, -0.08360628927338, -0.07754889023817, -0.06687445777949, -0.05579235670778, -0.04583105820141, -0.03740142179587, -0.03047055087209, -0.02485135363035, -0.02032381096457, -0.01668232871251, -0.00560089027582, -0.00253765775795, -0.00125663617346, -0.00066901215928 ];
```R = [ 1.9; 2; 2.1; 2.2; 2.3; 2.4; 2.5; 2.6; 2.7; 2.8; 2.9; 3.5; 4; 4.5; 5 ];
function y = f(r,x)
```
y = sqrt(x(3) * x(4)) * ( ( (x(2)+x(1)) ./ r(:,1) ).^12 - 2 * ( (x(2)+x(1)) ./ r(:,1) ).^6);
```endfunction
[f1,result,kvg,iter] = leasqr(R,E,VAL,"f",0.00001)

The output is :
```
warning: in /usr/lib64/octave/2.1.73/oct/x86_64-mandriva-linux-gnu/inv.oct near line 298, column 8:
```warning: inverse: matrix singular to machine precision, rcond = 3.83891e-18
f1 =

-7.4490e-02
-8.3606e-02
-7.7549e-02
-6.6874e-02
-5.5792e-02
-4.5831e-02
-3.7401e-02
-3.0471e-02
-2.4851e-02
-2.0324e-02
-1.6682e-02
-5.6009e-03
-2.5377e-03
-1.2566e-03
-6.6901e-04

result =

0.224500
1.768200
-0.046000
-0.152100

kvg = 1
iter = 1

```
If it works likes this it should converge in on 1 cycle (this is the case) but it shows an error...
```
```
If I try to modify the inital guess it doesn't converge and arrive to imaginary values...
```
```
Now I need help ! Does 4 variables are too much ? I tried to compile octave 3.0 but I have errors in compilation.
```
Does someone can provide me any clue ?

Thanks,
Fabien Archambault

--
Fabien Archambault
Equipe de dynamique des assemblages membranaires
Unité Mixte de Recherches CNRS UHP 7565
Université Henri-Poincaré, Nancy I BP 239,
54506 Vandoeuvre-lès-Nancy, cedex France

Tél : 03.83.68.43.96

```