Category:Mathcad

From Rosetta Code
(Redirected from Mathcad)
This page is a stub. It needs more information! You can help Rosetta Code by filling it in!
Language
Mathcad
This programming language may be used to instruct a computer to perform a task.
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using Mathcad.

Mathcad Websites

Product Website:


User Community Website:


Basic Mathcad Description

The Mathcad Worksheet

Mathcad is a proprietary software programming language that is built around the concept of writing both text and mathematical expressions on a virtual whiteboard, the main difference between a real whiteboard and Mathcad being that Mathcad can evaluate the expressions and display any results on the 'whiteboard'. The worksheet can be any length and width that the user wants. Mathcad divides the whiteboard up into virtual pages (size is user-selectable) with the Mathcad Prime restriction that only the left-hand pages can be printed (a change from earlier versions).

Equations and text are entered into 'Regions' that can be arbitrarily moved around to suit the user's needs. However, the order of the ranges is important, as Mathcad evaluates worksheets from top-left to bottom-right.

Mathcad Types

Mathcad's basic data types are the string, complex-valued scalars, nestable two-dimensional arrays, functions, and ranges. It also has a basic programming facility, limited to for- and while-loops, if-else if-else, and try-catch, with return, break and continue. Values and expressions can be assigned to variables. Given Mathcad's order of worksheet evaluation, a definition only holds good from the location it is defined at. Any subsequent redefinition of the variable name only has effect from the point of redefinition; it does not affect the values of the variable prior to that and adding a new expression before the redefinition will use the old variable values.

Mathcad Arrays

An array's elements may be of any Mathcad type, including arrays and functions. Array elements are addressed using the index operator, which can be used outside of a program.

Mathcad treats single-column numeric arrays as vectors and 2D flat numeric arrays as matrices. The term 'vector' is overloaded to mean any type of single-column array, regardless of the element types. It is important to learn the distinction between a range variable and a variable holding a vector, as their behaviors are quite different.

Ranges and Range Variables

The range type allows iteration over a range of numeric values and is specified using the range operator then entering values for the first number in a sequence, the second number, and then the final number; the second number is optional and defaults to the first number + 1. For example, 1.0, 1.1 .. 2.0, when evaluated generates the numbers 1.0,1.1.2,1.4,1.6,1.8,20 whilst 1.0 .. 2.0 will generate 1.0,2.0. Ranges are normally used by assigning them to a variable, which is then referred to as a range variable, which Mathcad will automatically iterate over.

Functions and Operators

Mathcad functions are treated as first-class objects and may be passed to other functions as arguments and returned from functions. Mathcad programming supports local function definitions. Mathcad supports recursive function definitions, both via programming and by functional composition and argument passing. One Mathcad 15 feature that is lacking in Mathcad Prime, however, is local function recursion.

Many functions are implemented as operators and most can be entered via a key combination or from a palette of operators in the toolbar (Ribbon in Mathcad Prime). For example, pressing the "+" key automatically generates an infix addition operator that has placeholders for its two arguments. Pressing "=" enters the Evaluation operator and evaluates the expression in its left-hand placeholder.

Numeric and Symbolic Processing

Mathcad can do both numeric and symbolic evaluation of expressions. Whilst there is a degree of interaction between the numeric and symbolic systems, it is generally best to think of them as two separate processors evaluating the same worksheet. Apart from the symbolic processor's ability to evaluate numbers to arbitrary precision and symbolically evaluate expressions, there are also differences in which functions the two 'processors' will handle - see the Mathcad documentation for help on this.

One particular difference of note to engineers and scientists is that the numeric processor is Units-aware and will operate on dimensioned quantities performing any dimension and unit transformations that are necessary. Non-linear functions, however, do not generally accept units and the user must convert dimensioned quantities to scalars before evaluating them.


Mathcad Versions

Mathcad exists in two main forms: the original Mathsoft version (Mathcad 15 and earlier) and PTC's revised Mathcad Prime. The main philosophical difference between Mathcad 15 and Mathcad Prime is that Prime has a more document-oriented paradigm and is geared towards working with other PTC products. As with most major product upheavals, Mathcad users fall into two main categories, those who regard Prime as a step backward and those who regard it as superior; both sides have some merit to their arguments, but from a general user perspective, Mathcad Prime is still (as at Prime Version 6) missing several key features that are present in Mathcad 15. There is also a free version of Mathcad Prime, known as Mathcad Prime Express, that lacks several of Mathcad Prime's advanced features, such as programming, symbolics, and 3D plotting - it is surprisingly capable and, interestingly, supports a 'pure' functional programming style.