Numerical Methods and Computer Programming Lab: Tutorial 01 - Roots of Equations

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

Numerical Methods and

Computer Programming Lab


Tutorial 01 – Roots of Equations

Dr. Chandrashekhar Hiremath


cph.mech@coep.ac.in
2nd Aug 2018
Department of Mechanical Engineering
Tutorials using C language
• Roots of Equations – T01

• Linear Algebraic Equations – T02

• Iterative Methods in Algebraic Equations or Numerical Interpolation – T03

• Numerical Integration – T04

• Ordinary Differential Equation – T05


Evaluation
• T2 – 20 marks
• Tutorial 1 to 4 (5 marks each)

• End Sem – 20 marks


• Tutorial 5 – 5 marks
• Attendance – 5 marks
• Oral/Test (programming) – 10 marks – during last two sessions (before end
sem exam)
• Syllabus – Tutorial 1 to 5
Tutorial 1: Roots of Equations
• Q1

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill
Education. 2015: Chapter 5 – section 5.1, 5.2, 5.3
Tutorial 1: Roots of Equations…
• Q2

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill Education.
2015: Chapter 6 – section 6.2, 6.3
• Last date of submission – (Tue) 21 Aug 2018 - 3 pm
Report Format
• Title page – Tutorial number, tutorial title, roll number and date of
submission
• For each completed answer
• 1st page – graph paper
• 2nd page – Flowchart for bisection method
• 3rd page – c program for bisection method
• 4th page - Flowchart for false position method
• 5th page – c program for false position method
• 6th page – output of bisection program
• 7th page – output of false position program
• 8th page – comparison of the results using graphical, bisection and false position
method and write conclusion
Tutorial 1: Roots of Equations
• Q1
Q1 - Graphically
• f(x) = -25 + 82 x – 90 x2 + 44 x3 – 8 x4 + 0.7 x5
• xl = 0.5 xu = 1.0
4.0
x f(x)
0.5 -1.478 3.0
0.6 0.322
0.7 1.589 2.0
0.8 2.481
1.0

f(x)
0.9 3.141
1 3.700
0.0
0.5 0.6 0.7 0.8 0.9 1
0.579361 -0.001 -1.0

-2.0
x
Q1 - Bisection

• Error estimate

• Stop program when error estimate reaches 10% and report the value of the root
Q1 - Steps
• Define variables
• Compute f(xl) and f(xu). Compute f(xl)*f(xu). Check that f(xl)*f(xu)<0
• Bisection
• Estimate xr (average of xl and xu).
• Compute f(xr), f(xr)*f(xl)
• Conditions
• If f(xr)*f(xl) < 0 xu=xr
• If f(xr)*f(xl) > 0 xl=xr
• If f(xr)*f(xl) = 0 end loop
• Compute error and check error criteria (10%)
• Repeat
• Print output
Q1 – False Position
Tutorial 1: Roots of Equations…
• Q2

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill Education.
2015: Chapter 6 – section 6.2, 6.3
• Last date of submission – (Tue) 21 Aug 2018 - 3 pm
Q2 - Newton – Raphson Method
Q2 – Secant Method
First Program
• Login to the computer – password ‘student’
• Create a folder and name it with your roll no.
• Create a subfolder “T0”
• Write a c program to print “Hello World”
• Ensure that the program is saved in “T0” folder
• Compile and run the program
• Save the output in a text file “out0.txt”
Thank You
Open text editor
Type your program
Save it in the desired folder

cd folder name – change directory

> gcc filename.c -lm - to compile the program

> ./a.out > out0.txt - to store the output in out0 file


Output for each program
• Print MIS no.

• Print the given function f(x)

• Print values of xl, xu, fxl, fxu

• Print xr, fxr and error for each iteration


Tutorial 2: Linear Algebraic Equations
• Q1

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill
Education. 2015: Chapter 9 – section 9.1, 9.2, 9.3, 9.4
Tutorial 2: Linear Algebraic Equations…
• Q2

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill Education.
2015: Chapter 11 – section 11.1, 11.2
• Last date of submission – (Tue) 11 Sept 2018 - 3 pm
Tutorial 01 - Answers
Tutorial 3: Curve Fitting
Group Activity
• Max team size: 5

• One report to be submitted by each group

• Include MIS No. and batch No. of each team member on the first
page

• No. of questions/ programs = 5


Tutorial 3: Curve Fitting
• Q1

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill
Education. 2015: Chapter 17 – section 17.1
Tutorial 3: Curve Fitting
• Q2

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill
Education. 2015: Chapter 17 – section 17.3
Tutorial 3: Curve Fitting
• Q3 & Q4

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill
Education. 2015: Chapter 18 – section 18.1, 18.2
Tutorial 3: Curve Fitting
• Q5

Chapra SC, Canale RP. Numerical methods for engineers. McGraw Hill
Education. 2015: Chapter 18 – section 18.7
Last date of submission – (Tue) 25 Sept 2018 - 3 pm

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy