Quantcast
Channel: PTC Community : Discussion List - PTC Mathcad
Viewing all articles
Browse latest Browse all 2936

Best format for writing Mathcad expressions in text?

$
0
0

Reference message Online Encyclopedia of Integers (OEIS) Sequence A256275

 

The Online Encyclopedia of Integer Sequences (The On-Line Encyclopedia of Integer Sequences® (OEIS®)) only accepts entry information in text format.   This creates a bit of a problem for Mathcad entries.

 

Mathcad is rare in that it only has a "Math Form" input and display, with (for example) summation being represented by Sigma (Σ) with underscript and overscript notation for the variable and initial value (k=1) and final value (n), respectively; similarly, expressions such as 2^(n^2) and (a+b)/(c+d) can be written and displayed without the need for parentheses to disambiguate them from 2^n^2 and a+b/c+d.

 

However, there is no universally agreed method of conveniently writing down a Mathcad expression that is readily meaningful for both Mathcad and non-Mathcad users.

 

Keystrokes are one method for Mathcad users but they don't "show" the expression, and don't give much insight into an expression; they do, however, allow a Mathcad user to enter the expression as intended. For example:

 

a ( n ) : 2 ^ n ^ 2 End + ' 1 + Ctl-$ 2 ^ ' n + 1 Space Space * ' n - k Tab k Tab 1 Tab n Tab

 

then

 

a ( 3 ) = to evaluate numerically or

a ( 3 ) Ctl-. to evaluate symbolically

 

where you type each of the characters in the order shown, with End, Ctl-$, Space, Tab and Ctl-. represent the

corresponding keys (the actual spaces above between the key characters act as key delimiters and don't get typed; a space is only typed where Space is written.

 

I wouldn't wish the saved (Mathcad 14/15) .xml format on my worst enemy ... well, I might! However, it is possible to process the xml to get rid of the tags, which gives more readable formats, but probably wouldn't be too recognizable to the average Mathcad user. Eg:

 

a ( n ) := ( plus ( plus 2 ( plus n 2 ) ) ( ( plus 1 ( summation lambda ( ( k ) ( plus 2 ( mult ( ( plus n 1 ) ) ( ( minus n, k ) ) ) ) ) ( 1, n ) ) ) ) )

 

or (removing some of the spaces adjacent to parentheses)

 

a( n ):=( plus( plus 2( plus n 2 ))(( plus 1( summation lambda(( k )( plus 2( mult(( plus n 1 ))(( minus n, k )))))( 1,

n )))))

 

or (removing all of the spaces adjacent to parentheses)

 

a(n):=(plus(plus 2(plus n 2))((plus 1(summation lambda((k)(plus 2(mult((plus n 1))((minus n, k)))))(1, n)))))

 

or (changing arithmetic function names to their usual symbols)

 

a(n):=(+(+ 2(+ n 2))((+ 1(summation((k)(+ 2(*((+ n 1))((- n, k)))))(1, n)))))

 

As an occasional dabbler in functional languages such as LISP, I'm OK with the above xml transformations, but I suspect not everybody would be.

 

Unfortunately, Prime doesn't save files in pure text xml format (unlike Mathcad 15), and has no components so it's not possible to iterate over all the regions and extract their xml codes, which makes it a problem converting expressions to text anyway.

 

Ideally, any such representation should act in furtherance of the long-standing requests to have a "standard" text format input and output format for import/export of equations.

 

What format would people recommend for writing Mathcad expressions as text?

 

Stuart


Viewing all articles
Browse latest Browse all 2936

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>