Microsoft Word - HW ^LN2 assignment v2
1
HW #2 Assignment (7 problems)
Due: Monday, 10/19/2020 for both Sessions 002 and 003.
Submission: the same way as HW #1
1. For a cubic equation,
ax3 + bx2 + cx+ d = 0.
The following formula gives its general solution is available (https:
sciencing.com/solve-cubic-
equations XXXXXXXXXXhtml).
where
Write C code for this formula, and use it to solve two examples that you choose.
Write C code for the following:
2. Solve
x sin x = ex - x sin (x2),
y the Newton-Raphson method in the interval, [-2, 2].
3. Find all the roots
ex - 3 x = 0,
using the bisection method.
4. Solve the following 10 simultaneous equations by the Gauss-Jordan elimination method.
a11 x1 + a12 x2 + a13 x3 + + a1 10x10 = c1
a21 x1 + a22 x2 + a23 x3 + + a2 10x10 = c2
a31 x1 + a32 x2 + a33 x3 + + a3 10x10 = c3
an1 x1 + an2 x2 + an3 x3 + + a10 10x10 = c10
(1)
2
where aij is given as
a[10][10]={
{3.55618, XXXXXXXXXX, XXXXXXXXXX, 5.6951, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
7.63384, XXXXXXXXXX},
{ XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
1.3969, XXXXXXXXXX},
{ XXXXXXXXXX, XXXXXXXXXX,3.20481, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
4.95544, XXXXXXXXXX},
{ XXXXXXXXXX, XXXXXXXXXX,7.3216, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
5.9867, 8.5401},
{ XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
XXXXXXXXXX, XXXXXXXXXX},
{6.02952, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,8.14264, XXXXXXXXXX,
XXXXXXXXXX, XXXXXXXXXX},
{ XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
XXXXXXXXXX, XXXXXXXXXX},
{5.15737, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, 2.5375,
XXXXXXXXXX, XXXXXXXXXX},
{ XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
-3.7679, 3.3708},
{ XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX}
};
and ci is given as
c[10]={ XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,
XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX};
5. Solve the following set of nonlinear equations by the Gauss-Seidel method.
27 x + ex cos y 0.12 z
=
3
0.2 x2 + 37 y + 3 x z
=
6
x2 0.2 y sin x + 29 z
=
4
(2)
Start with an initial guess of x = y = z = 1.
3
6. The altitude (ft) from the sea level and the co
esponding time (sec) for a fictitious rocket were
measured as follows:
Time XXXXXXXXXX XXXXXXXXXX
Altitude XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX
Numerically compute the velocity from the table above using the central difference scheme. Use
f(x)
3 f(x) 4 f(x h) + f(x 2 h)
2 h
at t=200 and use
f(x) ~ 4 f(x+h) - f(x+2 h) - 3 f(x)
2 h
at t=0.
Make sure that you attach example runs showing the results from the computer.
7. (a) Evaluate analytically
1
0
x ln x dx.
(b) Write a C program to numerically integrate the above using the Simpson rule.
Note that the graph of x ln x looks like
Note also that ln x as x 0. So the challenge is how to handle the seemingly singular
point of x = 0.