Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Calculus Mathematics

Lab 1
Question 1 (8 marks)
a)
>> (35.7*64-(7^3))/(45+5^2)
ans =
27.7400

b)
>> (5/4*7*6^2)+(3^7/(9^3-652))
ans =
343.4026

c)
>> (2+7)^3+(273^(2/3)/2)+55^2/3
ans =
1.7584e+003

d)
>> 2^3+7^3+(273^3/2)+55^(3/2)
ans =
1.0174e+007

Question 2 (6 marks)
>> x=13.5, syms z
x =
13.5000
>> x*(z^2)-(2*z/(3*x))^(3/5)
ans =
(27*z^2)/2 - (4/81*z)^(3/5)

1
Calculus Mathematics

>> (443*z/(2*x^3))+(exp(-x*z)/(x+z))
ans =
(1772*z)/19683 + 1/(exp((27*z)/2)*(z + 27/2))


Question 3 (6 marks)
>> a=15.62, b=-7.08, c=62.5, d=0.5*(a*b-c)
a =
15.6200
b =
-7.0800
c =
62.5000
d =
-86.5448

>> a+(a*b/c)*((a+d)^2/(sqrt(abs(a*b))))
ans =
-830.7755

>> d*(exp(d/2))+(((a*d+c*d)/((20/a)+(30/b)))/(a+b+c+d))
ans =
-147.4700













2
Calculus Mathematics

Lab 2

Question 1 (6 marks)
a)

>> [x y]=solve('0.5*x+y=-2','x-2*y=8')

x =

2.0


y =

-3.0


b)


>> [x y z]=solve('3*x-2*y+2*z=-1','7*x-3*y=-1*(2*z+1)','-2*x+2*y-3*z=4')

x =

-5/3


y =

-20/3


z =

-14/3




Question 2 (4 marks)

>> [a b c]=solve('a+b+c=2','4*a-2*b+c=-7','4*a+2*b+c=-3')

a =

-2


b =

3
Calculus Mathematics


1


c =

3


Question 3 (5 marks)


>> [a b c d]=solve('-112=((-3)^3)*a+((-3)^2)*b+(-3)*c+d','-2=-a+b-
c+d','4=a+b+c+d','13=8*a+4*b+2*c+d')

a =

3


b =

-4


c =

0


d =

5















4
Calculus Mathematics



Question 4

a)

>> f = inline(vectorize('x^4-x^3+2*x^2-4*x-8'),'x')

f =

Inline function:
f(x) = x.^4-x.^3+2.*x.^2-4.*x-8

>> ezplot(f) [2 marks]

>> grid on
>> ylabel('y')




[3 marls]


5
Calculus Mathematics



b)
>> f = inline(vectorize('x^3-(2/3)*x^2+(8/3)*x+1'),'x')

f =

Inline function:
f(x) = x.^3-(2./3).*x.^2+(8./3).*x+1

>> ezplot(f)
>> grid on [2 marks]
>> ylabel('y')






[3 marks]



6
Calculus Mathematics

c)

>> f = inline(vectorize('2*x^3+3*x^2+2*x+3'),'x')

f =

Inline function:
f(x) = 2.*x.^3+3.*x.^2+2.*x+3

>> ezplot(f)
>> ylabel('y') [2 marks]
>> grid on


[3 marks]

Question 5

>> x=0:0.1:2;
>> plot(x,0.5*(x.^2))
>> x=2:0.1:4;
>> hold on
>> plot(x,2)
>> x=4:0.1:6;
>> plot(x,6-x)
>> axis([0 6 -1 4]) [1 mark]

7
Calculus Mathematics

>> title 'Graph for Question 5'


>> xlabel 'x'
>> ylabel 'y'
>> grid on












































8
Calculus Mathematics

Lab3
Question 1
a) >> syms x
>> y=cos(x)/(1+sin(x))
y =
cos(x)/(sin(x) + 1)
>> diff(y)
ans =
- cos(x)^2/(sin(x) + 1)^2 - sin(x)/(sin(x) + 1)

b) >> y=(x-exp(x))*(2+exp(x^2));
>> diff(y)
ans =
2*x*exp(x^2)*(x - exp(x)) - (exp(x) - 1)*(exp(x^2) + 2)

c) >> y=(2^x-x^3)^2;
>> diff(y)
ans =
2*(2^x*log(2) - 3*x^2)*(2^x - x^3)

d) >> y=log(x^2+2*x-1);
>> diff(y)
ans =
(2*x + 2)/(x^2 + 2*x - 1)

e) >> y=((1-x)/(1+x))^x;
>> diff(y)
ans =
log(-(x - 1)/(x + 1))*(-(x - 1)/(x + 1))^x - x*(1/(x + 1) - (x - 1)/(x + 1)^2)*(-(x - 1)/(x + 1))^(x - 1)

f) >> y=log(x)^(log(3*x-2));
>> diff(y)
ans =
(log(3*x - 2)*log(x)^(log(3*x - 2) - 1))/x + (3*log(log(x))*log(x)^log(3*x - 2))/(3*x - 2)

9
Calculus Mathematics

g) >> y=(sqrt(x^2+3*x))*((x-2)^3)/((1-x)^(1/3));
>> diff(y)
ans =
(3*(x^2 + 3*x)^(1/2)*(x - 2)^2)/(1 - x)^(1/3) + ((x^2 + 3*x)^(1/2)*(x - 2)^3)/(3*(1 - x)^(4/3))
+ ((2*x + 3)*(x - 2)^3)/(2*(x^2 + 3*x)^(1/2)*(1 - x)^(1/3))

h) >> y=2*x*exp(3*x+4)/((x-1)*exp(sqrt(x+1)));
>> diff(y)
ans =
(2*exp(3*x + 4))/(exp((x + 1)^(1/2))*(x - 1)) + (6*x*exp(3*x + 4))/(exp((x + 1)^(1/2))*(x - 1))
- (2*x*exp(3*x + 4))/(exp((x + 1)^(1/2))*(x - 1)^2) - (x*exp(3*x + 4))/(exp((x + 1)^(1/2))*(x -
1)*(x + 1)^(1/2))

Question 2
a)>> g=x*(exp(x)-x-1)

g =

-x*(x - exp(x) + 1) [1 mark]

b)>> gprime=diff(g)

gprime =

exp(x) - x + x*(exp(x) - 1) – 1 [1 mark]

c)
To evaluate g(4)
>> subs(g,x,4)

ans =

198.3926 [1 mark]

>> subs(gprime,x,4)

ans =

263.9908 [1 mark]

Question 3
a)

>> f=x^5+3*(x^4)-3*x+7;
>> ezplot(f,-1,1)
>> grid on

10
Calculus Mathematics

>> ylabel y
>> title f(x)=x^5+3x^4-3x+7 [1 mark]

[2 marks]

b) >> diff(f)
ans =

5*x^4 + 12*x^3 – 3 [1 mark]

Question 4
a) >> syms x y;
>> F=inline('x^2+y^2-2*x-6*y+5','x','y')

F=

Inline function:
F(x,y) = x^2+y^2-2*x-6*y+5 [1 mark}

>> yprime=-diff(F(x,y),x)/diff(F(x,y),y)

yprime =

-(2*x - 2)/(2*y - 6) [1 mark]

b) >> subs(yprime,x,3) or subs(yprime, {x,y},{3,2})

ans =
-4/(2*y - 6) [1 mark]

>> subs(ans,y,2)

ans =
2 [1 mark]

11
Calculus Mathematics

Lab 4

Question 1
>> syms x
>> x = 0:.01:4;
>> y=sin(x.^2);
>> deriv_y = diff(y)./diff(x);
>> xd = x(2:length(x)-1);
>> xd = x(2:length(x));
>> plot(x,y,xd,deriv_y)
>> grid on
>> legend('f(x)','fprime(x)')
>> xlabel('x')
>> title('f(x) and fprime(x) vs x') [2 marks]

[3 marks]

>> delay_mult = deriv_y(1:length(deriv_y)-1).*deriv_y(2:length(deriv_y));


>> max_min = xd(find(delay_mult < 0))

max_min =

1.2500 2.1700 2.8000 3.3200 3.7600

Max = (1.25, 1), (2.8, 1), (3.76, 1)
Min = (2.17, -1), (3.32, -1) [5 marks]

12
Calculus Mathematics

Question 2 ®
Working to obtain formula = 2 marks

Answer
Note that the store has the shape of a trapezium. So the cross-sectional area (A) of the store is
given by the formula: Area = average length of parallel sides ⇥ distance between parallel sides:
1
A = (y + 3)x (1)
2
The lengths
p x and y are relatedpthrough the fact that AB + BC = 6, where BC = y and
AB = x2 + (3 y)2 . Hence x2 + (3 y)2 + y = 6. This equation can be rearranged in the
following way:
p
x2 + (3 y)2 = 6 y , x2 + (3 y)2 = (6 y)2 i.e. x2 + 9 6y + y 2 = 36 12y + y 2
which implies that x2 + 6y = 27 (2)
It is necessary to eliminate either x or y from (1) and (2) to obtain an equation in a single variable.
Using y instead of x as the variable will avoid having square roots appearing in the expression for
the cross-sectional area. Hence from Equation (2)
27 x2
y= (3)
6
Substituting for y from Equation (3) into Equation (1) gives
✓ ◆ ✓ ◆
1 27 x2 1 27 x2 + 18 1
A= +3 x= x= 45x x3 (4)
2 6 2 6 12
dA
To find turning points, we evaluate from Equation (4) to get
dx
dA 1
= (45 3x2 ) (5)
dx 12
dA 1
Solving the equation = 0 gives (45 3x2 ) = 0 ) 45 3x2 = 0
dx 12
p
Hence x = ± 15 = ± 3.8730. Only x > 0 is of interest, so
p
x = 15 = 3.87306 (6)
gives the required turning point.

Check: Di↵erentiating Equation (5) and using the positive x solution (6) gives
d2 A 6x x 3.8730
2
= = = <0
dx 12 2 2
Since the second derivative is negative then the cross-sectional area is a maximum. This is the only
turning point identified for A > 0 and it is identified as a maximum. To find the corresponding
27 3.87302
value of y, substitute x = 3.8730 into Equation (3) to get y = = 2.0000
6
So the values of x and y that yield the maximum cross-sectional area are 3.8730 m and 2.00000
m respectively. To find the maximum cross-sectional area, substitute for x = 3.8730 into Equation
(5) to get
1
A = (45 ⇥ 3.8730 3.87303 ) = 9.6825
2
So the maximum cross-sectional area of the store is 9.68 m2 to 2 d.p.

HELM (2008): 25
Section 12.2: Maxima and Minima
13
Calculus Mathematics

3 marks for working to obtain y

>> x=0:0.01:6;

>> y=1/12.*(45.*x-x.^3);

>> deriv_y = diff(y)./diff(x);

>> xd = x(2:length(x)-1);

>> xd = x(2:length(x));

>> plot(x,y,xd,deriv_y)

>> grid on

>> legend('f(x)','fprime(x)')

>> xlabel('x')

>> title('f(x) and fprime(x) vs x') [1 mark]

[3 marks]

>> delay_mult = deriv_y(1:length(deriv_y)-1).*deriv_y(2:length(deriv_y));

>> max_min = xd(find(delay_mult < 0))

max_min =

3.8700 [1 mark]

therefore, maximum cross-sectional area = 9.68 m2 [2 marks]



14
Calculus Mathematics

Lab 5
Question 1
a)
>> y=2*x/(sqrt(x+1))

y =

(2*x)/(x + 1)^(1/2)

>> int(y)

ans =

(4*(x + 1)^(1/2)*(x - 2))/3 [2 marks]


b)

>> y=x*exp(x^2)*(exp(x^2)+1)

y =

x*exp(x^2)*(exp(x^2) + 1)

>> int(y)

ans =

exp(x^2)/2 + exp(2*x^2)/4 [2 marks]


c)
>> y=2*x*log(x)

y =

2*x*log(x)

>> int(y)

ans =

x^2*(log(x) - 1/2) [2 marks]


Question 2

a)
>> int(sqrt(1-(sin(x)^2)),0,pi)

ans =

2 [2 marks]

15
Calculus Mathematics


b)
>> int((x^2-1)*sqrt(x),0,1)

ans =

-8/21 [2 marks]


c)
>> int(3*(exp(7*x))-(8^x),1,2)

ans =

(3*exp(14))/7 - (3*exp(7))/7 - 56/log(8) [2 marks]

>> eval(ans)

ans =

5.1490e+005

d)

>> int((3*exp(3*x))/(exp(3*x)+1),0,1)

ans =

log(exp(3)/2 + 1/2) [2 marks]

>> eval(ans)

ans =

2.3554

e)
>> int(3*x^2*log(x),1,2)

ans =

8*log(2) - 7/3 [2 marks]


Question 3

>> f = x*(sin(x))^2;
>> ezplot(f, [1,2]) [1 mark]

16
Calculus Mathematics

[3 marks]

>> int(x*(sin(x)^2))

ans =

sin(x)^2/4 - (x*sin(2*x))/4 + x^2/4 [2 marks]

int(x*(sin(x)^2), 1, 2)
ans =

cos(2)/8 - cos(4)/8 + sin(2)/4 - sin(4)/2 + 3/4
[2 marks]
>> eval(ans)

ans =

1.3854

17
Calculus Mathematics

Lab 6

Question 1
a)

>> y=x^2-2*x+1;
>> ezplot(y)
>> y2=x+1;
>> hold on
>> ezplot(y2)
>> grid on
>> axis([-2 4 -1 5])
>> title('Graph for Question 1')
>> ylabel('y') (3 marks)

(3 marks)
b)
>> int(y2-y,0,3)

ans =

9/2 unit2 (3 marks)

c)
>> int(pi*(y2^2)-pi*(y^2),0,3)

ans =

(72*pi)/5 unit3 (3 marks)

18
Calculus Mathematics

Question 2

Gradient for equation for cone= ¼

1
Equation of line: y = x
4

20
Volume of cone = ∫ π y 2 dx (3 marks)
0

Using MATLAB:

>> syms x
>> y=(1/4)*x;
>> int(pi*(y^2),0,20)

ans =

(500*pi)/

19

You might also like