Intro To SMath Studio 102011
Intro To SMath Studio 102011
sm
Introduction
__to__basic__SMath__Studio__operation
By Gilberto E. Urroz, August 2011 - edited December 2011 - updated June 2012
In this document we introduce the use of SMath Studio for the purpose of
calculating mathematical expressions, and solving algebraic equations.
1.__Where__to__download
__SMath__Studio?
(These instructions are valid as of August 05, 2011)
* Follow the link below the title "Download SMath Studio" for the most
recent version of the software. Then scroll down until you find the
download link for your operating system (e.g., Desktop Windows) under
the heading "Free Download"
http://www.neng.usu.edu/cee/faculty/gurro/SMathStudio.html
2.__Basic__operation
__of__the__SMath__Studio
__worksheet
* To turn paper grid on/off: View>Grid
* To enter text: click at the point where you want to start, and type
" followed by your text - Example: In the space immediately below,
click " and then type:
1 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
My first attempt at text in SMath Studio.
Enter your
solution here ->
Enter your
solution here ->
* The palettes on the right-hand side of the screen are used to enter
mathematical items into your worksheet.
2 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
<----------------------------+
Figure 1. Mathematical symbols
in the "Arithmetic" palette.
See list above.
Any time that you end up with an operator that has placeholders
(e.g., the square root symbol), you can just click on the place-
holder to enter a value, or expression, in it. For example, the
following images show the n-th root (Cntl+\), before and after
the placeholders are filled with numbers:
3 729 9
3__-__Assigning
__values
__to__variables
* Variable names: a variable name in SMath Studio can be any collection
of letters, numbers, or the undersign symbol _, as long as it
starts with a letter. Some examples of variable names are:
The value to the right of the assignment symbol (:=) will now be
assigned to the variable name to the left of it.
3 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
* Previously-evaluated variables
==============================
Variables evaluated earlier in a worksheet can be used to define
other variables. For example, having evaluated variables x and y1
above, we can define the following variables:
2
Moment_of_inertia x y1 Moment_of_inertia 9.7531
9753129
Moment_of_inertia
1000000
4 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
If you try to evaluate an expression involving a unevaluated EXERCISES: Click on an empty space in the
variable you will get an empty placeholder when you try to worksheet, then perform the required variable
list the newly calculated variable. For example, z has not assignment. Afterwards, show the contents of
been defined yet, but x is defined. Try to calculate k as: the variable assigned by using either a numerical
evaluation (=) or a symbolic evaluation (Cntl+.):
k x z k
Variable
__name Value__to__assign
Click over the k in the second expression to see the error Top_width b+2*m*y
message "z - not defined". X_Area (b+2*m*y)*y
Wet_Perim b+2*y*sqrt(1+m^2
In order to produce a result for k, in this example, you Hyd_Radius X_Area/Wet_Perim
need to define z above, or to the left, of the expression
for k, e.g.,
z 2 k x z k 4
5 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
An alternative way to enter Greek letters, that does not rely on
the "Symbols" palettes, is to type the "equivalent" English letter,
say, a, and immediately enter Cntl+G. Some examples are shown below.
The typing sequence to the left indicates the typing sequence as
well as the name of the Greek letter which is produced in the worksheet:
g Cntl+G (gamma): γ x Cntl+G (xi): ξ EXERCISES: Click on an empty space in the worksheet,
e Cntl+G (epsilon): ε r Cntl+G (rho): ρ then perform the required variable assignment. After-
z Cntl+G (zeta): ζ s Cntl+G (sigma): σ wards, show the contents of the variable assigned by
h Cntl+G (eta): η t Cntl+G (tau): τ using either a numerical evaluation (=) or a symbolic
q Cntl+G (theta): θ u Cntl+G (upsilon): υ evaluation (Cntl+.):
k Cntl+G (kappa): κ f Cntl+G (phi): φ
l Cntl+G (lambda): λ c Cntl+G (chi): χ
m Cntl+G (mu): µ y Cntl+G (ypsilon): ψ Variable__name Value__to__assign
n Cntl+G (nu): ν w Cntl+G (omega): ω α 38.2
φ_A sqrt(123 <space bar>/3)
Typing an upper-case English letter followed by Cntl+G will β 3.5
produce the "equivalent" upper-case Greek character, e.g., µ 1.2
ψ 0.5
G Cntl+G (Gamma): Γ S Cntl+G (Sigma): Σ τ_Top β+2*µ*ψ
Q Cntl+G (Theta): Θ F Cntl+G (Phi): Φ Ξ_Area (β+2*µ*ψ)*ψ
L Cntl+G (Lambda): Λ Y Cntl+G (Ypsilon): Ψ Ω_Perim β+2*ψ*sqrt(1+µ^2
X Cntl+G (Xi): Ξ W Cntl+G (Omega): Ω η_Rad Ξ_Area/Ω_Perim
t 20 v0 5.2 t0 5 at 4.5
v v0 at t t0 thus, v 72.7
EXERCISE: Solve the following problem:
Curvilinear motion problem: [2]. Determine the
Alternatively, to make the solution look like it would in a textbook normal acceleration, a.n, of a particle moving
setting, we can use subscripted variables. To type the name of a on a circular path of radius, ρ = 100 m, if the
subscripted variable, type first the name of the variable, then a speed of the particle is v = 20 m/s. Use the
period (.), then the subscript. In the following example, the equation: a.n = v^2/ρ.
characters between brackets show the typing sequence that produces Do not include units in the calculations.
the subscripted variables evaluation statement:
6 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
[v:v.0+a.t*(t-t.0)] v v a t t
0 t 0 v 72.7
Notes:
(1) We didn't include units in the definition of the variables
above. The use of units will be introduced later.
(2) The sequence <variable_name>.<subscript>produces a subs-
cripted variable only in mathematical expressions. This sequence
does not work in text. Try: v.0 (this is in text). Therefore,
it is not possible to type subscripted variables in text.
(3) English and Greek letters can be used for variable names as EXERCISE: Solve the following problem:
well as for subscripts. Examples: Thermal expansion problem [1]. Determine the
thermal expansion ∆L suffered by a rod of length
α 2.3 K 3.2 θ 34.5 L.0 = 10 cm if the initial temperature is T.0 =
β δ k
20 centigrade, the final temperature is T.f =
40 centigrade, and the coefficient of thermal
4-__Typing
__mathematical
__expressions expansion is α.S = 0.005 cm/centigrade. Also,
determine the final length, L.f, of the rod
Some of the examples shown above used relatively simple mathematical after the expansion. Use the equations:
expresions. Here we repeat some of them with the corresponding typing
sequence between brackets: ∆L = α.S*(T.f-T.0), and L.f = L.0 + ∆L
δ α α β
[v:v.0+a.t*(t-t.0)]
v v a t t
0 t 0
7 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
Another important typing sequence is the use of the right-arrow key in your
keyboard. It's action is similar to that of the space bar, namely, to select
wider expressions or expressions between parentheses.
This example shows the use of Greek letters (Cntl+G), parentheses, space bar,
subscripted variables, sqrt (square root), and abs (absolute value) in a 2D
mathematical expressions. With practice you will learn to build complex 2D
mathematics in SMath Studio.
Correcting errors:
==================
Correcting errors in entering an expression can be accomplished in many ways:
1 - Use the Backspace key to remove the last key stroke(s).
2 - Select elements to be removed using your mouse, then the Backspace key.
3 - Click on a specific location to insert variables or expressions.
4 - You can copy and paste an expression within another expression.
Sometimes you need to type an expression not with the purpose of evaluating
it, but with the purpose of documenting an assignment or report. In such case,
you can use the Boolean equal sign (first sign in the "Boolean" palette in
the right-hand side panel in the SMath Studio interface, also entered by using
Cntl+=) to build your non-evaluating mathematical expression. Thus, you could
type, for example:
8 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
2
b b 4 a c 0.886 EXERCISES: Use the quadratic
x , i.e., x
2 a 3.386 equation formula to solve the
following equations:
_____________________________________________________________________________
Note: to highlight a solution you could place a frame around it by using the 2
"Border on/off" button in the menu bar (it looks like a square frame). First, 3 y 2 y 6 0
you need to select the solution field by dragging your mouse while holding 2
down the left key over it. 2.5 ξ 7.5 ξ 16.5 0
You can also highlight the framed solution by using a background color as 2
λ 3 λ 25 0
follows: (1) Drag your mouse while holding the left key over the solution
field; (2) Click on the "Background color" button in the menu bar (it looks 2
25 β 76 0
like a painter's palette); (3)Click on one of the color squares; (4) Press
the [ OK ] button. Here's an example of highlighting a solution with both a
frame and a background color:
0.886
x
3.386
_____________________________________________________________________________
An alternative way to solve the quadratic equation used above, namely,
2
2 x 5 x 6 0
9 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
is to use function "solve". Here we show two different ways to call
function "solve":
1 - Using function "solve" with two arguments:
2 3.386
solve 2 x 5 x 6 0, x
0.886
2 - Using function "solve" with four arguments, limiting the range of the
solution:
2
solve 2 x 5 x 6 0 , x , 0 , 10 0.886
An alternative way to use function "solve" is to assign the function call to
EXERCISES: Use function "solve" to
a variable, e.g.,
solve the following equations:
2 3.386 2
x solve 2 x 5 x 6 0, x , whose solution is: x 3 y 2 y 6 0
0.886
2
2.5 ξ 7.5 ξ 16.5 0
The "solve" function call can be assigned to another variable, e.g.,
2
λ 3 λ 25 0
2 3.386
ξ solve 2 x 5 x 6 0, x , whose solution is: ξ 2
0.886 25 β 76 0
3
3 t 2 t 5 0
Other functions used in mathematical expressions:
================================================= 4 2
The "Functions" palette in the right-hand side of the SMath Studio interface 3 t 2 t 5 0
shows a number of mathematical functions that can be used in building 4
mathematical expressions: log (logarithm of any base), sign, sin, cos, ln 5 η 5 η 5 0
(natural log), arg (angle for a complex number), tan, cot, exp, and %
(percentage).
0.2
e 0.8187
(2) By default, the arguments of trigonometric functions (sin, cos, tan, cot)
must be given in radians, e.g.,
π π
sin 0.866 cos 0.7071
3 4
Symbols (6), (7) and (8) apply to the production of graphs. These three
symbols will be discussed in another section. Here, we concentrate on
describing symbols (1) through (5) in the "Functions" palette.
11 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
To enter a summation, product, derivative, or definite integral symbol, simply
select the location of the entry point in the worksheet and click the
corresponding symbol. Symbols (1), (2) and (4) will show four placeholders,
while symbol (3) will show two placeholders. Summations, products, and
integrals can be calculated using a numerical evaluation (=) or the symbolic
evaluation (Cntl+.). Derivatives can only be evaluated using symbolic
evaluation (Cntl+.).
10 10
1 1 1968329
1.5498
2 2 1270080
= k= 1 k k= 1 k
d 2
d 2 1 2 η d 1
d η ln η tan ζ
dη η dζ 2
cos ζ
Symbol 4, integral, as first clicked Example:
3
3 1 631970953161275
1 ds
d d s 1.249 2 505963005627923
2 0 1 s
0 1 s
4.2
0
The result is now: w 6.2
0
4.5
2 - Define, for example, the element in the third row and fourth
column of a matrix R using "el", so as to create a 3x4 matrix:
Listing R we get the required 3x4 matrix with all elements, but
the very last one, as zero:
0 0 0 0
If you now want to enter other R 2
R 0 0 0 0 11
values in the zero elements,
0 0 0 4.3 use the "el" function with R 3.1
23
other indices within the 3x4 EXERCISES: Use function "el" to create the
matrix, e.g., R 7 following vectors and matrices:
32
2 1
2 0 0 0
0 2 1 2
The result is now: R 0 0 3.1 0 uA 0 1 0
1 uB 3 Ac 3 4 Bc
0 7 0 4.3 1 0 1
4 4 5 6
5
__________________________________________________________________________
Notes: (1) Instead of function "el" you can simply type the name of
the vector (or matrix), then type [ and enter the largest subindex
(or subindices for a matrix), followed by <space bar> and an assignment.
Examples:
In this example, even though, both the expressions for m3, with subscript EXERCISES: Use brackets to create the
and subindex, look the same, they produce different mathematical objects. following vectors and matrices:
5
1
4 6 5 1 0 1
(3) A better way to build a vector or matrix, rather than using function 2 Fc
"el", is by using the "Matrix" button (first button) in the "Matrices" vA vB 3 Ec 4 3 0 1 0
3
palette, or, equivalently, typing "Cntl+m". This produces an entry form 2 2 1
5
as illustrated below: 1
By default, the entry form shows 3 Rows and 3
Columns. You can change these values to any
positive number. Remember:
14 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
1.2
For example, for this case we can use: v 6.5
8.7
1 0 0 0
0 1 0 0
identity 4
0 0 1 0
0 0 0 1
Alternatively, you can type the
name of the function at the
insertion point, and enter the
corresponding arguments to use EXERCISES: Calculate the
the function. following hyperbolic and
inverse functions:
For the purpose of writing mathematical expressions, I suggest, at this point, to
1 - sinh(2.3) :
stick to the following functions categories: Complex number, Trigonometric,
2 - cosh(1.2) :
Hyperbolic. Also, use those in the "Arithmetic" and "Functions" palettes in the right-
3 - asinh(2.4) :
hand side panels of the interface. Don't forget, also, to use the Boolean equal sign
4 - acosh(0.5) :
(Cntl+=) to write unevaluating expressions and for use with the "solve" function in
solving equations.
15 / 22
solving equations. 25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
m
[t:20's] t 20 s [v.0:5.2'm/'s] v 5.2
0 s
(2) You can define your own units. For example, you can define the hecta-
meter as follows:
['hm:100'm] hm 100 m
ft gal
['fps:'ft/'s] fps ['gpm:'gal/'min] gpm
s min
EXERCISE: Solve the following problem:
(3) The result of calculations involving units will default to units of the Thermal expansion problem [1].
SI (International System), for example: Determine the thermal expansion ∆L
suffered by a rod of length L.0 = 10 cm
if the initial temperature is T.0 = 20
Define: [D:5'in] D 5 in Check: D 0.127 m
centigrade, the final temperature is
T.f = 40 centigrade, and the coefficient
Define: [V:= 2.5'fps] V 2.5 fps Check: m of thermal expansion is α.S = 0.005
V 0.762
s cm/centigrade. Also, determine the final
2 3 length, L.f, of the rod after the
D m
Calculate: [Q:V*π*D^2/4] Q V π Result: Q 0.0097 expansion. Use the equations:
4 s
∆L = α.S*(T.f-T.0), and L.f = L.0 + ∆L
(4) To convert your result to, say, gpm, click in the field containing the
result. You will see a placeholder to the right of the result (see figure Calculate using units.
below -- this is only a figure, not a field where you can make any changes):
Click on the placeholder, and type the units you want to replace, e.g.,
'gpm (using the 'gpm units defined earlier), to get:
Q 152.9996 gpm
(5) You cannot use units in any term in an equation to be solved by the
"solve" command. For example, to solve the quadratic equation with:
2
s s
a 2 b 5 c 6
2 m
m
17 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
2 m
b b 4 a c 0.886
x , i.e., s
2 a x
m
3.386
s
2
solve a x b x c 0, x
If you click on the equation above, you'll get the error message: "No
real roots".
Thus, you can only use "solve" to find the solution to an equation not
involving units. For the case of interest, shown above, we could try
the following:
a 2 b 3.386
solve x x c 0, x Result in 'm/'s
2 s 0.886
s
m
2
m
EXERCISE: Solve the following problem:
Open Channel Flow in a Trapezoidal Channel.
By dividing a by 's^2/'m^2 and b by 's/'m we are effectively eliminating
the units from the equation, and allowing "solve" to deal with a unitless
expression. The results shown are in 'm/'s, as expected.
2 2
s s s s
2 0.1858 5 1.524
2 2 m ft
m ft -------------------------------------------
NOTE: Before solving this problem, define
2 the following unit: 'cfs = 'ft^3/'s, i.e.,
s s
a 0.1858 b 1.524 cfs = cubic feet per second.
i.e., 2 ft
ft -------------------------------------------
[1]. A Trapezoidal channel with a bottom
Now, I'll use the original "solve" function called shown above, namely: width, b = 5 ft, and a side slope, m = 1/2,
is laid on a slope, S.0 = 0.00023, and lined
a 2 b 3.3861 with concrete (Manning's n = 0.012). For a
solve x x c 0, x With result
2 s 0.886 discharge Q = 20 cfs, determine the depth of
s in 'm/'s
m flow, y, using Manning's equation:
2
m
18 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
a 2 b 11.1092
We can also use: solve x x c 0, x With result
2 s 2.9068
s in 'ft/'s
ft
2
ft
ft m ft m
Let's check: 11.1092 3.3861 , and 2.9068 0.886
s s s s
In units of the English System, the
When using "solve," therefore, my advice is to use dimensionally consistent constant C.u is C.u =
equations, without units, but making sure to track the proper units in the 1.486 ft^(1/3)/s.
result. Consider thefollowing application:
To solve this problem use the
m m "solve" function, with Manning's equation
t 20 s v 72.7 t 5s a 4.5
s 0 t 2 (see above), but eliminating the units by
s re-writing the equationas follows:
a t
v t t 0
solve v ,v 5.2
m 0 m s s 0
s 2
s
The variable we are solving for, namely, v.0, is not accompanied by units.
The results should be in the proper units of 'm/'s.
Alternatively, you could define the values of the known variables as pure
numbers, with the labels for the units typed in text fields next to the
numerical values, e.g., Solve for y, the result should be in ft.
2 33
f0 x x 2 f0 2.5
Example: 4
19 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
* You can evaluate the function at a number: f0 2.4 2.7857
* You can evaluate the function at a variable previously defined: EXERCISES: Define a function
f1 2 , 6 15 f1 2 , 3 20 α 2 β 5 f1 α , β 4
4.5826
solve f1 2 , y 0, y
4.5826
EXAMPLE - Defining the pmf and CDF for the Binomial distribution:
=================================================================
For a discrete random variable X that follows the Binomial distribution with
parameters n (positive integer) and p (0<p<1), the probability mass function
(pmf), f(x), is given by:
n! x n x
f x p 1 p , for x = 0, 1, ..., n
x! n x !
The cumulative distribution function (CDF), F(x), is, in turn, defined as:
x
F x f k , for x = 0, 1, ..., n
k= 0
20 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
For particular values: n 10 p 0.30 we can calculate some values of EXERCISE - For the Binomial
the pdf and CDF: variable used in the EXAMPLE, with
n = 10, p = 0.3, calculate the
f 9 0.0001 following probability:
f 3 0.2668 f 5 0.1029 f 7 0.009
F 3 0.6496 F 5 0.9527 F 7 0.9984 F 9 1
EXAMPLE - Defining the pdf and CDF for the Exponential distribution:
====================================================================
For a continuous random variable X that follows the exponential distribution
with parameter µ (a positive real number), the probability density function
(pdf), f(x), is given by:
µ x
f x µ e , for x ≥ 0 Compare the last result with
that given by:
______________________________________________________________________________
NOTE: Typically, λ is used as the parameter for the exponential distribution.
In this worksheet I have already used variable λ, which currently holds the
value:
λ 0.3 m
Thus, to prevent conflicts with the variable λ in defining the pdf above, I
decided instead to use the variable µ as the exponential distribution parameter.
________________________________________________________________________________
For the following value: µ 4.5 we can calculate some values of
the pdf as follows:
x
F x f t dt , for x = 0, 1, ..., n
0
However, attempts to calculate F(x) for selected values of x fail:
EXERCISE - For the Exponential variable
used in the EXAMPLE, with µ = 4.5,
F 0.1 F 0.5 F 1.0 F 1.5 calculate the following probability:
NOTE: The reason why this definition of F(x) fails to produce values is that I
have used already variables x, and t. Thus, these variables already have these
values associated with them:
21 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
m
0.886
s
x t 20
m
3.386
s
SMath Studio tends to replace these specific values in the calculation of F(x)
as defined above. Redefining F(x), using xx instead of x, and tt instead of t,
solves the problem as illustrated below:
xx
F xx f tt d tt Compare the last result with that given by:
0
Calculating F(x) for different values of x now produces the right results:
22 / 22