Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Re: Returning an array of matrices using a Mathcad...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
10:04 AM

01-13-2021
10:04 AM

This problem came up as a part of a recent linear algebra assignment.

In this case, we only use matrix multiplication and transpose, yet at the same time express a nontrivial control flow. There are 5^4=625 matrices to check, so performance is not a concern; I am focusing on ease of use.

For reference, here is the answer to this problem:

I have tried to write a Mathcad Program for this purpose. But the problem is that, neither it is returning the whole array of matrices, nor the one output that it gives is correct. It is returning A instead of P. The image of the Mathcad Program is:

Please, if anyone can help me in **returning an array of matrices that satisfy the given condition,** I would be obliged.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
01:26 PM

01-13-2021
01:26 PM

Even no solution contains a zero element, your loops should start from 0 and not from 1.

Note also the by default (you can change that behaviour) arrays are numbered beginning with 0, thats the reason for "i <-- 0". To apply the modulo operation on every element of the matrix T and not on the matrix itself (which makes no sense and results in an error) you have to use vectorization (the arrow over the expression). The temporary matrix T is necessary because we cannot write

because if we do so, the matrix multiplication would be done element by element and not the correct way. Se the difference here:

So here is one way to find the solutions via brute force:

P6 file attached

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
10:23 AM

01-13-2021
10:23 AM

Re: Returning an array of matrices using a Mathcad program.

Hmm,

The one output it gives is for the last matrix P tried. That is:

due to the fact that you did not build an escape into your program.

Did you check this:

No wonder:

Success!

Luc

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
11:42 AM

01-13-2021
11:42 AM

Re: Returning an array of matrices using a Mathcad program.

Thanks, LucMeekes. This problem uses the modulo 5 operations. I know a little bit of Mathcad, but I have checked it in wxMaxima, the answer is right. I don't know how to use those operations in Mathcad.

This is the website that has solved this problem in Maple, Mathematica & wxMaxima. I just wanted to make the Mathcad version of the same problem. Perhaps my question didn't convey the problem correctly. I'm sharing the link to the problem.

You can visit the website and check for yourself. I would be obliged if you please find a solution to this problem using programming in Mathcad.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
01:37 PM

01-13-2021
01:37 PM

Re: Returning an array of matrices using a Mathcad program.

As Werner has shown, you have to use the mod function:

Success!

Luc

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
01:26 PM

01-13-2021
01:26 PM

Even no solution contains a zero element, your loops should start from 0 and not from 1.

Note also the by default (you can change that behaviour) arrays are numbered beginning with 0, thats the reason for "i <-- 0". To apply the modulo operation on every element of the matrix T and not on the matrix itself (which makes no sense and results in an error) you have to use vectorization (the arrow over the expression). The temporary matrix T is necessary because we cannot write

because if we do so, the matrix multiplication would be done element by element and not the correct way. Se the difference here:

So here is one way to find the solutions via brute force:

P6 file attached

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

01-13-2021
01:35 PM

01-13-2021
01:35 PM

Re: Returning an array of matrices using a Mathcad program.

Thank you very much Werner_E 😀😍 & LucMeekes.