Vous êtes sur la page 1sur 2

ChE-121

ASSIGNMENT No. 1
First Due (Marked 100% basis): Jan 20th, 2016, 9:00pm
Second and final due (Marked 70% basis): Jan 21st, 2016, 9:00pm
Instructions: Solve the problems by hand, scan your work and submit a pdf
document to the corresponding drop box on the course website. DO NOT
use any of the MATLAB built-in functions to write the algorithms.
1. Follow-up exercise: Draw a flowchart the returns the factorial of a number N.
Your flowchart must return an error if the user enter an invalid N, e.g. a negative
or real number N, and should also consider the case of N=0.
2. In mathematics, functions can often be represented by infinite series. For
example, the exponential function can be computed using:
exp( x ) 1 x

2!

...

3!

n!

where n represents the number of terms that are included in the infinite series
function to compute exp(x). The error in the computation of exp(x) using the
infinite series can be evaluated from as follows:
error

true approx

* 100 %

true

where true represents the true value, obtained from the direct evaluation of exp(x),
whereas approx represents the value computed from the infinite series.
Design a flowchart that computes the exponential function using the infinite series
approximation. The flowchart will ask the user for the value in x that will be
evaluated and the number of terms n to be considered in the series. The flowchart
must print the value obtained from the series and the error associated with that
calculation. Assume that the symbol ! can be used in the flowchart to denote the
computation of a factorial number.
3. Draw a flowchart and write a Pseudocode that displays the roots of any second
order algebraic equation, e.g. ax2+bx+c=0.
4. A Fibonacci sequence is a sequence of numbers f0, f1, f2, f3, , in which the
first two values (f0 and f1) are equal to 1, and each succeeding number is the sum
of the previous two numbers. Thus, the first few values of the Fibonacci sequence
are:
1 1 2 3 5 8 13 21 34
A function that computes the Fibonacci sequence is as follows:

n 0, n 1
1
f (n)
f ( n 1) f ( n 2 ) n 1

Design a flowchart that returns the sum of all the elements included in a Fibonacci
sequence of n elements. The only input to the flowchart will be the integer
number n, which determines the number of elements in the Fibonacci sequence.
Assume that the user enters an integer number.
5. Draw a flowchart and write a Pseudocode that displays the number of positive,
negative and zero elements are in a vector of length N.

Vous aimerez peut-être aussi