Skip to main content
21-Topaz II
September 18, 2024
Solved

Searching a symbolic element in a square matrix (Using MATHCAD 15)

  • September 18, 2024
  • 2 replies
  • 2003 views

A big hello to everyone here,

I'm looking for a little program that receives as parameters only a square matrix of alphanumeric elements and a symbolic element to search in it. The program must return the row and column indices of the element searched. Is anyone able to make it? It seems simple to me. I thank very much whoever wants to do it.

Best answer by Werner_E

The numerics can not distinguish between -L.0*s and -0.000005

So a numerically evaluated "match" command will give you the position of both and also, depending on the setting of the system variable TOL even others which are "close" enough.

A symbolically evaluated "match" will give you the result you probably are looking for.

Werner_E_2-1726670642542.png

 

Werner_E_3-1726670950307.png

 

And, no, you can't look for just L.0, you have to use the full exact expression.

 

 

 

2 replies

23-Emerald IV
September 18, 2024

That's quite the challenge:

LucMeekes_0-1726669400087.png

The 'item'

LucMeekes_1-1726669439915.png

does not occur (as an element) in the matrix, in contrast to

LucMeekes_2-1726669515422.png

Luc

Werner_E25-Diamond IAnswer
25-Diamond I
September 18, 2024

The numerics can not distinguish between -L.0*s and -0.000005

So a numerically evaluated "match" command will give you the position of both and also, depending on the setting of the system variable TOL even others which are "close" enough.

A symbolically evaluated "match" will give you the result you probably are looking for.

Werner_E_2-1726670642542.png

 

Werner_E_3-1726670950307.png

 

And, no, you can't look for just L.0, you have to use the full exact expression.

 

 

 

23-Emerald V
September 18, 2024

Argh, me hearty! I'm in full on pirate mode, today, and 'tis capturing your worksheet I being!

 

A random thought was making its merry way through the aether and got tangled up in my skull.  Poor thing.  However, whilst it was there it wondered what would happen if I looked for coefficients of the desired variable.  Sooo, ....

 

2024 09 18 B.png

 

2024 09 18 C.png

 

Stuart

25-Diamond I
September 18, 2024

Congratulations on your pirate genes and the 'random thought' in your head. That really is a very clever approach!

Due to the nature of "coeffs" it will work pretty well as long as the variable is in a polynomial term. It will not find the position if its inside a function like sin or exp as then coeffs returns just a 1x1 matrix.
maybe if we combine it with "series" ....

Werner_E_0-1726688833331.png

It fails if L.0^2 is replaced by L.0^3 because of the modifier "3" in "coeffs".

 

I also came across an effect with "coeffs" which I was not aware of and which puzzled me at first - I seem to have completely forgotten about the additional "degree" modifier 🙂

Werner_E_3-1726689348001.png