Manual Smath Studio
Manual Smath Studio
Manual Smath Studio
Download details:
IP Address: 80.35.250.98
This content was downloaded on 12/12/2018 at 13:44
CHARACTERIZING THE COOL KOIs. VIII. PARAMETERS OF THE PLANETS ORBITING KEPLER’S
COOLESTJ.DWARFS
Jonathan Swift, Benjamin T. Montet, Andrew Vanderburg et al.
MOJAVE. XIII. PARSEC-SCALE AGN JET KINEMATICS ANALYSIS BASED ON 19 YEARS OF VLBA
OBSERVATIONS AT 15
GHZ
M. L. Lister, M. F. Aller, H. D. Aller et al.
Advanced data extraction infrastructure: Web based system for management of time series data
S Chilingaryan, A Beglarian, A Kopmann et al.
THE MULTIPLICITY OF MASSIVE STARS: A HIGH ANGULAR RESOLUTION SURVEY WITH THE
GUIDANCE
E. J. Aldoretta,
SENSOR
S. M. Caballero-Nieves, D. R. Gies et al.
YOUNG PLANETARY NEBULAE: HUBBLE SPACE TELESCOPE IMAGING AND A NEW MORPHOLOGICAL
SYSTEM
CLASSIFICATION
Raghvendra Sahai, Mark R. Morris and Gregory G. Villar
The InterPlanetary Network Supplement to the Second Fermi GBM Catalog of Cosmic Gamma-Ray Bursts
K. Hurley, R. L. Aptekar, S. V. Golenetskii et al.
THE ROTATION AND GALACTIC KINEMATICS OF MID M DWARFS IN THE SOLAR NEIGHBORHOOD
Elisabeth R. Newton, Jonathan Irwin, David Charbonneau et al.
IOP Concise Physics
Chapter 1
An overview of SMath Suite
Throughout the book reference is made to SMath files in the form [LinearRegress1.sm],
generally at the start of a paragraph. All these files are available here. Files with
names ending with M, M1, etc. are functional only when opened with SMath with
Maxima.
features found in the expensive application Mathcad but differs in that SMath is
free. Some of its features are shown in figure 1.1. The SMath user interface resembles
that of Mathcad.
Although the application is correctly called SMath Suite, it is normal to use just
the word SMath. However, when doing an internet search always use the full name
to avoid hitting sites dealing with an unrelated item.
1-2
SMath for Physics
The SMath Studio toolbar contains 21 icons (figure 1.2) which are briefly
described below.
Items (1) through (4) manipulate new or existing worksheets. Items (5) through (7) are
well-known editing functions. Items (8) and (9) will undo and redo the most recent
action. Items (10) through (12) adjust font or background properties—see Construction
Regions below. Item (13) allows you to put a frame over an entry; for example, to
show a solution to a problem. Items (14) and (15) re-align selected cells. Items (16) and
(17) open the Function and Unit menus, which are also available in the Insert menu.
Item (18) is also available under the Help menu. Items (19) and (20) are also available
in the Calculation menu. Item (21) shows or hides all the palettes on the right-hand side
of the page.
The palettes (figure 1.3) contain mathematical, graphical, and programming
functions that can be placed in the main window. Each palette may be condensed or
expanded on the tool on its header ⊡. The panel containing the palettes may be
toggled on/off with the last item on the toolbar.
We will briefly explore some of these palettes and what they contain. Note that
allowing the mouse pointer to hover over an item causes its name to be displayed.
As expected, the π tool inserts that symbol; this is one of SMath’s numerical
constants with the value 3.12…. The square roots tool is readily identified; the
keyboard short cut is \. Similarly, one can see the multiplication operator × but
most users will type *. In either case, SMath converts the operator to a middle dot,
as in area:= width · length.
To assign a value to a variable or to define it in terms of other variables the definition/
assignment operator := is used. This is the penultimate icon on the Arithmetic palette
but normally the user types just a colon (:) and SMath converts it to the operator.
The Functions palette contains only a few of the functions available from Insert |
Functions. The iconic tools for summation, product, differentiation, and integration
are very useful.
1-3
SMath for Physics
1-4
SMath for Physics
The screen captures below may help you understand the comments in the next
three paragraphs.
To make a text region either use the command Insert | Text Region or begin the
text with a double quote which will not be recorded. If you just start typing some
text, SMath will recognize it as a text region when you enter a space. As soon as this
happens a small yellow box appears to indicate your language. To start a new line in
a text region use Shift+Enter rather than just Enter.
Looking at the top line in figure 1.1 we see definitions for three variables (x, y and
ans). Recall that we can begin the last one either by typing ans: or by typing ans
and then clicking the definition operator (:=) in the Arithmetic palette; in each case
we have a partial definition with a place holder. Again we have two options: (a) we
could enter the numerator (x − y)2, then the division operator and type the
denominator x, or (b) use the division operator to give the template shown here and
then add the numerator and denominator. The trick in constructing and editing
formulas is to watch the poistion of the insertion symbols ⌊ and ⌋. Once a variable
has been defined it will appear in the dynamic assistant. So if we begin to type an we
will see the definition for ans.
To copy, move or align one or more regions begin by clicking to one side of a
region and then drag the mouse to select all the required regions. Use the Ctrl key to
select non-adjacent regions. When the mouse button is released just the regions are
shown as selected. Now you can drag to a new position, use one of the alignment
tools or issue the Copy command (Ctlr+C is the easiest way). The same selection
method can be used to give one or more regions a border, a background colour or a
different font size. A region selected in this manner can be copied by holding down
the Ctrl key as you drag the region. Text regions can be made bold, underlined and/
or italicizied—these effects will apply to the entire text; one cannot enhance just part
of a text region. Do not confuse the selection method here with clicking and drag-
ging inside a region to make it dark blue.
1-5
SMath for Physics
α Α alpha a ν Ν nu n
β Β beta b ξ Ξ xi x
γ Γ gamma g ο Ο omicron o
δ Δ delta d π Π pi p
ε Ε epsilon e ρ Ρ rho r
ζ Ζ zeta z σ Σ sigma s
η Η eta h τ Τ tau t
θ Θ theta q υ Υ upsilon u
ι Ι iota i ϕ Φ phi f
κ Κ kappa k ψ Π psi y
λ Λ lambda l χ Χ chi c
μ Μ mu m ω Ω omega w
The reader may wish to skim through the rest of this chapter and return to it when
using a particular SMath feature.
1-6
SMath for Physics
region can be individually formatted. The decimal and exponential threshold setting
for a math region displaying a number can also be altered on an individual basis.
Suppose, with the decimal places set to 8 and exponential threshold at 5, we see on a
page x = 128.22 827 158. We can select the region by left clicking, then by right
clicking bring up a menu from which Decimal places may be chosen; this leads to the
dialog in figure 1.5. The process can be repeated to change the exponential threshold
to 1. Now we have x = 1.282×102.
1 + 5/6 + 7/8 5
1+ 7
= 1.7273
6+ 8
1 + 5/6→ + 7/8 5 7
1+ + = 2.7083
6 8
On the SMath page, left click the result above, 5 7 65
1+ + =
then right click and select Fractions followed 6 8 24
by Fractions.
See if you can get the first result rather than 3⋅π π
= 4.7124 3⋅ = 4.7124
the second. 2 2
1-7
SMath for Physics
[Overview2.sm.] Figure 1.6 shows an SMath page with some simple definition and
display math regions. As a warm up to delving deeper into SMath, the reader is
invited to recreate such a page, perhaps with the explanatory text omitted. Note how
typing a: results in a:=. When you type c:a*b, the conversion to c := a·b is
instantaneous.
Experimentation is encouraged:
1. Change the global decimal place setting and the decimal setting for an
individual region.
2. Can d be displayed as a fraction?
3. Find other ways to obtain the √ operator.
4. Have you mastered the two alignment tools?
5. When you drag the d = 0.8 region up the page it becomes d = ∎ with a red
border; why?
6. Is there another way to compose the x assignment?
7. Can you change the value of b without retyping the entire assignment?
8. Click on z = 4.79 then right click and from the popup menu use Optimi-
zation | Symbolic.
1-8
SMath for Physics
There are several way of entering units. Method (a): suppose we have typed d1:=20
and the region is still active. From the menu bar use Insert | Units to bring up the
dialog shown in figure 1.8. Note how the left panel shows various categories but we
have selected All. In the Quick box we entered meter (note the US spelling). Now in
1-9
SMath for Physics
the right hand panel we can select centimeter (cm) and click the Insert button, or we
can double click the cm entry in the dialog. In either case the dynamic assistant pops
up so we tap the Tab key to confirm we want this unit. Method (b): now we have
typed d2 := 40 and wish to add the cm unit. We type a single quote (‘) and this
causes the units menu to pop up; we type cm and this locates the desired unit and we
confirm with the Tab key. Note that when the user types the single quote, SMath
adds a place holder but it is more oval than the normal rectangular place holder.
The progression to get r := 6 m3 min−1 is: after typing r : 6, insert the m unit and
then use ^3. Now insert the min unit and use ^−1. While units are shown in blue,
any exponent for a unit is not.
Note how SMath looks after unit conversion. We have centimetres and minutes
in the data but the result show metres and seconds. SMath always shows standard
SI units in numerical evaluation regions. However, as seen in figure 1.7, we can
override this. Click on a region displaying v2 := 0.8 m, use the right arrow key to
get to the far right of the region, and then use the single quote to indicate that you
wish to add units, and add the required units. If you enter inappropriate units, the
regions will show no numeric value and will have a red border.
1-10
SMath for Physics
Clearly, the current version of SMath has trouble displaying the correct units for
Boltzmann’s k, the gas constant Rm, and the Newtonian gravitation constant GN.
However, SMath ‘knows’ the correct units and displays them in the dynamic
assistant and uses them in calculations.
To insert a physical constant symbol into a math region use the same techniques
as for unit. So to get the region shown to the right, after typing the 2, the user typed ‘
(single quote to indicate a unit is needed), g to locate the items beginning with g,
a period to indicate a subscript in preparation for typing an e. As it turns out, there
was no need to add the e since the dynamic assistant located ge. All that remained
was to tap the Tab key to confirm the choice.
If you use π or e in a formula without assigning a value then the values shown in
figure 1.9 are used. If values are assigned, they will override the built-in values. It is
recommended that values not be assigned to either π or e.
1-11
SMath for Physics
A user wishes to define x with x := 2·ln(z). Method (a): after typing 2*, he
clicks the f (x) tool, locates the ln function in the Insert Function dialog, which he
double clicks, or he clicks the Insert button. Unfortunately, the Insert Function
dialog has no Quick Search facility, so you must scroll all the way through. The task
is shorter if you correctly guess what group to use from the left panel. Now he has
the template shown above.
Alternatively, since he knows the name of the function, after typing the 2* he types
ln and up pops the dynamic assistant. He commits his choice with the Tab key. Note
that in the dynamic assistant functions are shown in purple while units are blue.
1-12
SMath for Physics
At the bottom of figure 1.11 we see how to reference a matrix element: type A [3,
2 = to make this math region. Note the use of [ to get an index compared to [period]
to get a subscript. There is more white space between the matrix name (A) and the
first index (3) than there would be if we had a variable A with a subscripted 3.
Some simple matrix math is demonstrated in figure 1.12. In a later chapter we see
how to use matrix math to solve a system of equations.
[Vector.sm.] The range functions may be used to generate vectors with numerical
elements as seen in figure 1.13. Coupling this with the augment function we can
define a matrix—see figure 1.14.
• range(start, end): shows up in the worksheet as start..end, and produces a
vector whose elements are start, start+1, start+2, … end.
• range(start, end, start + increment): shows up in the worksheet as start, start +
increment … end, and produces a vectors whose elements are start, start +
increment, start + 2 increment, etc. The last element is the lowest value smaller
than end by less than increment.
1-13
SMath for Physics
The cross product of two three-element vectors (X and Y) is found with C:= X × Y,
where the × operator is the last item on the Matrix palette.
⎛ 1 ⎞ ⎛ 6 ⎞ ⎛−4 ⎞
⎜ 2⎟ × ⎜ 8 ⎟ = ⎜ 8 ⎟
⎜ ⎟ ⎜ ⎟ ⎜ ⎟
⎝ 3 ⎠ ⎝10 ⎠ ⎝−4 ⎠
1-14
SMath for Physics
2. Use the Insert | Plot | 2D menu option. Alternatively, use the keyboard
shortcut of typing @.
3. Type the function x^3 − 6*x^2 + 11*x−6 in the place holder in the lower
left corner of the graph.
4. Use the mouse wheel to rescale both axes. Drag the centre of the plot to keep
the zone of interest (where we see the three roots) visible.
5. Resize the plot by dragging one of its fill handles.
When using this method, we must use a function of x; no other variable name will
work. Furthermore, we have no control over the range of x-values; we address this in
later chapters.
The methods for modifying a graph are listed below; you must first ‘activate the
graph’ by clicking on the graph so that the handles are displayed:
1. Drag one of the handles (small solid squares) to resize the graph.
2. Drag the mouse pointer to reposition the origin.
3. Scroll the mouse wheel to rescale both axes.
4. Scroll the mouse wheel while holding down CTRL to rescale the y-axis.
5. Scroll the mouse wheel while holding down SHIFT to rescale the x-axis.
Sometimes when you plot a function the graph appears empty. In such cases it is
necessary to rescale the graph to find the plotted data. Try plotting x2 + 75x − 2500;
you will see nothing until the x scale is about ±64 and the y scale ±1024.
At the time of writing, SMath (version 0.97.5346) has a problem with certain high
resolution Microsoft wireless mice (model 4000, for example). The plot scales increase
regardless of the direction of rotation of the wheel. A fix for this problem is planned.
1-15
SMath for Physics
To relocate the graph on the page: click outside the graph and drag the mouse
until the graph is selected (blue background with default setting); now drag it to new
position. To copy or delete a graph you need to select it in the same way. Alter-
natively, a graph (or any region) can be moved by dragging it by the outside frame
when the mouse pointer is a four-pointed arrow.
[Graph2.sm.] Two or more functions can be plotted on one graph (figure 1.16) by
using the multiple values tool—it is the last one in the Functions palette. What is
produced is sometimes called a list. The list may be external to the graph or used in
the graph place holder. When you click on the tool a template with two place holders
is displayed. To add more items to the list, click on the brace { and drag the resulting
fill handle (lower right corner) down. Items can be deleted by dragging it up.
[Graph3.sm.] Figure 1.17 has five functions plotted and gives some idea of the
colours used by SMath with blue being used for the first function.
[Graph4.sm.] Figure 1.18 demonstrates how to add text and points to a graph. The
variable plottext is a 2×5 matrix: the first two elements in a row specify the starting
position (x, y), then the text to be displayed, followed by the font size and colour.
Similarly, in each row of the 7×5 matrix Points we have: x-position, y-position,
symbol, font size, and colour. See the note below regarding the symbol.
SMath offers over 140 colour choices from aliceblue to black—see http://en.
smath.info/forum/default.aspx?g=posts&m=3663. A misspelled colour name will
result in black being used. It is not possible to type the = symbol within a text
element in a vector; the = symbol in y = mx + b was produced with Alt+205.
1-16
SMath for Physics
For the value of char, use only one of: the period character which displays as a solid
circle; the lower case character o which displays as a circle; x which displays as a cross;
the asterisk (*) which displays as a star. Other characters are plotted incorrectly—too
low and too far to the right.
1-17
SMath for Physics
It is suggested that you copy and paste the plotG function from the file Graph_
PlotG.sm rather than try to code it. Also refer to section 1.19 to see how to make a
snippet to allow the plotG function more readily accessable.
[Graph.sm.] If we have a function such as f(x) defined on an SMath page and enter
f(x) in the plot’s place holder, then we have no control over the domain used by the
plot. This can be rectified using the augment function. This method is explained in
figure 1.20.
1-18
SMath for Physics
1-19
SMath for Physics
quartic of interest has no x3 term. It was simpler to define a function to show the
correct roots had been obtained.
The polyroots function uses an analytical method to generate results that are
accurate to within the precision of SMath (15 decimal places). The next two func-
tions we will look at, roots and solve, use numerical approximation methods. The
reader may be familiar with methods such as Newton–Raphson, secant, bisection,
etc; a concise review of numerical methods can be found at http://www.maths.dit.ie/
~dmackey/lectures/Roots.pdf.
[Roots.sm.] Normally we would use polyroots to find the roots of any polynomial
but for the sake of comparison in figure 1.23 we use polyroots, roots and solve to get
the roots of the cubic equation x3 − 2x2 − 3. The polyroots function finds three roots,
only one of which is real. The functions roots and solve give only real roots.
1-20
SMath for Physics
Figure 1.24. The roots function fails when argument-2 already has a numerical value.
The second argument in a roots evaluation cannot have been given a numerical value in
any statement prior to the roots calculation.
[Roots2.sm.] Figure 1.25 demonstrates another example of the use of roots: to find
the roots of a transcendental equation.
[Roots3.sm.] Figure 1.26 demonstrates the use of roots to solve a system of linear
equations. In the upper part, the vectors are used for the three arguments; in the
lower part the vectors are defined beforehand and are referenced by the arguments.
In a later chapter we see how matrix math can be used to solve a system of
equations.
[Roots4.sm.] Unlike the matrix method, the roots function method allows us to
tackle systems of nonlinear equations, as shown in figure 1.27.
[Solve1.sm.] In figure 1.28 the solve function is used to find the roots of the same
function that was solved with the roots function in figure 1.25. Solve has the
advantage of locating all the real roots in one operation and returning them in
a vector. In the top part of figure 1.26 solve is used in the two-argument form
1-21
SMath for Physics
1-22
SMath for Physics
solve( function-to-solve, variable). In the lower part we have the four-argument form
solve( function-to-solve, variable, lower-limit, upper-limit).
[Solve2.sm.] The two-argument form of the solve function is sensitive to the last
setting in Tool | Options | Calculate (see figure 1.4). This is demonstrated in
figure 1.29. Normally a polynomial is best solved with polyroots but the quadratic
here serves as a convenient example to make the point being made.
[Solve3.sm.] So far we have been finding roots, i.e. we have found x such that
f (x) = 0. In the next example (figure 1.30) we see how to find x such that f (x) = Q where
Q is some numerical value. A Boolean = must be used in the expression within solve.
1-23
SMath for Physics
1-24
SMath for Physics
1.18 Programming
Computer scientists speak of programs being constructed from three structures:
sequential, branching (aka decision or conditional), and looping. In a sequential
structure each statement is executed one after the other; in SMath this means from
left to right and from top to bottom. SMath has one way to make a branching
construct and that is the If…Else. SMath does not have the case construct found in
many computer languages. There are two looping constructs: for and while. The for
construct is used when one knows how many times some code is to be repeated; the
while construct is used to loop until some condition is met.
1-25
SMath for Physics
1. Start with the basic template; fill in the first place holder.
2. Click on the inner place holder—the second or the third.
3. Click on line in the Programming palette.
4. Click on the line to reveal a fill handle in the lower right area.
5. Drag this down as far as needed; drag up if you go too far.
1-26
SMath for Physics
The second and third constructs are equivalent, but the author finds the meaning
of the third one to be clearer.
In these constructs, j is referred to as the loop variable. Programmers take great care
never to explicitly change the value of a loop variable other than in the opening code of
the for loop.
1-27
SMath for Physics
When coding a while loop is it easy to make a mistake that causes the loop to run for
ever—the exit condition is never satisfied. You will see a green border around the code
that is being executed and the timer in the status bar keeps increasing. Press the Esc
button and accept the invitation to cancel the calculation!
While you are working in a program structure, be careful to avoid typing the eva-
luation operator (=) when a definition operator (:=) is required. This mistake will result
in egregious place holders in the top right corner of the structure and only after patient
work with the delete, backspace and arrows keys will you have workable code.
1.19 Snippets
It may be helpful when a user finds he is repeating a particular piece of code in
many worksheets, to place this code in a snippet. When SMath Studio is installed
there are already two snippets available. These allow the user to readily work
1-28
SMath for Physics
in degrees or in grads rather than in radians. In figure 1.37 the top part shows
the calculation of some trigonometry functions; the last item in each row was
given the symbolic optimization—either type = and then by right clicking the
region, set the optimization to symbolic, or use the shortcut Ctrl+period in place
of the =.
In the centre of the page there is a line with the notation Evaluation in
Degrees, and under that some more calculations but this time with arguments in
degrees not radians. Clicking the ⊞ at the left of the line will reveal the code that
allows for this. To add the hidden code to the worksheet, click the place where
the code is to added (look for the red cross), open the dialog shown in figure 1.38
using the command Tools | Snippet Manger, then double click the required
snippet.
1-29
SMath for Physics
The reader may be wondering how code gets added to the Snippet Manager. The
process is relatively easy; here is a concrete example for a user wishing to add the
plotG function as a snippet (figure 1.39).
a) Open a file with the function; Graph_PlotG.sm for example.
b) Copy and paste just the plotG function to a new page.
c) Save the new file as plotG.sm on the desktop, and close SMath Studio.
d) Using Windows Explorer (aka File Manager) move the new file from the
desktop to the folder C:\Progam Files (X86)\SMath Studio\snippets.
Windows will prevent the user who attempts in step (c) to save directly to the
snippet folder, hence the workaround of first saving it elsewhere. For those with the
portable version of SMath Studio a direct save is recommended.
[SnippetExample2.sm.] The steps to use the new snippet are the same as before.
The advantage of having the plotG snippet is being able to find the code quickly and
make tidy worksheets where the plotG function is hidden and therefore is not
obtrusive.
1-30
SMath for Physics
1-31