Skip to main content
1-Visitor
April 8, 2015
Solved

Faulty treatment of matrix indices in program?

  • April 8, 2015
  • 3 replies
  • 1616 views


Hi there,

I'm an experienced user of Mathcad and use Mathcad 15.0 (M010 [MC15_M010_20110622])

I encounter many bugs. Here is one.

Atached is a program concerning calculations on gears. Nothing complex, but with many variables, just following the norm. On many of the variables I need two or more [=rows(z)] values. In this case two. Use index j for that and ORIGIN=1.

In the course of the program several variables with index j are calculated. Some go wrong and show a complex answer; I corrected the values adding an extra formula row for index =1. These, in fact unnecessary lines, are marked with an A in front of the line. You can test by deleting an A marked line.

The program produces a matrix of 2 * 24. The columns are defined at the last row of the program.

Can you advise me on this one?

Best answer by AndyWesterman

Hi Paul,

I suspect that the line:

Capture.PNG

is the (1st) culprit.

when you loop the first time j=1 & alpha.a[2 is undefined(?)

calculating outside the program gives a complex result for this equation (a)

Splitting the program loop appears to fix the problem (b)

Hope this helps

Andy

3 replies

12-Amethyst
April 8, 2015

Hi Paul,

I suspect that the line:

Capture.PNG

is the (1st) culprit.

when you loop the first time j=1 & alpha.a[2 is undefined(?)

calculating outside the program gives a complex result for this equation (a)

Splitting the program loop appears to fix the problem (b)

Hope this helps

Andy

19-Tanzanite
April 8, 2015

It's not a bug (at least, it's not a Mathcad bug. It is a bug in your program) . The problem is in the definition of alpha.a. When j=1 d.a is a single element vector. That results in alpha.a being imaginary. On the second pass d.a is the correct two element vector, which fixes alpha.a, which fixes several variables all the way to eta.a.n, so then d.en[1, etc, calculate correctly. So Andy is correct that you need to split the loop, but the first loop only needs the definitions of k and d.a.

Version M010 does have bugs though. You should download and install M030: http://www.ptc.com/product/mathcad/free-trial/thank-you

psillem1-VisitorAuthor
1-Visitor
April 9, 2015

Hi Andy and Richard,

You're right. It solves my problem. My compliments to you and thanks for your quick respons.

I'll have to be a little more careful calling bugs.

I'll try to get the M030 installed at the Engineering company.

How to proceed for your points?

Best regards,

Paul