KOS 1110 Computers in Science
Assignment 4 - Questions in Introduction to Maple
Due date Friday, 10-9-2004
5pm

1. Hierarchy of arithmetic operations: Use your own examples (at least three examples and execute them in

    maple) to prove which arithmetic operations are carried out first in Maple and if they are of equal priority, in

    which directions they are carried?      

   

  # The answers obtained were based on the hierarchy of arithmetic which give priority beginning with parentheses ( ),

      exponents(^), multiplication(*) and division(/), addition(+) and substraction(-).
   # If the operation are equal priority like multiplication and division or addition and substraction, we must solve it from left to

      right.

 

     Example 1

>    5*3-6+7/2;

25/2

   # From the equation, multiplication (*) and division (/) need to be solved first, followed by substraction (-) and addition

      (+).The operation was carried out from left to right.

    Example 2

>    5*8/4-10+13;

13

  # From the equation, multiplication (*) and division (/) have the first priority compared to others and it is followed by

     substraction (-) and addition (+). The operation was carried out from left to right.

    Example 3

>    9-4*3+10;

7

  # From the equation, multiplication (*) operation need to be solved first, followed by substraction (-) and addition (+) and the

     operation was carried out from left to right.

2. Using your own examples (one example each and execute them in maple) clearly bring out all the differences

    between the following maple symbols and commands:
   a) ; and :
    b) = and :=
    c) ? and ???
    d) expression and function
    e) sum and add

   a) ; and :

        Example

  

>    restart;

>    2+3-4*5;

-15

>    2+3-4*5:

    #  (;) and (:) are to execute the commands but the differences between them is ( ;) can display the execution result but   if we  

       use  (:) , the result will not display.

 

 b) = and :=

        Example  

>    restart;

>    a1:=4*x+2*y-3;

a1 := 4*x+2*y-3

>    a1=4*x+2*y-3;

4*x+2*y-3 = 4*x+2*y-3

    # (=) and (:=) are use to assign the statement.

       If we use (:=), the variable which is in this example having a value of the expression. But, if we use (=), the result will assign

       to the x. So that the x will have same value of the expression.

  

 c) ? and ???

       Example

>    restart;

>    ?Vector

>    ???Vector

 

    # ?     - When we execute, we get the general explanation about that topic.

    # ???  - When we execute,we get specific explanation of the topic including the examples section( if any) and all other

                 contracted.

  

  d) expression and function

       Example

  

      Function

>    restart;

>    f:=x->2*x^2-5*x;

f := proc (x) options operator, arrow; 2*x^2-5*x end proc

   

    # Function represent a function call or application of a procedures to arguments.In this expression,we refer the entire

       expression f(x) as being of  the type, while the expression f is typically not itself of typefunction. The operands of a function

       expression are the arguments.

       Expression

>    f:=2*x^2-5*x;

f := 2*x^2-5*x

  

    # Expression is only represent the arguments.

 

  e) sum and add

       Example

       Sum

>    restart;

>    Sum (k/(2*k+1), k=1..infinity)=sum (k/(2*k+1), k=1..infinity);

Sum(k/(2*k+1),k = 1 .. infinity) = infinity

   # The sum command is for symbolic summation. It is used to compute a formula for an indefinite or definite sum.If Maple

      cannot compute a closed form, Maple returns the sum unevaluated.

      Add

>    add(k/(2*k+1),k=1..10);

64157087/14549535

    

   # To add affinite sequence of values, rather than compute a formula, use the add command.

3. Use of Help facilties in Maple:  Use the help commands in Maple and explain the use of three Maple commands

    (not discussed in the class) with your own examples.

  a) Slope

      student[slope] - To compute the slope of a line

      Calling Sequence
     slope(equation)
     slope(equation, y, x)
     slope(equation, y(x))
     slope(p1, p2)

      Parameters
     equation - equation of a line
     y,x      - (optional in most cases) dependent and independent variables
     p1,p2    - two 2-dimensional points (such as [a, b] and [c, d])

    Description
 · The function slope will compute the slope of a line determined by two points, or by an equation.
 · If equation is of the form y = f(x), then the dependent variable is taken to be y, and the independent variable to be x

 . Ambiguity caused by three or more unknowns or by the use of a different form of equation is resolved by providing two

   additional arguments, y and x, the names of the dependent and independent variables, respectively.
 · The command with(student,slope) allows the use of the abbreviated form of this command.

    Examples

 

>    restart;

>    with(student):
slope(y = 2*x+1);

2

>    slope(y = a*x+1, y, x);

a

>    slope(3*y+5 = x-1, x, y);

3

>    slope(3*y+5 = x-1, x(y));

3

  b) Statistics

       stats[transform, frequency]  - Frequency of Each Data Item
     
Calling Sequence
     stats[transform, frequency](data)
     transform[frequency](data)
     Parameters
     data - statistical list
   
 Description
   · The function frequency of the subpackage stats[transform, ...] replaces each data point of data by its frequency or weight.     

   · The order of the data items is not changed.  
   · Statistical data items in a list have a weight, obtained using transform[frequency] and a value, obtained using

     transform[statvalue]. One can obtained the total frequency, or total weight, using describe[count]. All frequencies in a

     statistical data list can be changed, proportionally, using the transform[scaleweight].
   · The command with(stats[describe],frequency) allows the use of the abbreviated form of this command.
 
  
  Examples

>    restart;

>    with(stats):
transform[frequency]([6]);

[1]

>    transform[frequency]([Weight(6,7)]);

[7]

>    transform[frequency]([6..7]);

[1]

>    data:=[Weight(6,13),missing, 7, Weight(16..16,6), 19..21];

data := [Weight(6,13), missing, 7, Weight(16 .. 16,6), 19 .. 21]

>    transform[frequency](data);

[13, 1, 1, 6, 1]

  c) bernoulli  

    - compute Bernoulli numbers and polynomials
     Calling Sequence
     bernoulli(n, x)
    Parameters
     n      - non-negative integer
     x      - (optional) expression
    Description
   · The bernoulli(n) function computes the nth Bernoulli number. Bernoulli numbers come from the coefficients in the Taylor

      expansion of x/(e^x - 1).
  · The bernoulli(n, x) function computes the nth Bernoulli number, or the nth Bernoulli polynomial, in the expression x.
    The nth Bernoulli number is defined as bernoulli(n,0).
    The nth Bernoulli polynomial is defined by the exponential generating function:
     
t*exp(x*t)/(exp(t)-1) = sum( bernoulli(n,x)/n!*t^n, n=0..infinity ) .

     Examples

>    restart;

>    bernoulli(3);

0

>    bernoulli(3,x);
 

1/2*x+x^3-3/2*x^2

>    bernoulli(3,1/2);

0

4. Use of units and Scientific Constants: Select any three problems involving different types of units from your  

    textbooks and carry out the complete calculations including the units using Maple.  State the problem fully and

    comment whether Maple gives the correct final answer along with appropriate units.  (Refer the examples

    discussed in the class)

  a) Decay activity for a sample of iodine-131.

      The expression for the activity is defined as A where A0 is the initial activity, is the mean lifetime of the isotope and and the t

       is the elapsed time.

>    restart;

>    with(ScientificConstants);

[AddConstant, AddElement, AddProperty, Constant, Element, GetConstant, GetConstants, GetElement, GetElements, GetError, GetIsotopes, GetProperties, GetProperty, GetUnit, GetValue, HasConstant, HasEleme...
[AddConstant, AddElement, AddProperty, Constant, Element, GetConstant, GetConstants, GetElement, GetElements, GetError, GetIsotopes, GetProperties, GetProperty, GetUnit, GetValue, HasConstant, HasEleme...

>    A:=A0*exp(-lambda*t);

A := A0*exp(-lambda*t)

    The mean lifetime is related to the halflife by lambda  = 0.693/H

>    lambda:= 0.693/evalf(Element(I[131],halflife));

lambda := .1000141319e-5

    Plot with A0=1.

>    A0:=1;

A0 := 1

>    plot(A, t=0..6e6, labels=["time(s)","Activity"]);

[Maple Plot]

 b) What is the energy of an electron, E?

>    restart;
with(Units);

[AddBaseUnit, AddDimension, AddSystem, AddUnit, Converter, GetDimension, GetDimensions, GetSystem, GetSystems, GetUnit, GetUnits, HasDimension, HasSystem, HasUnit, Natural, RemoveDimension, RemoveSyste...
[AddBaseUnit, AddDimension, AddSystem, AddUnit, Converter, GetDimension, GetDimensions, GetSystem, GetSystems, GetUnit, GetUnits, HasDimension, HasSystem, HasUnit, Natural, RemoveDimension, RemoveSyste...
[AddBaseUnit, AddDimension, AddSystem, AddUnit, Converter, GetDimension, GetDimensions, GetSystem, GetSystems, GetUnit, GetUnits, HasDimension, HasSystem, HasUnit, Natural, RemoveDimension, RemoveSyste...

>    mass:=9.11e-31 * kg;

mass := .911e-30*kg

>    c:=3.00e8 *m/s;

c := .300e9*m/s

>    E:=mass * c^2;

E := .81990000e-13*kg*m^2/s^2

 c) Given capacitance and inductance, find the resistance in microohms.

>    restart;

>    with(Units[Natural]);

Warning, the assigned name polar now has a global binding

Warning, these protected names have been redefined and unprotected: *, +, -, /, <, <=, <>, =, Im, Re, ^, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, argument, ceil, collect, combine, conjugate, convert, cos, cosh, cot, coth, csc, csch, csgn, diff, eval, evalc, evalr, exp, expand, factor, floor, frac, int, ln, log, log10, max, min, mul, normal, root, round, sec, sech, seq, shake, signum, simplify, sin, sinh, sqrt, surd, tan, tanh, trunc, type, verify

[`*`, `+`, `-`, `/`, `<`, `<=`, `<>`, `=`, Im, Re, Unit, `^`, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, argument, ceil, collect, co...
[`*`, `+`, `-`, `/`, `<`, `<=`, `<>`, `=`, Im, Re, Unit, `^`, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, argument, ceil, collect, co...
[`*`, `+`, `-`, `/`, `<`, `<=`, `<>`, `=`, Im, Re, Unit, `^`, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, argument, ceil, collect, co...

>   

>    resistance:=sqrt(inductance/capacitance);

resistance := (inductance/capacitance)^(1/2)

>    eval(resistance,[inductance=124.*nH,capacitance=3.52*uF]);

.5935256754e-2*1000^(1/2)*Unit([Omega])

>    evalf(%);

.1876892984*Unit([Omega])

>    convert(%,units,uOmega);

187689.2984*Unit([uOmega])

5. Find out the dimensions of three different physical properties using Maple.

>    restart;

      a)acceleration

>    with (Units);

[AddBaseUnit, AddDimension, AddSystem, AddUnit, Converter, GetDimension, GetDimensions, GetSystem, GetSystems, GetUnit, GetUnits, HasDimension, HasSystem, HasUnit, Natural, RemoveDimension, RemoveSyste...
[AddBaseUnit, AddDimension, AddSystem, AddUnit, Converter, GetDimension, GetDimensions, GetSystem, GetSystems, GetUnit, GetUnits, HasDimension, HasSystem, HasUnit, Natural, RemoveDimension, RemoveSyste...
[AddBaseUnit, AddDimension, AddSystem, AddUnit, Converter, GetDimension, GetDimensions, GetSystem, GetSystems, GetUnit, GetUnits, HasDimension, HasSystem, HasUnit, Natural, RemoveDimension, RemoveSyste...

>    GetDimension(acceleration);

length/time^2

      b) momentum    

>    GetDimension(momentum);

length*mass/time

      c) energy   

>    GetDimension(energy);

mass*length^2/time^2

6. Calculate the volume occupied by 1 kg of mercury at 25°C.

>    restart;

>    with(ScientificConstants):

>    GetElement (Hg);

80, symbol = Hg, name = mercury, names = {mercury}, boilingpoint = [value = 629.88, uncertainty = undefined, units = K], electronegativity = [value = 2, uncertainty = undefined, units = 1], density = [...
80, symbol = Hg, name = mercury, names = {mercury}, boilingpoint = [value = 629.88, uncertainty = undefined, units = K], electronegativity = [value = 2, uncertainty = undefined, units = 1], density = [...
80, symbol = Hg, name = mercury, names = {mercury}, boilingpoint = [value = 629.88, uncertainty = undefined, units = K], electronegativity = [value = 2, uncertainty = undefined, units = 1], density = [...
80, symbol = Hg, name = mercury, names = {mercury}, boilingpoint = [value = 629.88, uncertainty = undefined, units = K], electronegativity = [value = 2, uncertainty = undefined, units = 1], density = [...

>    density:=13.5336*g/cm^3;

density := 13.5336*g/cm^3

>    mass:=1*kg;

mass := kg

>    convert(1,units,kg,g);

1000

>    mass:=%;

mass := 1000

>    volume:=mass/density;

volume := 73.89016965/g*cm^3

7. Use Maple to calculate the number of water molecules in 1 g of liquid water.

>    restart;with(ScientificConstants):

>    GetElements:

>    2*Element(H,atomicweight)+Element(O,atomicweight):

>    evalf(%);

.2991509666e-25

>    convert(%,units,kg,amu);

18.01528000

>    1./%;

.5550843506e-1

>    %*evalf(Constant(N['A']));

.3342796776e23

8. What is computer algebra system and what are its advantages?    

     # Computer Algebra System or Symbolic Computation is the computation with symbols representing mathematical objects

        including :-

        a) integers,real and complex numbers

        b) polynomials

        c) derivatives and integrals

        d) system of equation, series expansion of function

     #   Advantages

         a) To obtain closed and exact form of solutions

         b) Build thousands of function

         c) Greatest option for simplifying expressions

 

9. Determine whether (y+8)/(x-2) = x+6  is linear or not ? (Hint: solve for y and comment)     

>    solve ({(y+8)/(x-2)=(x+6)},y);

{y = -20+x^2+4*x}

  

    #Comment : Since there is x power of 2 , it determines that this function is not linear function but it is a quadratic  function.

10. Show that z=1, y=2, x=3 are the solutions for x+2y-3z = 4.  (Hint: use subs )

>    restart;

>    A:=x+2*y-3*z=4;

A := x+2*y-3*z = 4

>    subs(x=3,A);

3+2*y-3*z = 4

>    subs(y=2,%);

7-3*z = 4

>    subs(z=1,%);

4 = 4

    # Proven  

11.  a) Solve the equations:  x - y = -3 and x + 2y = 3.  Plot these equations in the same graph.  Do these graphs

           cross each other?  What is the meaning of the point of intersection?

>    restart;

>    e1:=x-y=-3;

e1 := x-y = -3

>    e2:=x+2*y=3;

e2 := x+2*y = 3

>    solve({x-y=-3},y);

{y = x+3}

>    solve({x+2*y=3},y);

{y = -1/2*x+3/2}

>    plot({x+3,(-x/2)+(3/2)},x=-3..3);

[Maple Plot]

   # These graph cross each other at coordinate (-1,2). Intersection point is the point at which graph cross each other.We also

      can find the point of intersection between two line by using this command:

>    solve({e1,e2},{x,y});

{y = 2, x = -1}

  

 b) Plot the equations: y = -x - 3 and y = -x + 2.  From the graphs what can you say about the existence of solutions

     for this set of equation?

>    restart;

>    y:=-x-3;

y := -x-3

>    y:=-x+2;

y := -x+2

>    plot({-x-3,-x+2},x=-infinity..infinity);

[Maple Plot]

    # There is only one solution since both equation are linear and parallel to each other due to similar slopes.

    c) Plot the equations: x + y = 1 and 2x + 2y = 2.  From the graphs what can you say about the existence of

       solutions for this set of equation?

>    restart;

>    e3:=x+y=1;

e3 := x+y = 1

>    e4:=2*x+2*y=2;

e4 := 2*x+2*y = 2

>    solve({x+y=1},y);

{y = -x+1}

>    solve({2*x+2*y=2},y);

{y = -x+1}

>    plot({-x+1,-x+1},x=-3..3);

[Maple Plot]

   # Both equations are give the same set of point.

12. Solve the equations: 2x + y - 2z = 8, 3x + 2y - 4z = 15 and 5x + 4y - z = 1 .

>    e5:=2*x+y-2*z=8;        

e5 := 2*x+y-2*z = 8

>    e6:=3*x+2*y-4*z=15;

e6 := 3*x+2*y-4*z = 15

>    e7:=5*x+4*y-z=1;

e7 := 5*x+4*y-z = 1

>    solve({e5,e6,e7},{x,y,z});

{z = -4, y = -2, x = 1}

13. Write any equation of your own and expand it using Maple.  Factorize and simply the result and show that it

      gives back the starting equation.

      Expand

>    restart;

>    e8:=(x+3)/2*(x+2*y)/6*(5*x-3*y)/4*(3*y+x)/3;

e8 := 1/144*(x+3)*(x+2*y)*(5*x-3*y)*(3*y+x)

>    expand(%);

11/72*x^3*y+5/144*x^4+5/48*x^2*y^2-1/8*x*y^3+11/24*x^2*y+5/48*x^3+5/16*x*y^2-3/8*y^3

     Simplify

>    simplify(%);

11/72*x^3*y+5/144*x^4+5/48*x^2*y^2-1/8*x*y^3+11/24*x^2*y+5/48*x^3+5/16*x*y^2-3/8*y^3

      Factorize

>    factor(%);

1/144*(x+3)*(x+2*y)*(5*x-3*y)*(3*y+x)

14. Write any equation in with three variables (x, y and z) and solve it using Maple.  

>    e9:=4*x+5*y-z=40;

e9 := 4*x+5*y-z = 40

>    e10:=2*x-y+3*z=-18;

e10 := 2*x-y+3*z = -18

>    e11:=x-2*y+4*z=-30;

e11 := x-2*y+4*z = -30

>    solve({e9,e10,e11},{x,y,z});

{y = 43/7, z = -33/7, x = 8/7}