0% found this document useful (0 votes)
56 views11 pages

Cal211-CC05-GROUP 8

The document presents the solution to three problems using calculus concepts and MATLAB. Problem 1 finds the intersection of two parametric curves and their tangents at that point. Problem 2 uses the trapezoidal integration formula to approximate the length of a path defined by a function and finds the time taken for a car to travel along this path. Problem 3 demonstrates the Euler method to numerically solve a differential equation by approximating the slope at discrete points along the curve.

Uploaded by

danh.tran214
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)
56 views11 pages

Cal211-CC05-GROUP 8

The document presents the solution to three problems using calculus concepts and MATLAB. Problem 1 finds the intersection of two parametric curves and their tangents at that point. Problem 2 uses the trapezoidal integration formula to approximate the length of a path defined by a function and finds the time taken for a car to travel along this path. Problem 3 demonstrates the Euler method to numerically solve a differential equation by approximating the slope at discrete points along the curve.

Uploaded by

danh.tran214
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/ 11

VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY

PROJECT OF CALCULUS 1
Lecturer: Đậu Thế Phiệt
Class: CC05 | Group 8
Bùi Minh Đức 2052959
Trần Khanh Danh 2052906
Nguyễn Ngọc Phước Tấn 2012020
Dương Thành Bách 2052861

1
CONTENTS

Problem 1 3

Problem 2 6

Problem 3 8

2
Problem 1: Given the parametric equations
x(t) = 𝑡 3 − 4t − 2,
{
y(t) = −2𝑡 2 + 1
Find an intersection of the curve and the tangents at that point. Draw the figure.

i) The theory and algorithm


1. Find an intersection of the parametric equations:
• We are looking for two different values, say, s and t, where x(s) = x(t) and y(s) =
y(t). That is, the x-values are the same precisely when the y-values are the same. This
gives us a system of 2 equations with unknowns:
t3 – 4t -2 = s3 – 4s – 2
-2t2 + 1 = -2s2 + 1
• When x(s) = x(t) and y(s) = y(t), the value of t must be different from the value of s.
2. Find tangents at the intersection of the curve:
𝑑𝑦
yTangentline = (𝑡) × (x – x(t)) + y(t)
𝑑𝑥

ii) The matlab command


1) Find an intersection of the curve:
syms t s x y
x=t.^3 -4*t-2-(s.^3 -4*s-2);
( Assign the first function to x )
y=-2*(t.^2)+1 -(-2*(s.^2)+1);
(Assign the second function to y )
[t,s]=solve(x,y,'t','s')
( solve these functions to find t and s value )

2) The tangents at that point:

3
syms t h u k a b
t=-3:0.1:3
x=t.^3 -4*t-2;
y=-2*(t.^2)+1;
h=u.^3 -4*u-2;
( Let function h(u) = x(t) )
k=-2*(u.^2)+1;
( Let function k(u) = y(t) )
plot(x,y,'b-')
grid on;
fontSize = 15;
xlabel('x', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
ylim([-20, 15]);
slope1=subs(diff(k,u)/diff(h,u),u,-2);
𝒅𝒚
( (𝒕𝟏) )
𝒅𝒙
slope2=subs(diff(k,u)/diff(h,u),u,2);
𝒅𝒚
( (𝒕𝟐) )
𝒅𝒙
yTangent1=subs(k,u,-2);
( y(t1) )
yTangent2=subs(k,u,2);
( y(t2) )
hold on;
yTangentline1=slope1*(x-subs(h,u,-2))+yTangent1;
𝒅𝒚
( yTangentline1 = (𝒕𝟏) × (x – x(1)) + y(1) )
𝒅𝒙
yTangentline2=slope2*(x-subs(h,u,2))+yTangent2;
𝒅𝒚
( yTangentline2 = = (𝒕𝟐) × (x – x(2)) + y(2) )
𝒅𝒙
plot(x,yTangentline1 ,'r-','LineWidth', 2);
plot(x,yTangentline2 ,'y-','LineWidth', 2);

3) The results and conclusion.

4
5
Problem 2: A car moves along a path of street with the shape is the graph of the
function y =xex . At each position, the light ray from the car
is considered to be tangent to the street. There is a statue at the coordinates (0.35, 0.37)
(km). Assume that the car moves at a constant
velocity 60 km/h. How long does the car take in moving from A, that
has x-coordinate = −0.6 to B, where the light ray spot to the statue.
The trapezoidal formula is a using to approximate the integral of a
function. Study the formula and use it to approximate the path AB.

i) The theory and algorithm:


⚫ Write the tangent line at the point where the light ray spot to the statue by the formula:
y(x) = slope ∗ (x − x0) + y0
⚫ Afterthat, replace the coordinates of the statue on the tangent line to find the x-
coodinate of point B.
𝑏
⚫ Applying the integral formula ∫𝑎 √(1 + 𝑓′(𝑥)2 ) to find the length of path AB.
𝐴𝐵
⚫ Hence, using this formula t = to find how long does car take in moving from A to B.
𝑣
ii)The Matlab commands:
syms xB yB slope x f(x)
v = 60;
xStatue = 0.35;
yStatue = 0.37;
yB = xB.*exp(xB);
% y = xex
slope = diff(yB,xB)
% Find the derivative of given function y at point B.
y = slope*(xStatue-xB)+yB-yStatue
6
% The tangent line of given function y at point B.
xB = vpasolve(exp(xB)*(xB+1)*(xStatue-xB)+xB*exp(xB)-yStatue==0)
% Calculate the equation to find xB.
f(x) = x + x.*exp(x);
% The derivative of given function y.
a = sqrt(1+(f(x)).^2);
lengthAB = vpa(int(a, x, -0.6, 0.029176), 4)
% Calculate the length of path AB.
t = lengthAB/v

iii) The result and conclusion:

7
Problem 3
Euler method:
If an initial problem cannot be solved analytically, numerical methods must be used
to get reasonable approximations to a solution. In this chapter, we'll look at some of these
techniques.
Euler's technique is the simplest numerical approach for solving this equation. This
approach is so basic that it is rarely utilized in practice. However, because of its simplicity, it
is excellent for illustration. The tangent line to the integral curve of this equation at (𝑥i, 𝑦(𝑥i))
approximates the integral curve across the interval [𝑥i, 𝑥i+1] according to Euler's approach.
Since the slope of the integral curve of this equation at (𝑥i, 𝑦(𝑥 i)) is 𝑦′(𝑥i) = 𝑓(𝑥i, 𝑦(𝑥 i)) ,
the equation of the tangent line to the integral curve at (𝑥i, 𝑦(𝑥i)) is
𝑦 = 𝑦(𝑥i) + 𝑓(𝑥i, 𝑦(𝑥i))(𝑥 − 𝑥 i)
Setting 𝑥 = 𝑥i+1 = 𝑥i+ℎ
𝑦𝑖 + 1 = 𝑦(𝑥𝑖) + ℎ𝑓(𝑥𝑖, 𝑦(𝑥𝑖))

as an approximation to 𝑦(𝑥𝑖+1). Since 𝑦(𝑥0)=𝑦0 is known, we can use 𝑖=0 to compute

𝑦1= 𝑦0+ℎ𝑓(𝑥0, 𝑦0)

However, setting 𝑖 = 1

𝑦2= 𝑦(𝑥1) + ℎ𝑓(𝑥1, 𝑦(𝑥1))


which isn’t useful, since we don’t know 𝑦(𝑥1). Therefore we replace 𝑦(𝑥1) by its
approximate value 𝑦1 and redefine
𝑦2= 𝑦1+ℎ𝑓(𝑥1, 𝑦1)

Having computed 𝑦2, we can compute

𝑦3= 𝑦2+ℎ𝑓(𝑥2, 𝑦2)

In general, Euler’s method starts with the known value 𝑦(𝑥0) = 𝑦0 and
computes 𝑦1, 𝑦2, … , 𝑦n successively by with the formula

𝑦i+1= 𝑦i+ℎ𝑓(𝑥i, 𝑦i), 0 ≤ 𝑖 ≤ 𝑛 − 1

8
i. Algorithm
- Start
- Define function f(x,y)
- Get the value of x0, y0, h and xn
Here:
x0 and y0 are the initial conditions
h is the interval
xn is the required value
- Caculate the steps: n = (xn – x0)/h
- Start loop from i = 1 to n
- yn = y0 + h*slope
- x0 = x0 + h
- Display yn as the result
- End

ii.Code and command


%Clear the command window and workspace
clear all;
clc;
global h %Use h from the function

%Determine the constant


x0 = 0;
y0 = 3;
xn = 1;

Enter_the_value %Call the function Enter_the_value

syms x y
Dy = diff(y); %Differential of y
f = dsolve('Dy + 3*x^2*y = 6*x^2','y(0)=3','x'); %Solve with dsolve

%Verify with dsolve


fprintf('After using dsolve, we get the equation is f(x) = %s\n',f)
fprintf('So this is verified\n')
pause(3); %Pause the code in 3 seconds

%Using Euler method


k(x,y) = 6*x^2 - 3*x^2*y; %The dy/dx
n = (xn - x0)/h; %Caculate the steps
y1(1,:) = y0; %Add the value of y0 to matrx y1
x1(1,:) = x0; %Add the value of x0 to matrx x1
for i = 1:n %Use Euler method with the loop
9
slope = k(x0,y0);
yn = y0 + h*slope;
y0 = yn;
y1(i+1, :) = y0; %Add the value of y0 to matrx y1
x0 = x0 + h;
x1(i+1, :) = x0; %Add the value of x0 to matrx x1
end
V = [x1 y1]
fprintf('The answer is %f \n',double(yn)); %Print the answer

%Caculate the error


error = abs(yn - double(subs(f,x0)));
fprintf('The error is %f \n',double(error)); %Print the error

%Draw the diagram


clf
%Draw the diagram based on the matrix x1 and y1
plot(x1,y1,'-r')
title('The difference between Euler method (red) and equation f(x) (blue)')
hold on
%Draw the diagram based on the equation f(x)
plot(x1, subs(f,x1),'-b')

function Enter_the_value
global h
%Choose the value of h
h = menu("What is the value of h?",'h = 1','h = 0.1'...
,'h = 0.01 ','h = 0.001','Quit');
if h == 1
h = 1;
elseif h == 2
h = 0.1;
elseif h == 3
h = 0.01;
elseif h == 4
h = 0.001;
elseif h ==5
return
end
end

iii. Result
In this example we assumed that the value of initial conditions of x and y are 0 and 3,
the required value of x is 1 and the interval (h) is 0.1.
After calculating, we get the value of y when x = 1 is 2.392794 with an error is
0.024914. The figure shows the difference between the Euler method (red) and the equation
f(x) blue. The red line will be more and more matched if the h is smaller and smaller.

10
11

You might also like