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

How to search (find) and replace math terms like identity(3)

SOLVED
Highlighted

How to search (find) and replace math terms like identity(3)

I am sorry, because I guess that my question is either very trivial (and I missed it), or without positive answer.

I need to change in a Mathcad (v.11 still, but I tried also with v.15) a matrix dimension from 3 to 2.

I have several equations, with "identity(3)" function, that needs to be corrected accordingly. I thought that the replace command would suffice to make a global change. Yet there is no way that Mathcad finds (both regions selected) the terms "identity(3)" in my worksheet, even if they are there. The culprit seems the bracket character.

Is there a way to make the find/replace command work? Thanks.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to search (find) and replace math terms like identity(3)

A rather crazy idea which I would not recommend at all is to redefine the identity function at the top of the worksheet

Don't comment on the readibility of that worksheet 😉

1.png

View solution in original post

16 REPLIES 16
Highlighted

Re: How to search (find) and replace math terms like identity(3)

anthony Queen wrote:

I am sorry, because I guess that my question is either very trivial (and I missed it), or without positive answer.

I need to change in a Mathcad (v.11 still, but I tried also with v.15) a matrix dimension from 3 to 2.

I have several equations, with "identity(3)" function, that needs to be corrected accordingly. I thought that the replace command would suffice to make a global change. Yet there is no way that Mathcad finds (both regions selected) the terms "identity(3)" in my worksheet, even if they are there. The culprit seems the bracket character.

Is there a way to make the find/replace command work? Thanks.

I don't think there is, unless you feel like saving the file as an xmcd file and then using a text editor to find and replace instances of the corresponding xml strings.

The ability to search and replace on expressions has long been on my wish list - it ought to be possible for the user to just copy an expression, paste it to the find box and have Mathcad find the whole thing, including operators (such as +).

One of the things I've learned is to avoid hard coding numeric constants into my programs. I find it's far easier, both during development and maintenance, to define all constants using a variable.

Stuart

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Many thanks StuartBruff.

The find command works correctly with "identity" and "3" in two separate searches. But not "identity(3)" in one go. I was hoping in some special characters like "*" or "?" used in Dos to avoid the undentifiable brackets. But I did not have luck. You seems to confirm this. I now undertstand your wise attitude towards constants.

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Could you not use special K mode and refine the variables to allow find to work?

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Mike Armstrong wrote:

Could you not use special K mode and refine the variables to allow find to work?

Don't know. Have you tried it, Mike? It would be very useful to be able to search and replace an expression such as "identity( 2)".

What do you mean by "refine the variables"?

Stuart

Highlighted

Re: How to search (find) and replace math terms like identity(3)

StuartBruff wrote:

Mike Armstrong wrote:

Could you not use special K mode and refine the variables to allow find to work?

Don't know. Have you tried it, Mike? It would be very useful to be able to search and replace an expression such as "identity( 2)".

I have just tried it and it does not work - bad idea sorry.

What do you mean by "refine the variables"?

I am not sure. I think I have have been thinking about another thread. A little early I suppose.

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Mike Armstrong wrote:

StuartBruff wrote:

Mike Armstrong wrote:

Could you not use special K mode and refine the variables to allow find to work?

Don't know. Have you tried it, Mike? It would be very useful to be able to search and replace an expression such as "identity( 2)".

I have just tried it and it does not work - bad idea sorry.

No need to apologise, it wasn't a Bad Idea, Mike, it just didn't work out. Now if you'd accidentally launched every nuke in the arsenal by doing so, then it would have been a bad idea ... A Very Bad Idea, in fact. ... Unless you're a cockroach, of course.

Stuart

Highlighted

Re: How to search (find) and replace math terms like identity(3)

StuartBruff wrote:

Mike Armstrong wrote:

StuartBruff wrote:

Mike Armstrong wrote:

Could you not use special K mode and refine the variables to allow find to work?

Don't know. Have you tried it, Mike? It would be very useful to be able to search and replace an expression such as "identity( 2)".

I have just tried it and it does not work - bad idea sorry.

No need to apologise, it wasn't a Bad Idea, Mike, it just didn't work out. Now if you'd accidentally launched every nuke in the arsenal by doing so, then it would have been a bad idea ... A Very Bad Idea, in fact. ... Unless you're a cockroach, of course.

Stuart

images.jpg

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Maybe you could post an example and we can see if there is a way to automate what you are trying to achieve.

Highlighted

Re: How to search (find) and replace math terms like identity(3)

It should definitely be possible to automate it by doing an xml search & replace, especially for a simple expression where you can really work out the replacement string. However, a more general capability would likely prove to be "interesting", as it would need to translate the user-level strings into their xml equivalents ... Unless you could work out how to use the Mathcad GUI, or something like equation editor, to input expressions?

Stuart

Highlighted

Re: How to search (find) and replace math terms like identity(3)

StuartBruff wrote:

It should definitely be possible to automate it by doing an xml search & replace, especially for a simple expression where you can really work out the replacement string.

Stuart

This was the sort of thing I was thinking about. However, I believe an example is required from Anthony to decide on the best option.

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Mike Armstrong wrote:

This was the sort of thing I was thinking about. However, I believe an example is required from Anthony to decide on the best option.

Just use what he wanted in his first post - change "identity(3)" to "identity(2)".

Stuart

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Maybe the numerical argument could be automated.

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Here's an example worksheet for you to try, Mike.

You need to find the xml regions containing

<ml:apply>

<ml:id xml:space="preserve">identity</ml:id>

<ml:real>3</ml:real>

</ml:apply>

and change them to

<ml:apply>

<ml:id xml:space="preserve">identity</ml:id>

<ml:real>2</ml:real>

</ml:apply>

Stuart

Message was edited by: Stuart Bruff - The editor dropped the (images) copied directly from Mathcad, so I copied the text to Notepad and copy/pasted from there.

Highlighted

Re: How to search (find) and replace math terms like identity(3)

A rather crazy idea which I would not recommend at all is to redefine the identity function at the top of the worksheet

Don't comment on the readibility of that worksheet 😉

1.png

View solution in original post

Highlighted

Re: How to search (find) and replace math terms like identity(3)

Werner Exinger wrote:

A rather crazy idea which I would not recommend at all is to redefine the identity function at the top of the worksheet

Don't comment on the readibility of that worksheet 😉

1.png

Sneaky. I like it, Werner..

Stuart

... until he wants to really define an identity 3, but then I suppose it would be easy enough to define identity3:=identity(3) before redefining identity or even use a difference math style for identity(3).

Highlighted

Re: How to search (find) and replace math terms like identity(3)

@^T [StuartBruff, Werner Exinger, Mike Armstrong]

Thanks for the great feedback. I liked the idea of Werner too, though admittedly it is not a good practice. But this comes from my initial bad design. I am still using MC v.11, so xml is not the standard format.

@Mike: I could uploaded my file, but in the essence I wanted to know how to handle a very simple case, like the one posted by Werner's image.

Thanks again.

Announcements