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

Assignment 4 Problem No. 1

The document describes solving three problems using Newton-Raphson method. Problem 1 involves finding the time of impact and range of a projectile. Problem 2 involves using Newton-Raphson to solve the van der Waals equation to find the molar volume of carbon dioxide at 1 atmosphere and 273K. Problem 3 involves rewriting an equation describing charge decay in a capacitor in series with an LCR circuit in the form f(R)=0 and using Newton-Raphson to find the resistance for 1% charge remaining after 0.05 seconds. The document provides the theory, equations, programs and outputs for each problem.

Uploaded by

Rahul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Assignment 4 Problem No. 1

The document describes solving three problems using Newton-Raphson method. Problem 1 involves finding the time of impact and range of a projectile. Problem 2 involves using Newton-Raphson to solve the van der Waals equation to find the molar volume of carbon dioxide at 1 atmosphere and 273K. Problem 3 involves rewriting an equation describing charge decay in a capacitor in series with an LCR circuit in the form f(R)=0 and using Newton-Raphson to find the resistance for 1% charge remaining after 0.05 seconds. The document provides the theory, equations, programs and outputs for each problem.

Uploaded by

Rahul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

ASSIGNMENT 4

Problem No. 1
Let the displacement of a projectile in the vertical and
horizontaldirection be respectively given by

y= 1600*1−e−^(t5))−160*t
and
x= 800*(1−e−^(t5))

a. Plot the trajectory of the projectile.•

b. Use the Newton Raphson method to find the elapsed time until
impactcorrect up to three decimal digits.•

c. Find the number of iterations to achieve this accuracy.•

d.Find the range of the projectile

ANSWER
Given,
The displacement of a projectile in the vertical and
horizontal direction are respectively:
y=16001−𝑒−𝑡5−160𝑡
and
𝑥=800(1−𝑒−𝑡5)
The Trajectory of the aboveprojectile is found out via
eliminating the time factor and plotting the curve obtained
between y and x respectively (in 2 Dimensions).Here the
time elapsed until impact will be obtained via Newton
Raphson Method.The Equation to find the numerical root
via Newton Raphson Method is given as:Xn+1=
Xn–f(Xn)/f’(Xn)Here, the time elapsed until impact refers to
the time at which the projectile hits the ground
(Mathematically this corresponds to the time at which Y-
axis Ordinate becomes Zero). Hence, The Required
Equation becomes:tn+1= tn–y(tn)/y’(tn)Calculating
y’(t):Via Manual Differentiation, we obtain:y’(t)=160(2te-t/
5–1)The Given Transcendental Equation y(t)=0 or 1600(1 –
e-t/5)-160t=0can be solved using Newton-Raphson Method
with the help of y(t) itself at the indicated values and its
derivative respectively.
108| P a g eAfter obtaining the time elapsed until the
impact is found upto the desired accuracy, we then use this
in order to calculate the range of the projectile.

PROGRAM
program projectile
real:: t,x,y,ti,h,f,fd
integer :: i,ct
ti=0.0
open(1,file='proj1.dat',status='unknown')
do i =1,1000
x = 800.0*(1-exp(-ti/5.0))
y = 1600.0*(1-exp(-ti/5.0))-160.0*ti
write(1,*) x,y
ti=ti+0.1
enddo

1 write(*,*)"Enter the Initial Guess value for time "


read(*,*)t
step=1.0
ct=0
do while(abs(step)>0.0001)
ct=ct+1

if(ct>100) then
write(*,*)"Root cannot be determined.Enter another value for
initial time"
goto 1
endif

if (fd(t)==0) then
write(*,*)"Enter another value for Initial time as solution becomes
indefinte"
goto 1
endif
step= -f(t)/fd(t)
t=t+step
enddo

r=800*(1-exp(-t/5.0))
write(*,*)"the object hits ground at(in s)"
print*,t
write(*,*)"the range of the projectile is(in m)",r
write(*,*)"the no of iterations the solution has ungergone has",ct
end program projectile

real function f(a)


real::a
f=1600.0*(1-exp(-a/5.0))-160.0*a
return
end function f

real function fd(a)


real::a
fd=160.0*(2.0*exp(-a/5.0)-1.0)
return
end function fd

OUTPUT
c. The Plot of the Trajectory
In order to obtain the Trajectory of the Projectile, the following
commands have to be used

And the following graph has been obtained.


DISCUSSIONS
1. From the Plot of Trajectory of the Realistic Projectile, it is
clearly evident that the curve is unlike and dissimilar to the
curve obtained for the Ideal Projectile which was symmetric
with respect to the Highest Point achieved by the projectile
on both sides unlike here where the graph is asymmetric
owing to the interaction of the projectile with the
considerable drag force which was previously ignored in the
case of the ideal projectile.
PROBLEM 2

van der Waals’ equation for real gas with a specific range
ofpressure (p) and temperature (T) is given by
(p+aV2)(V−b) =RT
where,a and b are empirical constants, depend on the properties
of a particular gas.
Assuming atmosphere and c.c as the units of pressure and volume
respectively at0oC, van der Waals found a=.00874 atmos and
b=.0023 c.c for CO2.

•Rewrite the expression in the form as f(V) = 0


Plot the function against molar volumeV[0.5,1.5].

•Take an initial guess value from the plot.

•Use Newton Raphson method to solve van der Waals equation to


computemolar volumeVof carbon dioxide correct up to 8th decimal
place , at atemperature of T= 273Kand pressure p= 1 atmos.
Given the value of R=.00368652. Find the number of iteration to
achieve this accuracy.

•Take an initial guess value which is much larger than the result
you haveobtained. Repeat the above process. How sensitive is the
method to the initial guess value?

ANSWER

THEORY
a
( )
a.Given, P+ V ( V −b )=RT where the corresponding variables have the
2

usual sense.
Rewriting the Van der Waal’s equation for real gas in the form of
f ( V )=0 we obtain;

( P+ Va ) ( V −b )−RT=0
2
a ab
PV −Pb+ − −RT =0
V V2
3 2 2
P V −Pb V + aV −ab−RT V =0
V ( PV + a )−V ( Pb+c )−ab=0 ; Here C=RT
2 2

Where f ( V )=V ( P V +a )−V


f ( V )=0 2 2
( Pb+c )−ab
Manually calculating the first derivative of f (V ) we obtain:
' 2
f ( V )=3V P+a−2V (Pb+ c)
Implementing Newton Raphson Method with the help of the
obtained f ( V ) and f ( V ), to find the required molar volume for the
'

given gas under the given conditions:


f (V )
V n +1=V n−
f ' (V )

PROGRAM
program vanderwalls
real*8::f,fd,v,va,error
integer::ct
va=0.5
open(1,file='Vanderwaals.dat',status='unknown')
do while(va<=1.5)
write(1,*)va,f(va)
va=va+0.001
end do

1 write(*,*)"Enter the Initial Guess Value"


read(*,*)v
error=1.0
ct=-1
do while(abs(error)>0.00000001)
ct=ct+1

if(ct>1000)then
write(*,*)"Enter a New Initial Guess Value"
goto 1
end if

if(fd(v)==0.0)then
write(*,*)"Enter a new Initial Guess Vslue as the solution
becomes indefinite"
goto 1
end if

error=-f(v)/fd(v)
v=v+error
end do

write(*,*)"The Required Volume is: "


print"(f10.8)",v
write(*,*)"No. of iterations undergone -->",ct
end program vanderwalls

real*8 function f(x)


real*8,::x
real*8::c,a,b
c=273.*0.00368652
a=0.00874
b=0.0023
f=x*(x**2+a)-x**2*(b+c)-a*b
end function f

real*8 function fd(x)


real*8,::x
real*8::c,a,b
c=273.*0.00368652
a=0.00874
b=0.0023
fd= 3*x**2+a-2*x*(b+c)
end function fd
OUTPUT

a. GRAPH OF f(v) VS v
b. Taking the initial value from the graph = 1.1
The corresponding value of volume V obtained using Newton-
Raphson method is = 1.00000012

The no of iterations required to reach this value is only 4


This is shows the advantage of Newton-Raphson method over the
Bisection method. In this method, the no of steps required to reach
the root is much less than in the Bisection Method. Maybe in this
problem,the no of iterations doesnot matter but in problems of
much accuracy, it does matter
c. We can see from the output here that taking large value of the
initial guess does not affect the results that we obtained from the
program atleast for the first 8 digits after decimal, which is what we
are concerned with. It shows that the method of Newton-Raphson is
not much sensitive to the initial guess because it is method that
uses tangent to the curve of the function to reach the roots of the
solution and by drawing a few trangents, the root value can be
obtained.

IMPORTANT NOTE: Another thing that we can notice here is that


no of iterations required to reach the final root value of the problem
is much greater when the initial guess is taken to be 0.6. The reason
for this is that when the such a close value is used the tangent to
the curve is very flat near the actual root solution, so to reach the
root it requires for iterations.

PROBLEM NO.3:
The amount of instantaneous charge in discharging a fully charged
capacitor in series LCR Circuit (see Figure Below) is given by:
R2
−Rt
1
√ t
q=q 0 e 2 L cos

Where q is the initial charge stored in the capacitor.


0
− 2
CL 4 L

a. Rewrite the expression in the form as


f ( R )=0
b. Use Newton Raphson Method to find a suitable resistance R so that the
charge on a capacitor is discharged to 1% of its original value q0 at time
t=0.05 sec. The values of L and C are 5 Henry and 100 μF respectively.

ANSWER:
We have,
The amount of instantaneous charge in discharging a fully charged
capacitor in series LCR Circuit 
R2
−Rt
1
√ t
q=q 0 e 2 L cos

Where q is the initial charge stored in the capacitor.


0
− 2
CL 4 L

Given, q=0.1 q 0 Hence, We Have:


Writing the above equation in f ( R )=0 form:
−Rt 2
1 R
0.1=e 2 L cos
−Rt
√ 1
− 2t
LC 4 L
R
2
0.1−e 2L

¿> f ( R )=0
cos
√ − 2 t=0
LC 4 L

R2
−Rt
1
Where R = 0.1−e 2 L cos
√ − 2t
LC 4 L

PROGRAM
program problem3
real::f,fd,r,l,c,t,w,a,error
integer::count
l=5
c=0.0001
t=0.05
error=1.0
1 write(*,*)"Enter Initial Guess Value:"
read(*,*)r
count=0
do while(abs(error)>0.00001)
a=r/(2*l)
w=sqrt(1/(l*c)-a**2)

count=count+1
if(count>1000)then
write(*,*)"Root cannot be reached via this Initial
Guess Value.Enter new Value"
goto 1
end if
if(fd(r,a,w)==0.0)then
write(*,*)"Enter New Initial Value because solution
is indefinite"
goto 1
end if
error=-f(r,a,w)/fd(r,a,w)
r=r+error
end do
write(*,*)"The Solution is (in Ohm):",r
write(*,*)"The No. of Iterations Undergone is-->",count
end program problem3

real function f(x,a,w)


real,intent(in)::x,a,w
f=exp(-a*0.05)*cos(w*0.05)-0.1
end function f

real function fd(x,a,w)


real,intent(in)::x,a,w

fd=((-0.05/(2*5))*cos(w*.05)+sin(w*.05)*x*.05/(100*w))*(e
xp(-a*0.05))
end function fd

OUTPUT

DISCUSSIONS
When the resistance of the circuit is around 437 omhs then
the capacitor will loose 1% of its fully charged value at
0.05secs.
IMPORTANT NOTE: We see that after the initial guess of
448, solution given by the complier is NaN, which shows
the sensitivity of the program on initial guess.But wwe
have to understand that this sensitivity is not due to the
method of root finding that we have used(Newton-Raphson)
but due to the problem itself. We the equation we have
used
−Rt 2
1 R
R= 0.1−e 2L
cos
√ − 2t
LC 4 L

When we take the value of Initial Guess R very high, the


term inside the square root becomes negative and thus the
whole term imaginary and we cannot find the root of an
imaginary term using Newton-Raphson method, so we get
the output as NaN when we used an higher value of Initial
Guess of the Resistance.

You might also like