0% found this document useful (0 votes)
71 views

Intro To SMath Studio 102011

This document provides an introduction to using SMath Studio for mathematical calculations and solving algebraic equations. It discusses downloading SMath Studio, basic operations in the SMath Studio worksheet like entering text and calculations, using mathematical symbols, assigning values to variables, and the differences between numerical and symbolic evaluation of expressions. The document contains exercises for the reader to practice these skills in SMath Studio.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views

Intro To SMath Studio 102011

This document provides an introduction to using SMath Studio for mathematical calculations and solving algebraic equations. It discusses downloading SMath Studio, basic operations in the SMath Studio worksheet like entering text and calculations, using mathematical symbols, assigning values to variables, and the differences between numerical and symbolic evaluation of expressions. The document contains exercises for the reader to practice these skills in SMath Studio.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

25 Jun 2012 19:51:39 - IntroToSMathStudio102011.

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)

Download SMath Studio by following this download page link:


http://en.smath.info/forum/yaf_topics12_Download-SMath-Studio.aspx

* 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"

* For Windows select either:


- "SMathStudioDesktop.0_89_8.Setup.msi"to install in your computer, or
- "SMathStudioDesktop.0_89_8.Portable.exe"to carry in a portable drive

Try the Tutorials - developed by yours truly:


http://smath.info/wiki/Tutorials.ashx

Study these Examples for applications:


http://smath.info/wiki/Examples.ashx

Follow postings in the Wiki - information and discussion on the software:


http://smath.info/wiki/AllPages.aspx

These instructions are also available at my SMath Studio web site:

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 select the number of decimals to display in results: Tools>Options


Set "Decimal places", for example, to 4

* 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 ->

* To enter a numerical calculation: click on the worksheet at the point


where you want to start the calculation, then enter the calculation
you desire - Example: Click somewhere in the space immediately below,
then, type: 5 + (1 + sqrt(3 / 2 + sin ( p <Cntl-G> / 3 =

Enter your
solution here ->

* The palettes on the right-hand side of the screen are used to enter
mathematical items into your worksheet.

* To show/hide the palettes on the right-hand side of the screen, click


on the very last icon in the control panel above. When you hoover
your mouse over this icon the legend "Show/hide side panel" shows up.
The icon looks like this:
NOTE: From here down, EXERCISES are shown to
the right of the instructions or EXAMPLES
* To enter special symbols, such as infinity, pi, i, absolute value, given. To gain practice in the use of SMath
square root, etc., click on the corresponding symbol in the "Arithmetic" Studio, solve the EXERCISES as shown below:
palette on the right-hand side of the screen.
EXERCISES: Click on an empty space in the
Alternatively, use the following keystrokes (see Figure 1, below): worksheet,then type the keystroke sequence
shown between brackets:
(1) Infinity: Cntl+Shift+Z 1 - [1/<Cntl+Shift+Z> <Cntl-.>]:
(2) Pi: Cntl+Shift+P, or p <Cntl+G> 2 - [sin(p <Cntl+G> /3 =] :
(3) i (imaginary unit): i 3 - [1/5+3*i=] :
(4) Raise to a power: ^ 4 - [p <Cntl+G> ^ 2/3=] :
(5) Absolute value: abs( 5 - [abs(2+3*i)=] :
(6) Square root: \ or type sqrt( 6 - [sqrt(-5=] :
(7) N-th root: Cntl+\ 7 - [<Cntl+\>3(top)27(bottom)=]:
(8) Symbolic evaluation (->): Cntl+. 8 - [2.3^3 <Cntl+.>] :
(9) Factorial: ! 9 - [20!/5!*15!=] :
(10) Assignment to a variable : (produces :=) 10- [a:sqrt(125)] :
(11) Numeric evaluation: = 11- [a=] :

Other mathematical symbols (0-9 . + - * / ,) can be entered


directly from the keyboard.

2 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm

(12) The plus/minus operator produces a list of two values, as


EXERCISE: Click on an empty space in the
illustrated here:
worksheet, then type the keystroke sequence
shown between brackets:
3
3
3 [-3 <Click ±> sqrt(3^2 <space bar> -4*1*2
<space bar> <space bar> <space bar >
<space bar> / 2 =]:

<----------------------------+
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:

x, x1, x_1, x2y, xy, Xxy, X_23_y, Velocity_of_the_moon,etc.

* To define a variable: (1) click in an empty space in the worksheet,


(2) type the name of the variable and use the assignment symbol (:)
Then, (3) enter a value or expression to the right of the resulting
assignment symbol (:=). (4) Click somewhere else in the worksheet.

The value to the right of the assignment symbol (:=) will now be
assigned to the variable name to the left of it.

Some examples of variable assignments are shown below:

x 2 y1 1.123 Radius_of_ball 2 13.5

3 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm

* To see the value of a variable previously defined, type the


variable name to the right of or below the variable definition,
followed by the equal sign (=) or by the symbolic evaluation
sign (->). Examples:
1123
y1 1.123 y1
x 2 x 2 1000
3
2
2 27
Radius_of_ball 5.6742 Radius_of_ball
2

* Numerical vs. symbolic results: EXERCISES: Click on an empty space in the


=============================== worksheet, then perform the required variable
NOTE: Using = produces a numerical (floating-point) result, assignment. Afterwards, show the contents of
while using -> produces a symbolic result (ratio of integers, the variable assigned by using either a
or expression involving radicals and fractions). numerical evaluation (=) or a symbolic
evaluation (Cntl+.):
* Unevaluated variables:
====================== Variable__name Value__to__assign
If a variable has not been previously evaluated, it will show x01 38.2
an empty placeholder in an assignment statement if we try to u_A sqrt(-23 <space bar>/3)
list that particular variable name. For example, at this point b 3.5
variable "Width" has not been evaluated yet, so, typing m 1.2
"Width = " [Enter] will produce: y 0.5
Width

Thus, SMath Studio indicates that no value is yet assigned to


that variable, and, by default, produces an assignment state-
ment to evaluate that variable.

* 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

* Using Greek characters for variables and expressions:


=====================================================
There are two "Symbols" palettes shown in the panel to the right-
hand side of the SMath Studio worksheet. The "Symbols(α-ω)"
palette contains lower-case Greek letters, while the "Symbols(Α-Ω)
palette contains upper-case Greek letters. The two Symbol palettes
are reproduced in Figure 2, below, together with a palette showing
the English letters "equivalent" to the Greek letters by their
position. Thus, the English letter p (or P) is "equivalent" to,
or corresponds to, the Greek letter π (or Π), pronounced "pi".

Figure 2. "Symbol" palettes with Greek letters and their


English "equivalent" letters.

To enter a Greek letter in text, into a variable name, or into an


expression, simply select the point of insertion in the worksheet
and then click on the character you want to insert. Examples:

In text: Next, we defined the values of α and β:


Into a variable name: α 2 β 4
Into an expression: δ α α β , i.e., δ 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

* Using variables with subscripts:


===============================+
Suppose you want to solve the following problem from physics:

We can simply choose to not use subscripts, instead using two-


character variable names for the subscripted variables, e.g.,

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

t 20 [v.0:5.2] v 5.2 [t.0:5] t 5 [a.t:4.5] a 4.5


0 0 t

[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

[Radius_of_ball : 2 + sqrt 13.5] Do not include units in the calculations.


Radius_of_ball 2 13.5

[Moment_of_inertia : (x + y1 <space bar> <space bar>) ^ 2]


2
Moment_of_inertia x y1
[d <Cntl+G> : a <Cntl+G> * ( a <Cntl+G> + b <Cntl+G>]

δ α α β
[v:v.0+a.t*(t-t.0)]

v v a t t
0 t 0

Techniques for building mathematical expressions:


=================================================
The examples above include some particular character sequences, namely:

sqrt to enter the square root symbol


<Cntl+G> to enter Greek letters
<space bar> to select wider expressions or expressions between parentheses

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.

Two-dimensional (2D) mathematical expressions:


==============================================
The mathematical expressions produced by SMath Studio are referred to as
two-dimensional (2D) math, namely, exponents, fractions, etc., will be shown
in their proper place as in textbook style. Here's another example:

[t <Cntl+G> : t <Cntl+G>.0+a <Cntl+G>.c * (T.f-T.0 <space bar> <space bar>


/ sqrt(1+ abs( D <Cntl+G> T /b <Cntl+G> <space bar> <space bar> ^3 <space bar>
<space bar> <space bar> <space bar> ^ 3/2]
3
2
T T
f 0
τ τ α τ
0 c 3
∆T
1
β

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.

Using the Boolean equal sign for non-evaluating expressions:


===========================================================
The example above is an assignment statement. The variables in the right-hand
side of the assignment statement should be available beforehand in order for
this statement to produce a result. In this example those variables are un-
defined. If you click on the expression τ= to the right the message "τ.0 - not
defined" will be shown.

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

[t <Cntl+G> <Cntl+=> t <Cntl+G>.0+a <Cntl+G>.c * (T.f-T.0 <space bar> <space bar>


/ sqrt(1+ abs( D <Cntl+G> T /b <Cntl+G> <space bar> <space bar> ^3 <space bar>
<space bar> <space bar> <space bar> ^ 3/2]
EXERCISE: Type the following expression
3
in SMath Studio, as a non-evaluating
2 expression (i.e., use a Boolean =)
T T
f 0
τ τ α
0 c 3
∆T
1
β

The result is simply a mathematical expression that includes no evaluations.

Using the Boolean equal sign with function "solve":


===================================================
One other use of the Boolean equal sign is to build a mathematical equation
to be solved using function "solve". For example, the quadratic equation:
2
2 b b 4 a c
a x b x c 0 has the well known solution: x
2 a

Thus, if we take: a 2 b 5 c 6 we calculate solutions as follows:

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).

To type any of these functions in an expression or to evaluate them,


simply click on the corresponding function name in the "Functions" palette.
All these functions can also be typed, for example: EXERCISES: Calculate the following:
1 - log base 5 of 625 :
[log(10,2):] log 10 3.3219 ,i.e., log 10 of base 2
2 2 - sign of -2.5 :
sign 10 1 3 - sine of 1.75 rad :
4 - cosine of 0.85 rad :
sin 1.2 cos 1.2 1.2944 5 - natural log of 125 :
6 - natural log of -124:
arg 4.5 3.2 i 0.6181 7 - ln(1+3*i) :
ln 10 2.3026 8 - exp(2.35) :
9 - exp(1-i) :
exp 0.2 0.8187 10- 5% of 120 :

perc 20 , 5 1 , i.e., 20% of 5


10 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
Notes: (1) The letters i (imaginary unit), π (ratio of circumference to diameter
in a circle), and e (base of natural logarithms), are predefined constants and
can be used directly in mathematical expressions. Thus, the last statement above,
namely "exp(-0.2) = 0.8187" can also be written as:

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

If you want to use degrees in your arguments of trigonometric functions, type


EXERCISES: Calculate the following:
the number of degrees followed by 'deg (the quote must be included),e.g.,
1 - ln(e^(-2.5)) :
[sin(60'deg)=] [cos(45'deg)=] 2 - sin(1.5)^2+cos(1.5)^2:
3 - sin(28.5 deg) :
sin 60 deg 0.866 cos 45 deg 0.7071 4 - tan(123.6 deg) :

Additional functions in the "Functions" palette: EXERCISES: Use function "solve" to


================================================ solve the following equations:
Besides the 10 functions listed above, the "Functions" palette also includes
the following 8 functions (see Figure 3, below): ln r 1.5 0
x
1 - summation 2 - product 3 - derivative 4 - definite integral e 0.25
5 - element of a vector 6 - multiple values
7 - two-dimensional (2D) graph 8 - three-dimensional (3D) graph 2 ξ ξ
e e 3
τ
2 τ
e ln 3
2

<----------------------------+ sin r cos r 0.25 in 0 < r < 2π


Figure 3. Details of the
"Functions" palette.
sin φ
0.1 0 in -π < 0 < p
φ

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+.).

Here are some examples:


EXERCISES: Calculate the following:
Symbol 1, summation, as first clicked - Example:

10 10
1 1 1968329
1.5498
2 2 1270080
= k= 1 k k= 1 k

Symbol 2, product, as first clicked - Example:


8 8
r 2 18.9737 r 2 3 4 5 6
= r= 5 r= 5
Symbol 3, derivative, as first clicked - Examples:

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

Symbol 5 produces two placeholders, a main placeholder to contain the


name of a vector and a subindex placeholder to contain a numerical
value representing the order of an element in the vector. We present
two examples here:

1 - Define, for example, the 5-th element of a vector w using "el", so


as to create a new vector of 5 elements: , for h = 2

[el(w,5 <space bar> :-4.5] w 4.5


5

If we now list w, we get a column vector of 5 elements with all zero


elements, but the last one:
12 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm

0 If you now want to enter other


values in the zero elements, w 4.2
0 1
w 0 use the "el" function with
indices 1 through 4, e.g., w 6.2
0 3
replacing elements 1 and 3:
4.5

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:

[el(R,3,4 <space bar> : 4.3 R 4.3


34

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:

[s[4 <space bar> : 5] s 5 to produce 0


4
0
s
0
5
13 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm

Other values can be entered by a similar approach, e.g.,

[s[2 <space bar> : 3] s 3


2
[s[1 <space bar> : -2] s 2
1
2
The vector s is now: 3
s
0
5

(2) Variable names with subindices, created by either using "el" or


by using brackets ([), are different than variable names with subscripts,
created by using the period (.). Example:

- subscript - use (.): [m.3:4] m 4 and m m not defined


3

- subindex - use ([): [m[3 <space bar> :4] m 4 and 0


3
m 0
4

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:

- column vector: Rows= n Columns= 1


- row vector: Rows= 1 Columns= m
- nxm matrix: Rows= n Columns= m

As an example, use: [ v: <Cntl+m> Rows: 3 Columns:1 [Insert]]

Next, click on each placeholder and enter the


This produces: v individual values of the element. When done,
click outside of the vector.

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

(4) Detailed explanation of the "Matrices" palette, and operations with


matrices will be provided later.
__________________________________________________________________________
EXERCISE: Use the "Matrix" button
Functions from the "Function" menu:
to create the following vectors and
===================================
matrices:
Click on the button [f(x)] in the menu bar to generate a "Function" menu.
The menu looks as shown in the figure below: 1
0
2 6 5
The "All" category will list 1
all functions available in wA wB 3 Hc 5 6
0
SMath Studio. Click in any 2 6 5
5
other category to see a listing 1
of functions specific to that
category. Click on a specific 1 1 1
function and an "Example" and Kc
2 1 3
a "Description" of the selected
function will be displayed. Follow
the Example and Description to
use the function.

To insert the function, select the


insertion point, then select the
function name. Then, click the
[Insert] button. Here's an example
of inserting function "identity":

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

EXERCISE: Calculate the


following inverse trigonometric
5__-__Using__units functions:
The "Unit" menu in the menu bar is the blue icon that looks like a funnel located 1 - asin(0.8) :
immediately to the right of the "Function" menu [f(x)]. To insert units, type the 2 - acos(0.6) :
numerical value accompanying the units, then click on the "Unit" menu, and select 3 - atan(3.5) :
the proper unit to insert. The "Unit" menu looks as follows:

Select the "Dimension" in the EXERCISES: For the following


left-hand side list, and the "Unit" complex numbers:
from the right-hand side list. In
this figure I have selected the z1 = 3+2*i z2 = -4+6*i
"Length" dimension and the "Meter z3 = 5-8*i z4 = π+sqrt(2)*i
('m)" unit. If I wanted to define
a variable, say λ = 0.3 m, I would Calculate the following:
use:
1 - Re(z1), real part :
[l <Cntl+G> : 0.3 <Unit menu, 2 - Im(z2), imag. part:
select Meter> press [Insert]] 3 - abs(z3), modulus :
4 - arg(z4), angle :
λ 0.3 m
Alternatively, simply type:
EXERCISES: Use functions "pol2xy"
[l <Cntl+G> : 0.3 'm]: λ 0.3 m and "xy2pol" to convert from polar
to Cartesian coordinates, or
Thus, if you know the symbol for the unit to enter you only need to type ' followed from Cartesian to polar coords.
by the unit symbol after the numerical value. These functions are available
in [f(x)] under "Complex number":
For example, we repeat the solution of this physics problems, but now using units:
1 - Convert r = 3, θ = π/3 to (x,y):
_________________________________________________________________________________

2 - Convert x = -5, y = 2, to (r,θ)

m
[t:20's] t 20 s [v.0:5.2'm/'s] v 5.2
0 s

m EXERCISE: Solve the following problem:


[t.0:5's] t 5s [a.t:4.5'm/'s^2] a 4.5
0 t 2 Curvilinear motion problem: [2]. Determine
s
the normal acceleration, a.n, of a particle
Solution: moving on a circular path of radius, ρ = 100 m,
if the speed of the particle is v = 20 m/s.
[v:v.0+a.t*(t-t.0)] v v a t t m
0 t 0 v 72.7 Use the equation: a.n = v^2/ρ. Calculate
s
using units.
16 / 22
25 Jun 2012 19:51:39 - IntroToSMathStudio102011.sm
_________________________________________________________________________________
Notes: (1) Check the list of units in the "Unit" menu to make sure that the
particular unit you are seeking is defined. For example, in the units of
"Length" you find km, dm, m, cm, mm, µm, nm, pm. So, if you needed to use,
say, a hm (hectameter = 100 m), such a unit will not be available.

(2) You can define your own units. For example, you can define the hecta-
meter as follows:

['hm:100'm] hm 100 m

In Fluid Mechanics/Hydraulics,we could define a unit of flow velocity, the


fps (feet per second), or a unit of discharge, the gpm (gallons per minute),
as follows:

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

We can use the formula:

2 m
b b 4 a c 0.886
x , i.e., s
2 a x
m
3.386
s

Since this result was obtained through a simple algebraic calculation,


the results are showing with the proper units. However, an attempt to
solve the equation using "solve" will fail:

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.

Let's check what happens if we use values of a and b in units of the


English System -- Here I'm using the equivalent values:

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.

t 20 s v 72.7 m/s t 5 s a 4.5 m/s^2


0 t

Then, use: solve v v a t t ,v 5.2 m/s


0 t 0 0
_____________________________________________________________________________________
6__-__Defining
__your__own__functions
Above we showed how to use the functions in the "Functions" palette as well as in the
"Function" menu [f(x)]. These functions, which are readily available in SMath Studio
for your use, are referred to as "predefined functions." Functions defined by the user
are, of course, "user-defined functions."

A user-defined function can be defined by using the general format:

<function_name>(<argument(s)>)= <expression involving arguments(s)>

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

h(y) = 1/(1+y^2), then


ξ 1.34 f0 ξ 1.9482 9489
f0 ξ Evaluate h(2) (1)
2500 Evaluate h(π/2) (2)
(3)
Evaluate h(3.5)+h(1.2)^2
* You can use the function in an equation, e.g.,: (4)
Solve the equation: h(y)=0.05
using function "solve"
(5) Determine an expression for the
2.0616 derivative of h(y) with respect
solve f0 t 2.5 0 , t
2.0616 to y. Use symbolic evaluation.
(6) Calculate the summation of
You can define a multivariate function (i.e., a function of more than one variable), sqrt(h(k))for k from 1 to 5.
for example: (7) Calculate the definite integral
2 2 of h(ξ)^2 from ξ = 1 to 5
f1 x , y x y 25

Evaluations of f1(x,y) are shown next:

f1 2 , 6 15 f1 2 , 3 20 α 2 β 5 f1 α , β 4

You can use the function in an equation, e.g.,

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:

f 0.1 2.8693 f 0.5 0.4743 f 1.0 0.05 f 1.5 0.0053

The cumulative distribution function (CDF), F(x), can be defined as:

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:

F 0.1 0.3624 F 0.5 0.8946 F 1.0 0.9889 F 1.5 0.9988


_______________________________________________________________________________
_______________________________________

22 / 22

You might also like