Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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.
Solved! Go to Solution.
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.
And, no, you can't look for just L.0, you have to use the full exact expression.
That's quite the challenge:
The 'item'
does not occur (as an element) in the matrix, in contrast to
Luc
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.
And, no, you can't look for just L.0, you have to use the full exact expression.
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, ....
Stuart
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" ....
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 🙂
Nice. I was aware of the limitations of coeffs but a savvy pirate sticks to raiding lone, silver-heavy carracks with scurvy-ridden crews, and leaves fully tooled-up and escorted galleons to others.
It would have been a far easier task if the symbolic engine could split expressions into atomic symbols. Indeed, it may well have that capability (almost certainly must have), but it just does not make it public.
IIRC, the Vanilla Mathcad 11 symbolic engine "leaked" a few undocumented Maple functions into the wild. I think ops and subsop were some of them, as was eval (OK, I found a couple of old .mcd worksheets that used them). ops was useful for getting at elements of an expression, and subsop allowed substitution of elements in an expression. Needless to say, they were soon corralled and put to work in the employ of various Mathcadders.
Stuart
https://www.maplesoft.com/support/help/Maple/view.aspx?path=op&cid=663
https://www.maplesoft.com/support/help/view.aspx?path=subsop
Yep, I make use of those features frequently.
On the other hand, Mathcad 11's match() function doesn't work the way Werner showed. It's not equipped to work symbolically:
No symbolic result was found. 😞
Luc
@LucMeekes wrote:
Yep, I make use of those features frequently.
On the other hand, Mathcad 11's match() function doesn't work the way Werner showed. It's not equipped to work symbolically:
No symbolic result was found. 😞
Luc
I've had a sporadic play with trying to find a way to get MP10 to return better symbolic expression "resolution" of names. Unfortunately, I've had little joy (for values of little → 0).
However, in partial compensation, I posted a crisp, new numeric match function here:
https://community.ptc.com/t5/Mathcad/Match-Function-Error/m-p/974363/highlight/true#M213922
(When I say "new", I mean an old M11-version, restructured for MP10 and with a general tidy-up)
The added IsRange function uses the type exhaustion method because it doesn't look as ugly as the try-else alternative of trapping a non-range operator error (eg, sum)). And I could use MP's IsFunction to reduce error by type omission. Original Mathcad 11's on error construct allows for nice, compact code, so an error-trapping IsRange might be the better route to go for M11. I know I used to do some form of check for ranges in M11, but I can't remember what.
Stuart
@Werner_E wrote:
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 🙂
What I have long thought would be a decent enhancement along the same lines is returning prime factorization in that format.
Mathcad goes to all the trouble of working out the prime factorization, and then all you can do is look at how pretty the result is. Sure, I can copy the factors out by hand, but once again, we're into buy-dog, bark-yourself territory. Wuff!
Stuart
Looks like my version of Prime is broken
From your description I would have expected the result
Maybe in Prime 11, 12, 13, ...