cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

1-Newbie

## Unsure how to interpret Minerr result...

Hi,

First post on this forum. I've been a Mathcad user for several years on and off, I'm still on version 2001 and need to upgrade ASAP!

Anyway, quick question...

I've been using Minerr with the LM iteration previously for configuration of various electronic equipment. I'm trying to use it once more, although I'm now using it to solve a Matrix of values - please see attached.

My question is, how do I interpret the resultant Matrices/Vector in the result set? In other words, how do I determine u1, u2, u3, SX, SY and SZ?

Any help/assistance is appreciated.

Regards,

Mike.

1 ACCEPTED SOLUTION

Accepted Solutions
19-Tanzanite
(To:RichardJ)

I think this is what you really wanted though. The model now includes all the data and all the parameters.

13 REPLIES 13
24-Ruby V
(To:mshaw-3)
 My question is, how do I interpret the resultant Matrices/Vector in the result set? In other words, how do I determine u1, u2, u3, SX, SY and SZ?

Simple answer - as you have set it up you can't. You provide a guess value for the matrix S which is a diagonal matrix, but as you can see does Mathcad not respect your will that S[0,1 should be zero, etc. YOu will have to state that as additional constraints in the solve block. As those constraints aren't hard constraints, you may even write 10^5*S[0,1=0, thus weighting that constraintheavily and chances are the value will come out close to zero at the end.

Similar your matric P. For Mathcad you simply provide 9 arbitrary guess values and Mathcad feels free to play with all of them. So again you have to constrain some of them to zero and to keep the relationship between -sin(u1) and cos(u1) you may write U1 and sqrt(1-U1^2) instead. Same with U", U3 and sqrt(1-U2^2-U3^2).

That way you will have 30 equations / constraints and 21 variables to solve for.

Alternative would be to just use Minerr(SX,SY,SZ,BX,BY,BZ,u1,u2,u3) , which would mean 20 equations and 9 variables to solve for. This time you would have to write b=(BX,BY,BZ) (boolean equal sign) in the solve block instead of b:=(BX,BY,BZ) above. Same for the other matrices.

A quick try yielded the attached (I'm not able to save in 2001 format, so I attach a pdf) which is less than disappointing. ERR is extremely high and setting CTOL to something lower than the high value set in the sheet (0.1) does not change anything. So either there is really no better fit or I have done something wrong.

1-Newbie
(To:Werner_E)

Thankyou for that, I have implemented the first suggestion around constraining P[0,0 , etc, and still have a large ERR value. The big error seems to indicate an issue with the underlying data I'm trying to fit?

Thankyou.

19-Tanzanite
(To:Werner_E)

Your solve block does not do anything. The values after the solve block are the same as those before. If you enable the calculation of the three definitions you disabled then the error drops to about 80 (the solve block is still not doing anything, but the error is much lower). I haven't had time to figure out why.

Another curiosity is that for me the diag function does not work after the solve block. If I redefine S_ using copy and paste then it works fine:

A weird bug!

1-Newbie
(To:RichardJ)

Thankyou for that Richard. I notices that U was unchanged and therefore not solving for u1, u2 and u3. I'm struggling with this one I'm afraid, I suspect the collected raw data is too noisy.

I have expanded the Matrices in the following worksheet and re-ran the Minerr function for three unknowns, u1, u2 and u3. I still get a large ERR value of 43.579 (I have tried several values for CTOL, etc). I think I've entered the data and equations correctly, if there are any Mathcad wizards out there that can confirm that for me?

19-Tanzanite
(To:mshaw-3)

You obviously really like typing

It doesn't have to be so painful

Also note that arrays start at 0 by default, not 1.

19-Tanzanite
(To:RichardJ)

I think this is what you really wanted though. The model now includes all the data and all the parameters.

1-Newbie
(To:RichardJ)

Hi Richard, Thankyou for the worksheets. I didn't realise you could do it that way, much cleaner! I seem to have a 'Floating Point Error' with it at the moment, just trying to track it down at the moment.

Changing the precision in the Evaluate menu removes the error. However, the values returned for SX, SY, ... , u3 are unchanged from their original values. Will dig into it some more 🙂

Ahhh.... Ok, changing the FP precision resets the method to Conjugate Gradient. Changing to LM brings up the 'Encountered a floating point error' issue. Will keep looking...

19-Tanzanite
(To:mshaw-3)

I'm not sure which precision you are referring to. Can you be more specific?

If you simply evaluate the function Resid(SX,SY,SZ,BX,BY,BZ,u1,u2,u3) above the solve block, what happens? Do you get the error?

1-Newbie
(To:RichardJ)

Hi,

Regarding the precision, if I click on Minerr and then go to 'Symbolics'- 'Evaluate' and select 'Floating Point', I can change the Floating Point precision.

Evaluating the function above the Solve block produces No Error.

I really appreciate the help/assistance you are giving.

As a side note, I've just purchased Mathcad Prime 3.0 and installing now.

Regards,

Mike.

19-Tanzanite
(To:mshaw-3)

There is no symbolic math in the worksheet, so that precision will have no effect.

If you have purchased Prime 3.0 you also purchased Mathcad 15. Install that as well, because it's much more powerful than Prime 3.0, and it can read the worksheet I posted (Prime cannot, although if you install MC15 you could convert it). If you install MC15 there's not much point in figuring out what the problem is in MC2000.

1-Newbie
(To:RichardJ)

Ok thankyou.

Have installed Mathcad 15 and opened the worksheet in that. Everything works and the results are great. I can't thankyou enough for the help and assistance. It is much appreciated.

24-Ruby V
(To:RichardJ)
 A weird bug!

No, it isn't, it's working as documented. If the argument of diag() is a nx1 vector, the output is a nxn diagonal matrix. If the argument of diag() is a nxn matrix, then the output is a nx1 vector (consisting of the diagonal elements.

After the solve block S_ is a vector, so diag yields a matrix.

Later you define S_ as matrix, so the result of diag() is vector. A real tricky function.

BTW, Mike won't be able to open your sheet as he is using MC 2001.

19-Tanzanite
(To:Werner_E)
 No, it isn't, it's working as documented. If the argument of diag() is a nx1 vector, the output is a nxn diagonal matrix. If the argument of diag() is a nxn matrix, then the output is a nx1 vector (consisting of the diagonal elements.After the solve block S_ is a vector, so diag yields a matrix.Later you define S_ as matrix, so the result of diag() is vector. A real tricky function.

Duh!

 BTW, Mike won't be able to open your sheet as he is using MC 2001.

Good point. I've updated my post with a 2001 version.

Announcements