KOS 1110 Computers in Science
Assignment 4 - Questions in Introduction to Maple 

1.	Computer Algebra System: What is computer algebra system (symbolic computing)?
Computer algebra system or symbolic computing is a computation that carries out all the computation with not only numbers but also symbols that represent             mathematical objects such as derivatives, integers, polynomials and so on. The symbolic computation can derive the calculated answer in exact solution and not in the form of floating answer.

2.	What are the differences between symbolic computing and numerical computing?
Symbolic computation gives an exact form of answers when it deals with any mathematical problems. Otherwise, numerical computation gives floating answers to any mathematical problems and this will tend to create accumulated errors if we deal with long-complicated mathematical problems since for every intermediate answers, the numerical computation system will try to round up the answers and come up with floating answers and at the end, the final answer will be effected since the accumulated errors arising from the sequence of calculations.
> 
3.  What are the advantages of symbolic computing compared to the numerical computing?
Symbolic computation can give exact answers to every mathematical question it deals and this will avoid any accumulated errors from the floating answers. Other than that, symbolic computation also can deal with symbols representing mathematical objects such as sin, cos and so on. But for numerical computation, it can only deal with numbers and basic mathematical commands or operations.
> 
4.	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?   
> 7+8-2+3;

> 8-2*3+6/2;

> (2+1)+3*(2-1);

From the examples above, if operations used are just either addition and substraction, the calculation starts from left to right regardless of the operation used. But if in the equation, all the operations are being used (multiplication, division, addition and substraction) as well as the bracket, maple will solve the one in the bracket first, regardless the operation used and then after that it will solve the multiplication and division follows with the addition and substraction. The calculation is still from left to right direction.

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

Example a)
> with (Units);

> with (Units):
The example above shows that when we use ";" the maple will download show all the formula and constants that contain inside that particular command. However when we use this ":" , maple will download the formula and constants only without showing it. Those two signs are crucial in maple since those are the execution sign for any commands to be executed.

> restart;
Example b)
> m=3*x;

> x=3;

> m;

> m:=3*x;

> x:=3;

> m;

From the example above, it clearly shows that the equal sign is just to represent the mathematical equation in the maple version without asking the maple to solve the equation if the constant value is inserted. However, when we use ":=" sign, maple will convert the keyed in data into proper mathematical order and then maple will solve the problem given when the constant value is inserted.
> 
Example c)
The symbol of Question Mark (?) will allow the maple to open a new window with the help facilities and the description of the desired topic, together will all the examples of that related topic as well as any related topic that should be considered for further understanding.
> ?spline
spline - compute a natural spline
Calling Sequence
     spline(X, Y, z, d)
Parameters
     X,Y - two vectors or two lists
     z   - name
     d   - (optional) positive integer or string
Description
•	The spline function is obsolete and has been replaced by the CurveFitting[Spline] function. A call to spline automatically generates a call to CurveFitting[Spline]. 
•	The spline function computes a piecewise polynomial approximation to the X Y data values of degree d (default 3) in the variable z. The X values must be distinct and in ascending order. There are no conditions on the Y values. The result is returned in the form 
        piecewise( z < X[2], P[1], z < X[3], P[2], ..., P[N] )
 	which is equivalent to         if z < X[2] then P[1] elif z < X[3] then P[2] ... else P[N] end if
 	where the N = nops(X)-1 segment polynomials P[i] are of degree <= d. 
•	The segment polynomials P[1], P[2], ..., P[N] are uniquely given by the following (d+1) N conditions 
  1: 2 N interpolating conditions
       P[i]|z=X[i] = Y[i] and P[i]|z=X[i+1] = Y[i+1], i=1..N
   2: (d-1) (N-1) continuity conditions
       diff(P[i],z$k)|z=X[i+1] = diff(P[i+1],x$k)|z=X[i+1], i=1..N-1, k=1..d-1
   3: d-1 additional conditions
       diff(P[1],z$k)|z=X[1] = 0, k=d-iquo(d,2),...,d-1, and
       diff(P[N],z$k)|z=X[N+1] = 0, k=d-iquo(d-1,2),...,d-1.
 	The last two conditions give rise to what are called the ``natural splines''. For example, for cubic splines, with k = 2, we obtain the two conditions       diff(P[1],z$2)|z=X[1] = 0  and  diff(P[N],z$2)|z=X[N+1] = 0.
•	The fourth optional argument must be a positive integer (default 3) or one of the keywords linear, quadratic, cubic, or quartic. It specifies the degree of the segment polynomials. 
Examples
> 
spline([0,1,2,3],[0,1,4,3],x,linear);

> spline([0,1,2,3],[0,1,4,3],x,cubic);

See Also 
CurveFitting, CurveFitting[Spline], piecewise  
> 
When we use triple Question Mark (???), maple will open new window that only shows the examples without opening any extended information tab.
> ???spline
spline - compute a natural spline
Calling Sequence
     spline(X, Y, z, d)
Parameters
     X,Y - two vectors or two lists
     z   - name
     d   - (optional) positive integer or string
Description
Examples
> 

spline([0,1,2,3],[0,1,4,3],x,linear);

> spline([0,1,2,3],[0,1,4,3],x,cubic);

See Also 
> 
> 
> 
> 
Example d)
Function
General form is:
[>name:=variable->expression:

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

> f(3);

> 
Expession

> restart;
> f:=x^2-4*x;

> x:=3;

> f;

Example e)
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''. 
> sum('k^3', 'k'=0..30);

To add a finite sequence of values, rather than compute a formula, use the add command. For example, add(k, k=0..9) returns 45. Although the sum command can be used to compute explicit sums, it is recommended that the add command be used in programs if an explicit sum is   needed.
> add(1.4*y+3,y=2..17);

> 
6.	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. 
Example 1: convert/ln - convert arctrig functions to logarithms. convert/ln converts all inverse trigonometric functions appearing in the expression to their corresponding logarithmic form. 
> convert(arcsin(x),ln);

> 
Example 2: dilog - The Dilogarithm Function. The dilogarithm function is defined as follows: 
                  
                      dilog(x) =  int(ln(t)/(1-t), t=1..x);
> dilog(0);

> 
Example 3: exp - The Exponential Function. The exponential function, exp(x), calculates the value of E to the power of x, where E is the base of the natural logarithm, 2.718281828... . E is no longer reserved in Maple. exp(1) is used instead. 
> exp(ln*x);

> 
7.	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, but don't reuse the examples discussed in the class or in the help menu)
> 
Problem 1: The density of gold is 19.3gcm. What volume in mililiters will 20.0g of gold occupy?
> restart;
> with(ScientificConstants);

> GetElements();

> GetElement(Au,density);

> mass:=20*g;

> volume:=20*g/(19.3*g/(cm^3));

> 
Problem 2: To travel from Kuala Lumpur to India by car, one need to spend 1.5 years. How many seconds does one need to spend to travel to India from Kuala Lumpur by car?

> restart;
> with(Units[Natural]):
> t:=1.5*year;

> convert(t,units,s);

> 
Problem 3: Suppose you have a 2.0 lb block of iron at 50 C. How much heat in joules would it takes to warm this block to 75 C
> 
> restart;
> with(Units):
Warning, the name Unit has been rebound

> with(Units[Natural]):
> m:=2*lb;

> convert(m,units,g);

> evalf(%);

> spec:=0.449;

> heat:=spec*(%%)*25;

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

> restart;
> with (Units);

> GetDimensions();

> 
> GetDimension (magnetic_flux_density);

> GetDimension( torque );

> GetDimension (heat_insulation_coefficient);

9.	Calculate the volume occupied by 1 kg of mercury at 25 C.
> restart;
> with (ScientificConstants);
Warning, the name GetUnit has been rebound

> GetElement(Hg,density);

> mass:=1000*g;

> volume:=1000*g/(13.5336*g/(cm^3));

> 
10.	Use Maple to calculate the number of water molecules in 1 g of liquid water.
> restart;
> with (ScientificConstants);

> GetElement(H,atomicweight); GetElement(O,atomicweight):

> 2*Element(H,atomicweight)+1*Element(O,atomicweight);

> evalf(%);

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

> 1/%;

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

> 
> 
11. Determine whether   is linear nor not? (Hint: solve for y, and comment)
> restart;
> with(plots):
Warning, the name changecoords has been redefined

> f:=(y+8)/(x-2)=x+6;

> solve(f,{y});

> plot(-20+x^2+4*x,x=-infinity..infinity);

From the graph obtained, it is obvious that the equation given is not a linear equation.
> 
12.	Show that z=1, y=2, x=3 are the solutions for x+2y-3z = 4.  (Hint: use subs)
> restart;
> x+2*y-3*z=4;

> subs(z=1,y=2,x=3,{x+2*y-3*z=4});

> 

13.  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? 
	
      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?
 	
      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?

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

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

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

From the graphs obtained, obviously  that these 2 graphs are crossing to each other at one particular point. This point of intersection is the value of x that meets for both equations.
> 
> 
> plot({-x-3,-x+2},x=-infinity..infinity);

From this graph, there are two points of intersection and this means that there are two value of x that meet for both equations.
> 
> plot({1-x,1-x},x=-infinity..infinity);

From the graph obtained, it shows that all the values of x for the first equation meet the values of x for the second equation.
> 
> 

14.	Solve the equations: 2x + y - 2z = 8, 3x + 2y - 4z = 15 and 5x + 4y - z = 1.
> restart;
> solve({2*x+y-2*z=8,3*x+2*y-4*z=15,5*x+4*y-z=1},{x,y,z});

> 
> 
15.	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.
> restart;
> p1:=(2*x+y^2+3)*(4*x^2-3*y)*(x^2+8-5*y^2);

> expand(%);

> factor(p1);

> simplify(p1);

> 
> 
16. Write any equation with three variables (x, y and z) and solve it using Maple.
> restart;
> f1:= 3*x+8*x*y-4*y/6+5*z=83;

> f2:=5*x^2/(7*x*y)-y+4*z-8=32;
> 

> f3:=2*x+5*y-2*z=32;

> solve({f1,f2,f3},{x,y,z});

>