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

Matlab CH 1 Solution

This document contains solutions to 19 math problems involving calculations using variables and trigonometric identities. The problems cover topics like solving equations, evaluating expressions, using trigonometric functions, applying laws of sines and cosines, and calculating volumes, lengths, angles and areas of geometric shapes. The solutions provide the step-by-step working and use of MATLAB code to arrive at numerical answers for each multi-part problem.

Uploaded by

Hammad Naeem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
569 views

Matlab CH 1 Solution

This document contains solutions to 19 math problems involving calculations using variables and trigonometric identities. The problems cover topics like solving equations, evaluating expressions, using trigonometric functions, applying laws of sines and cosines, and calculating volumes, lengths, angles and areas of geometric shapes. The solutions provide the step-by-step working and use of MATLAB code to arrive at numerical answers for each multi-part problem.

Uploaded by

Hammad Naeem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Chapter 1

Solved Problems

1. Calculate:

(a) (b)

Solution

>> % Part (a)


>> (5-19/7+2.5^3)^2
ans =
320.7937
>> % Part (b)
>> 7*3.1+sqrt(120)/5-15^(5/3)
ans =
-67.3421

2. Calculate:

(a) (b)

Solution

>> % Part (a)


>> (8+80/2.6)^(1/3)+exp(3.5)
ans =
36.5000
>> % Part (b)
>> (1/sqrt(0.75)+73/3.1^3)^(1/4)+55*0.41
ans =
23.9279
1
2 Chapter 1: Solved Problems

3. Calculate:

(a) (b)

Solution

>> % Part (a)


>> (23+45^(1/3))/(16*0.7)+log10(589006)
ans =
8.1413
>> % Part (b)
>> (36.1-2.25*pi)*(exp(2.3)+sqrt(20))
ans =
419.3971

4. Calculate:

(a) (b)

Solution

>> % Part (a)


>> 3.8^2/(2.75-41*2.5)+(5.2+1.8^5)/sqrt(3.5)
ans =
12.7349
>> % Part (b)
>> (2.1E6-15.2E5)/(3*6E11^(1/3))
ans =
22.9222
Chapter 1: Solved Problems 3

5. Calculate:

(a) (b)

Solution

>> % Part (a)


>> sin(0.2*pi)/cos(pi/6)+tand(72)
ans =
3.7564
>> % Part (b)
>> (tand(64)*cosd(15))^2+sind(37)^2/cosd(20)^3
ans =
4.3586

6. Define the variable z as z = 4.5, then evaluate:


(a) (b)

Solution

>> z=4.5;
>> % Part (a)
>> 0.4*z^4+3.1*z^2-162.3*z-80.7
ans =
-584.2500
>> % Part (b)
>> (z^3-23)/(z^2+17.5)^(1/3)
ans =
20.3080

7. Define the variable t as t = 3.2, then evaluate:

(a) (b)

Solution

>> t=3.2;
>> % Part (a)
>> exp(2*t)/2-3.81*t^3
ans =
176.0764
4 Chapter 1: Solved Problems

>> % Part (b)


>> (6*t^2+6*t-2)/(t^2-1)
ans =
8.5108

8. Define the variables x and y as x = 6.5 and y = 3.8, then evaluate:

(a) (b)

Solution

>> x=6.5; y=3.8;


>> % Part (a)
>> (x^2+y^2)^(2/3)+x*y/(y-x)
ans =
5.6091
>> % Part (b)
>> sqrt(x+y)/(x-y)^2+2*x^2-x*y^2
ans =
-8.9198

9. Define the variables a, b, c, and d as:


, , , and , then evaluate:

(a) (b)

Solution

>> c=4.6; d=1.7;


>> a=c*d^2;
>> b=(c+a)/(c-d);
>> % Part (a)
>> exp(d-b)+(c+a)^(1/3)-(c*a)^d
ans =
-1.0861e+03
>> % Part (b)
>> d/c+(c/b)^2-c^d-a/b
ans =
-14.6163
Chapter 1: Solved Problems 5

10. Two trigonometric identities are given by:


(a) (b)
For each part, verify that the identity is correct by calculating the values of
the left and right sides of the equation, substituting .

Solution

>> x=pi/10;
>> % Part (a)
>> Left=cos(x)^2-sin(x)^2
Left =
0.8090
>> Right=1-2*sin(x)^2
Right =
0.8090
>> % Part (b)
>> Left=tan(x)/(sin(x)-2*tan(x))
Left =
-0.9533
>> Right=1/(cos(x)-2)
Right =
-0.9533

11. Two trigonometric identities are given by:

(a) (b)
For each part, verify that the identity is correct by calculating the values of
the left and right sides of the equation, substituting .

Solution

>> x=20;
>> % Part (a)
>> Left=(sind(x)+cosd(x))^2
Left =
1.6428
>> Right=1+2*sind(x)*cosd(x)
Right =
1.6428
>> % Part (b)
>> Left=(1-2*cosd(x)-3*cosd(x)^2)/sind(x)^2
Left =
6 Chapter 1: Solved Problems

-30.1634
>> Right=(1-3*cosd(x))/(1-cosd(x))
Right =
-30.1634

12. Define two variables: alpha = π/8, and beta = π/6. Using these variables, show
that the following trigonometric identity is correct by calculating the values
of the left and right sides of the equation.

Solution

>> alpha=pi/8; beta=pi/6;


>> Left=tan(alpha+beta)
Left =
1.3032
>> Right=(tan(alpha)+tan(beta))/(1-tan(alpha)*tan(beta))
Right =
1.3032

13. Given: . Use MATLAB to calculate the

following definite integral: .

Solution

>> xa=pi/6; xb=pi/3;


>> Ia=2*xa*cos(xa)+(xa^2-2)*sin(xa)
Ia =
0.0440
>> Ib=2*xb*cos(xb)+(xb^2-2)*sin(xb)
Ib =
0.2648
>> I=Ib-Ia
I =
0.2209
Chapter 1: Solved Problems 7

14. A rectangular box has the dimensions shown. A


(a) Determine the angle BAC to the nearest
degree.
(b) Determine the area of the triangle ABC to 16 cm
the nearest tenth of a cm. C
B
Law of Cosines: 43 cm
Heron’s formula for triangular area: 23 cm
, where .

Solution

>> a=sqrt(23^2+43^2)
a =
48.7647
>> b=sqrt(16^2+23^2)
b =
28.0179
>> c=sqrt(43^2+16^2)
c =
45.8803
>> % Part (a)
>> AngleABC=acosd((a^2+c^2-b^2)/(2*a*c))
AngleABC =
34.2665
>> % Part (b)
>> p=(a+b+c)/2;
>> A=sqrt(p*(p-a)*(p-b)*(p-c))
A =
629.8589
8 Chapter 1: Solved Problems

15. The arc length of a segment of a parabola ABC is y


given by: B

h
Determine LABC if a=8 in. and h=13 in. C x
A a a

Solution

>> a=8; h=13;


>> L=sqrt(a^2+4*h^2)+a^2*log(2*h/a+sqrt((2*h/a)^2+1))/
(2*h)
L =
31.8667

16. The three shown circles, with radius 15 in.,


10.5 in., and 4.5 in., are tangent to each other.
(a) Calculate the angle γ (in degrees) by
using the Law of Cosines.
(Law of Cosines: )
(b) Calculate the angles γ and α (in degrees)
using the Law of Sines.
(c) Check that the sum of the angles is 180º.

Solution

Script File:

% Ch. 1, Prob. 16 (6th ed.)


a=10.5+4.5; b=15+4.5; c=15+10.5;
% Part (a)
Gam=acosd((a^2+b^2-c^2)/(2*a*b))
% Part (b)
Bet=asind(b*sind(Gam)/c)
Alp=asind(a*sind(Gam)/c)
% Part (c)
SumAng=Gam+Bet+Alp

Command Window:

>> HW_1_16
Gam =
Chapter 1: Solved Problems 9

94.4117
Bet =
49.6798
Alp =
35.9085
SumAng =
180

17. A frustum of cone is filled with ice cream such that


the portion above the cone is a hemisphere. Define do
the variables di=1.25 in., d0=2.25 in., h=2 in., and
determine the volume of the ice cream.

h
Solution di

>> ri=1.25/2; ro=2.25/2; h=2;


>> Vcon=pi*h/3*(ri^2+ri*ro+ro^2);
>> Vtop=2*pi*ro^3;
>> V=Vcon+Vtop
V =
13.8876

18. In the triangle shown in., in., and


in. Define a, b, and c as variables, and then:
(a) Calculate the angles α, β, and γ by substituting the
variables in the Law of Cosines.
(Law of Cosines: )
(b) Verify the Law of Tangents by substituting the
results into the right and left sides of:

Law of Tangents:

Solution

Script file:
% HW 1_18 6ed
clear,clc
a=27; b=43; c=57;
disp('Part (a)')
10 Chapter 1: Solved Problems

Al=acosd((-a^2+b^2+c^2)/(2*b*c))
Bet=acosd((-b^2+a^2+c^2)/(2*a*c))
Gum=acosd((-c^2+a^2+b^2)/(2*a*b))
Tot=Al+Bet+Gum
disp('Part (b)')
LHS=(b-c)/(b+c)
RHS=tand((Bet-Gum)/2)/tand((Bet+Gum)/2)

Command Window:

Part (a)
Al =
26.9669
Bet =
46.2365
Gum =
106.7966
Tot =
180
Part (b)
LHS =
-0.1400
RHS =
-0.1400

19. For the triangle shown, , , and its perimeter is mm.


Define α , β , and p, as variables, and then:
(a) Calculate the triangle sides (Use the Law of
Sines).
(b) Calculate the radius r of the circle inscribed in
the triangle using the formula:

where .

Solution

Script File:

A=72; B=43;
G=180-A-B;
Chapter 1: Solved Problems 11

% Part (a)
a=114/(1+sind(B)/sind(A)+sind(G)/sind(A))
b=a*sind(B)/sind(A)
c=a*sind(G)/sind(A)
% Part (b)
s=(a+b+c)/2;
r=sqrt((s-a)*(s-b)*(s-c)/s)

Command Window:

a =
42.6959
b =
30.6171
c =
40.6870
r =
10.3925

20. The distance d from a point P to the z


line that passes through the two points A B
and B can be calculated by y
where r is the distance between the
points A and B, given by P
and S is the
area of the triangle defined by the three points cal- A
culated by where x

. Determine the distance of


point P from the line that passes through point A
and point B . First define the variables xP, yP, zP, xA, yA, zA, xB,
yB, and zB, and then use the variable to calculate s1, s2, s3, and r. Finally cal-
culate S and d.

Solution

Script file:
clear, clc
12 Chapter 1: Solved Problems

A=[-2 -1.5 -3];


B=[-2.5 6 4];
P=[2 6 -1];
r=sqrt(sum((B-A).^2));
s1=P(1)*A(2)+A(1)*B(2)+B(1)*P(2)-
(P(2)*A(1)+A(2)*B(1)+B(2)*P(1));
s2=P(2)*A(3)+A(2)*B(3)+B(2)*P(3)-
(P(3)*A(2)+A(3)*B(2)+B(3)*P(2));
s3=P(1)*A(3)+A(1)*B(3)+B(1)*P(3)-
(P(3)*A(1)+A(3)*B(1)+B(3)*P(1));
S=sqrt(s1^2+s2^2+s3^2)/2;
DIS=2*S/r

Command Window:
DIS =
5.6655
>>

21. The perimeter of an ellipse can be approximated y


by: b

x
a

Calculate the perimeter of an ellipse with


in. and in.

Solution

Command Window:

>> a=18; b=7;


>> P=pi*(a+b)*(3-sqrt((3*a+4)*(a+3*b))/(a+b))
P =
86.2038
Chapter 1: Solved Problems 13

22. 4217 eggs have to be packed in boxes that can hold 36 eggs each. By typing
one line (command) in the Command Window, calculate how many eggs
will remain unpacked if every box that is used has to be full. (Hint: use
MATLAB built-in function fix.)

Solution

Command Window:

>> 4217-fix(4217/36)*36
ans =
5

23. 777 people have to be transported using buses that have 46 seats and vans
that have 12 seats. Calculate how many buses are needed if all the buses have
to be full, and how many seats will remain empty in the vans if enough vans
are used to transport all the people that did not fit into the buses. (Hint: use
MATLAB built-in functions fix. and ceil)

Solution

Command Window:

>> nBuses=fix(777/46)
nBuses =
16
>> nPeoLeft=777-nBuses*46
nPeoLeft =
41
>> nVans=ceil(nPeoLeft/12)
nVans =
4
>> nSeatEmp=nVans*12-nPeoLeft
nSeatEmp =
7
14 Chapter 1: Solved Problems

24. Change the display to format long g. Assign the number 7E8/13 to a
variable, and then use the variable in a mathematical expression to calculate
the following by typing one command:
(a) Round the number to the nearest tenth.
(b) Round the number to the nearest million.

Solution

Command Window:

>> format long g


>> x=7E8/13
x =
53846153.8461538
>> a=round(x*10)/10
a =
53846153.8
>> b=round(x/1000000)*1000000
b =
54000000

25. The voltage difference Vab between points a


R1 R2
and b in the Wheatstone bridge circuit is given
by:
V + a b

R4 R3
where and . Calculate
the Vab if volts, ohms,
ohms, ohms, and ohms.

Solution

Command Window:

format short
>> V=15; R1=119.8; R2=120.5; R3=121.2; R4=119.3;
>> c=R2/R1; d=R3/R4;
>> Vab=V*(c-d)/((c+1)*(d+1))
Vab =
-0.0374
Chapter 1: Solved Problems 15

26. The current in a series RCL circuit is given R L C


by:
V

where . Calculate I for the circuit shown if the supply voltage is 80


V, Hz, , H, and F.

Solution

Command Window:

>> V=80; R=6; f=50; L=400E-3; C=40E-6;


>> w=2*pi*f;
>> I=V/sqrt(R^2+(w*L-1/(w*C))^2)
I =
1.7213

27. The Monthly payment M of a mortgage P for n years with a fixed annual
interest rate r can be calculated by the formula:

Determine the monthly payment of a 30 year $450,000 mortgage with inter-


est rate of 4.2% ( ). Define the variables P, r, and n and then use
them in the formula to calculate M.

Solution

Command Window:

>> format bank


>> n=30; P=450000; r=0.042;
>> rm=r/12;
>> C=(1+rm)^(12*n);
>> M=P*rm*C/(C-1)
M =
2200.58
16 Chapter 1: Solved Problems

28. The number of permutations of taking r objects out of n objects with-


out repetition is given by:

(a) Determine how many 6-letter passwords can be formed from the 26 let-
ters in the English alphabet if a letter can only be used once.
(b) How many passwords can be formed if the digits 0, 1, 2, ....., 9 can be
used in addition to the letters.

Solution

Command Window:

>> % Part (a):


>> n=26; r=6;
>> P=factorial(n)/factorial(n-r)
P =
165765600
>>
>> % Part (b):
>> n=36; r=6;
>> P=factorial(n)/factorial(n-r)
P =
1.4024e+09
>>

29. The number of combinations of taking r objects out of n objects is given


by:

In the Powerball Lottery game the player chooses 5 numbers from 1 through
59, and then the Powerball number from 1 through 35.
Determine how many combinations are possible by calculating .
(Use the built-in function factorial.)

Solution

Command Window:

>> C5_59=factorial(59)/(factorial(5)*factorial(59-5));
>> C1_35=factorial(35)/(factorial(1)*factorial(35-1));
>> Combination=C5_59*C1_35
Combination =
1.752235100000000e+08
Chapter 1: Solved Problems 17

30. The equivalent resistance of two resistors


R1 and R2 connected in parallel is given by

. The equivalent resistance of


two resistors R1 and R2 connected in series
is given by, . Determine the
equivalent resistance of the four resistors in the circuit shown in the figure.

Solution

Command Window:

>> R1=200; R2=140;


>> R3=80; R4=250;
>> Req=R1*R2/(R1+R2)+R3*R4/(R3+R4)
Req =
142.96

31. The output voltage Vout in the circuit shown is given


by (Millman’s Theorem): R1 R2 R3
Vout
V1 V2 V3

Calculate Vout given V, V, V,


Ω,, Ω,, Ω,.
Solution
Script file:
clear, clc
V1=36; V2=28; V3=24;
R1=400; R2=200; R3=600;
N=V1/R1+V2/R2+V3/R3;
D=1/R1+1/R2+1/R3;
Vout=N/D

Command Window:
Vout =
29.4545
>>
18 Chapter 1: Solved Problems

32. Radioactive decay of carbon-14 is used for estimating the age of organic
material. The decay is modeled with the exponential function ,
where t is time, is the amount of material at , is the amount
of material at time t, and k is a constant. Carbon-14 has a half-life of
approximately 5,730 years. A sample taken from the ancient footprints of
Acahualinca in Nicaragua shows that 77.45% of the initial ( ) carbon-
14 is present. Determine the estimated age of the footprint. Solve the prob-
lem by writing a program in a script file. The program first determines the
constant k, then calculates t for , and finally rounds the
answer to the nearest year.

Solution

Command Window:

>> k=log(0.5)/5730
k =
-0.00012097
>> Age=round(log(.7745)/k)
Age =
2112
>>

33. The greatest common divisor is the largest positive integer that divides the
numbers without a remainder. For example, the GCD of 8 and 12 is 4. Use
the MATLAB Help Window to find a MATLAB built-in function that
determines the greatest common divisor of two numbers. Then use the func-
tion to show that the greatest common divisor of:
(a) 91 and 147 is 7.
(b) 555 and 962 is 37.

Solution

Command Window:

>> % Part (a):


>> gcd(91,147)
ans =
7
>>
>> % Part (b):
Chapter 1: Solved Problems 19

>> gcd(555,962)
ans =
37

34. The amount of energy E (in Joules) that is released by an earthquake, is


given by:

where M is the magnitude of the earthquake on the Richter scale.


(a) Determine the energy that was released from the Anchorage earthquake
(1964, Alaska, USA), magnitude 9.2.
(b) The energy released in Lisbon earthquake (Portugal) in 1755 was one
half the energy released in the Anchorage earthquake. Determine the
magnitude of the earthquake in Lisbon on the Richter scale.

Solution

Command Window:

>> % Part (a):


>> MAn=9.2;
>> EAn=1.74E19*10^(1.44*MAn)
EAn =
3.08e+32
>>
>> % Part (b):
>> ELi=EAn/2;
>> MLi=log10(ELi/1.74E19)/1.44
MLi =
8.991
>>

35. According to the Doppler effect of light the perceived wavelength λ p of a


light source with a wavelength of is given by:

where c is the speed of light (about m/s) and v is the speed the
observer moves toward the light source. Calculate the speed the observer
has to move in order to see a red light as green. Green wavelength is 530nm
20 Chapter 1: Solved Problems

and red wavelength is 630nm.

Solution

Command Window:

>> c=300E6;
>> LR=630; LG=530;
>> r=530/630;
>> v=c*((1-r^2)/(r^2+1))
v =
5.1343e+07
>>

36. Newton’s law of cooling gives the temperature T(t) of an object at time t in
terms of T0, its temperature at , and Ts, the temperature of the sur-
roundings.

A police officer arrives at a crime scene in a hotel room at 9:18 PM, where
he finds a dead body. He immediately measures the body’s temperature and
find it to be 79.5ºF. Exactly one hour later he measures the temperature
again, and find it to be 78.0ºF. Determine the time of death, assuming that
victim body temperature was normal (98.6ºF) prior to death, and that the
room temperature was constant at 69ºF.

Solution

Script File:

clear, clc
% Determining k:
Ts=69; T0=79.5; T60=78;
ta=60;
k=log((T0-Ts)/(T60-Ts))/ta;
% Determine min before 9:18 PM
T0=98.6; T9_18=79.5;
tb=round(log((T0-Ts)/(T9_18-Ts))/k);
Time=9*60+18-tb;
Hr=fix(Time/60)
Min=Time-Hr*60
Chapter 1: Solved Problems 21

Command Window:

Hr =
2
Min =
35

37. The velocity v and the falling distance d as a function of time of a skydiver
that experience the air resistance can be approximated by:

and

where kg/m is a constant, m is the skydiver mass, m/s2 is the


acceleration due to gravity, and t is the time in seconds since the skydiver
start falling. Determine the velocity and the falling distance at s for a
95 kg skydiver

Solution

Command Window:

>> m=95; k=0.24; g=9.81; t=8;


>> v8=sqrt(m*g/k)*tanh(sqrt(k*g/m)*t)
v8 =
53.024
>> d=m/k*log(cosh(sqrt(k*g/m)*t))
d =
254.81

38. Use the Help Window to find a display format that displays the output as a
ratio of integers. For example, the number 3.125 will be displayed as 25/8.
Change the display to this format and execute the following operations:
(a) (b)

Solution

Command Window:

>> format rat


22 Chapter 1: Solved Problems

>> 5/8+16/6
ans =
79/24
>> 1/3-11/13+2.7^2
ans =
1247/184

39. Gosper’s approximation for factorials is given by:

Use the formula for calculating 19!. Compare the result with the true value
obtained with MATLAB’s built-in function factorial by calculating the
error (Error=(TrueVal-ApproxVal)/TrueVal).

Solution

Command Window:

>> n=19;
>> nApp=sqrt((2*n+1/3)*pi)*n^n*exp(-n)
nApp =
1.216428232016491e+17
>> nTru=factorial(n)
nTru =
1.216451004088320e+17
>> Error=(nTru-nApp)/nTru
Error =
1.872008963197555e-05

40. According to Newton’s law of universal gravitation the attraction force


between two bodies is given by:

where m1 and m2 are the masses of the bodies, r is the distance between the
bodies, and N-m2/kg2 is the universal gravitational constant.
Determine how many times the attraction force between the sun and the
earth is larger than the attraction force between the earth and the moon.
The distance between the sun and earth is m, the distance
between the moon and earth is m, kg,
Chapter 1: Solved Problems 23

kg, and kg.

Solution

Script File:

G=6.67E-11; dS_E=149.6E9; dM_E=384.4E6;


mE=5.98E28; mS=2E30; mM=7.36E22;
FSE=G*mS*mE/dS_E^2;
FME=G*mM*mE/dM_E^2;
Ratio=round(FSE/FME)

Command Window:

Ratio =
179
24 Chapter 1: Solved Problems

You might also like