SlideShare a Scribd company logo
Scientific Programming Using
Excel VBA for Beginners
Dr. RIZAuddin bin Saian
Faculty of Computer & Mathematical Sciences
Universiti Teknologi MARA (Perlis)
Venue: LT1, UiTM Perlis
27 September 2019 (Friday)
3pm
Problem
• We want to find the root for .
227/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Objective
• To approximate the root for
using Newton’s method (Newton-Raphson
method)
– Perform Newton’s method by hand.
– Write a VBA code to perform the Newton’s
method.
327/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Newton’s Method
427/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Equation of tangent line
527/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Initial Guess of x
6
Actual root
X
X
x0
(Initial guess)
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 1
7
X
Tangent line at x0 = -1
X
x0x1
Actual root
(Initial guess)
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 2
8
x1
Tangent line at x1
X X
x0
Actual root
(Initial guess)
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Example: Find the root.
9
Actual root
X
x0 = -1
X
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Initial guess of x
10
The estimated root,
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 1
11
i x xn+1
0 - 1 -1.5
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 2
12
i x xn+1
0 - 1 -1.5
1 -1.5 -1.347826087
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 3
13
i x xn+1
0 - 1 -1.5
1 -1.5 -1.347826087
2 -1.347826087 -1.325200399
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 4
14
i x xn+1
0 - 1 -1.5
1 -1.5 -1.347826087
2 -1.347826087 -1.325200399
3 -1.325200399 -1.324718174
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 5
15
i x xn+1
0 - 1 -1.5
1 -1.5 -1.347826087
2 -1.347826087 -1.325200399
3 -1.325200399 -1.324718174
4 -1.324718174 -1.324717957
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 6
16
i x xn+1
0 - 1 -1.5
1 -1.5 -1.347826087
2 -1.347826087 -1.325200399
3 -1.325200399 -1.324718174
4 -1.324718174 -1.324717957
5 -1.324717957 -1.324717957
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Iteration 6
17
i x xn+1
0 - 1 -1.5
1 -1.5 -1.347826087
2 -1.347826087 -1.325200399
3 -1.325200399 -1.324718174
4 -1.324718174 -1.324717957
5 -1.324717957 -1.324717957
STOP!
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Visual Basic for Application (VBA)
18
Press Alt key and hold. Then, press F11 together to open the VBA Editor.
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Add new Module
1927/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Define a function
2027/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Exercise 1
• Define function Newton with parameter “x”
and return the estimation value for the root
of with x0=-1.
2127/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Exercise 1
• Define function Newton with parameter “x”
and return the estimation value for the root
of with x0=-1.
2227/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Loop
2327/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Exercise 2
• Modify the Newton function in Ex. 1 to use
loop to calculate the root using 4 iterations.
2427/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
Exercise 2
• Modify the Newton function in Ex. 1 to use
loop to calculate the root using 4 iterations.
2527/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
THANK YOU
www.rizauddin.com
27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com 26

More Related Content

Similar to Scientific programming using Excel VBA for beginners

Algorithms and Data Structures - Edukite
Algorithms and Data Structures - EdukiteAlgorithms and Data Structures - Edukite
Algorithms and Data Structures - Edukite
EduKite
 
Basic Principles of Behavior of Algorithms - Edukite
Basic Principles of Behavior of Algorithms - EdukiteBasic Principles of Behavior of Algorithms - Edukite
Basic Principles of Behavior of Algorithms - Edukite
EduKite
 
Diploma In MATLAB for Scientific Computing – Edu Kite
Diploma In MATLAB for Scientific Computing – Edu KiteDiploma In MATLAB for Scientific Computing – Edu Kite
Diploma In MATLAB for Scientific Computing – Edu Kite
EduKite
 
Boost Your Data Career with Predictive Analytics! Learn How ?
Boost Your Data Career with Predictive Analytics! Learn How ? Boost Your Data Career with Predictive Analytics! Learn How ?
Boost Your Data Career with Predictive Analytics! Learn How ?
Edureka!
 
IJSRED-V2I5P42
IJSRED-V2I5P42IJSRED-V2I5P42
IJSRED-V2I5P42
IJSRED
 
IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...
IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...
IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...
IRJET Journal
 
SAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdfSAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdf
KoushikGuna
 
EnTagRec: An Enhanced Tag Recommendation System for Software Information Sites
EnTagRec: An Enhanced Tag Recommendation System for Software Information SitesEnTagRec: An Enhanced Tag Recommendation System for Software Information Sites
EnTagRec: An Enhanced Tag Recommendation System for Software Information Sites
Alexander Serebrenik
 
Agent based modeling level 2 - edukite
Agent based modeling level 2 - edukiteAgent based modeling level 2 - edukite
Agent based modeling level 2 - edukite
EduKite
 
Microsoft Office 2016 Excel Beginners - Course Gate
Microsoft Office 2016 Excel Beginners - Course GateMicrosoft Office 2016 Excel Beginners - Course Gate
Microsoft Office 2016 Excel Beginners - Course Gate
Course Gate
 
Arduino Based Scientific Calculator
Arduino Based Scientific CalculatorArduino Based Scientific Calculator
Arduino Based Scientific Calculator
ijtsrd
 
Stock Market Analysis and Prediction
Stock Market Analysis and PredictionStock Market Analysis and Prediction
Stock Market Analysis and Prediction
Anil Shrestha
 
ATI Courses Professional Development Short Course Engineering Systems Modelin...
ATI Courses Professional Development Short Course Engineering Systems Modelin...ATI Courses Professional Development Short Course Engineering Systems Modelin...
ATI Courses Professional Development Short Course Engineering Systems Modelin...
Jim Jenkins
 
Basic Concepts Of Numerical Analysis For Engineering - Edukite
Basic Concepts Of Numerical Analysis For Engineering - EdukiteBasic Concepts Of Numerical Analysis For Engineering - Edukite
Basic Concepts Of Numerical Analysis For Engineering - Edukite
EduKite
 
Microsoft excel 2016 intermediate training - Adams Academy
Microsoft excel 2016 intermediate training  - Adams AcademyMicrosoft excel 2016 intermediate training  - Adams Academy
Microsoft excel 2016 intermediate training - Adams Academy
Adams Academy
 
Certificate In Analytic Methods In Science And Engineering - Edukite
Certificate In Analytic Methods In Science And Engineering - EdukiteCertificate In Analytic Methods In Science And Engineering - Edukite
Certificate In Analytic Methods In Science And Engineering - Edukite
EduKite
 
ASKEDEMYSERIES1BOOK1
ASKEDEMYSERIES1BOOK1ASKEDEMYSERIES1BOOK1
ASKEDEMYSERIES1BOOK1
ASKBiztechInc
 
Microsoft Office 2007 Excel Advanced - Course Gate
Microsoft Office 2007 Excel Advanced - Course GateMicrosoft Office 2007 Excel Advanced - Course Gate
Microsoft Office 2007 Excel Advanced - Course Gate
Course Gate
 
IRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and Lime
IRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and LimeIRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and Lime
IRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and Lime
IRJET Journal
 
IRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine LearningIRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine Learning
IRJET Journal
 

Similar to Scientific programming using Excel VBA for beginners (20)

Algorithms and Data Structures - Edukite
Algorithms and Data Structures - EdukiteAlgorithms and Data Structures - Edukite
Algorithms and Data Structures - Edukite
 
Basic Principles of Behavior of Algorithms - Edukite
Basic Principles of Behavior of Algorithms - EdukiteBasic Principles of Behavior of Algorithms - Edukite
Basic Principles of Behavior of Algorithms - Edukite
 
Diploma In MATLAB for Scientific Computing – Edu Kite
Diploma In MATLAB for Scientific Computing – Edu KiteDiploma In MATLAB for Scientific Computing – Edu Kite
Diploma In MATLAB for Scientific Computing – Edu Kite
 
Boost Your Data Career with Predictive Analytics! Learn How ?
Boost Your Data Career with Predictive Analytics! Learn How ? Boost Your Data Career with Predictive Analytics! Learn How ?
Boost Your Data Career with Predictive Analytics! Learn How ?
 
IJSRED-V2I5P42
IJSRED-V2I5P42IJSRED-V2I5P42
IJSRED-V2I5P42
 
IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...
IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...
IRJET- Finding the Original Writer of an Anonymous Text using Naïve Bayes Cla...
 
SAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdfSAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdf
 
EnTagRec: An Enhanced Tag Recommendation System for Software Information Sites
EnTagRec: An Enhanced Tag Recommendation System for Software Information SitesEnTagRec: An Enhanced Tag Recommendation System for Software Information Sites
EnTagRec: An Enhanced Tag Recommendation System for Software Information Sites
 
Agent based modeling level 2 - edukite
Agent based modeling level 2 - edukiteAgent based modeling level 2 - edukite
Agent based modeling level 2 - edukite
 
Microsoft Office 2016 Excel Beginners - Course Gate
Microsoft Office 2016 Excel Beginners - Course GateMicrosoft Office 2016 Excel Beginners - Course Gate
Microsoft Office 2016 Excel Beginners - Course Gate
 
Arduino Based Scientific Calculator
Arduino Based Scientific CalculatorArduino Based Scientific Calculator
Arduino Based Scientific Calculator
 
Stock Market Analysis and Prediction
Stock Market Analysis and PredictionStock Market Analysis and Prediction
Stock Market Analysis and Prediction
 
ATI Courses Professional Development Short Course Engineering Systems Modelin...
ATI Courses Professional Development Short Course Engineering Systems Modelin...ATI Courses Professional Development Short Course Engineering Systems Modelin...
ATI Courses Professional Development Short Course Engineering Systems Modelin...
 
Basic Concepts Of Numerical Analysis For Engineering - Edukite
Basic Concepts Of Numerical Analysis For Engineering - EdukiteBasic Concepts Of Numerical Analysis For Engineering - Edukite
Basic Concepts Of Numerical Analysis For Engineering - Edukite
 
Microsoft excel 2016 intermediate training - Adams Academy
Microsoft excel 2016 intermediate training  - Adams AcademyMicrosoft excel 2016 intermediate training  - Adams Academy
Microsoft excel 2016 intermediate training - Adams Academy
 
Certificate In Analytic Methods In Science And Engineering - Edukite
Certificate In Analytic Methods In Science And Engineering - EdukiteCertificate In Analytic Methods In Science And Engineering - Edukite
Certificate In Analytic Methods In Science And Engineering - Edukite
 
ASKEDEMYSERIES1BOOK1
ASKEDEMYSERIES1BOOK1ASKEDEMYSERIES1BOOK1
ASKEDEMYSERIES1BOOK1
 
Microsoft Office 2007 Excel Advanced - Course Gate
Microsoft Office 2007 Excel Advanced - Course GateMicrosoft Office 2007 Excel Advanced - Course Gate
Microsoft Office 2007 Excel Advanced - Course Gate
 
IRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and Lime
IRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and LimeIRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and Lime
IRJET- Stabilization of Black Cotton Soil using Rice Husk Ash and Lime
 
IRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine LearningIRJET- Student Placement Prediction using Machine Learning
IRJET- Student Placement Prediction using Machine Learning
 

Recently uploaded

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 

Recently uploaded (20)

BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 

Scientific programming using Excel VBA for beginners

  • 1. Scientific Programming Using Excel VBA for Beginners Dr. RIZAuddin bin Saian Faculty of Computer & Mathematical Sciences Universiti Teknologi MARA (Perlis) Venue: LT1, UiTM Perlis 27 September 2019 (Friday) 3pm
  • 2. Problem • We want to find the root for . 227/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 3. Objective • To approximate the root for using Newton’s method (Newton-Raphson method) – Perform Newton’s method by hand. – Write a VBA code to perform the Newton’s method. 327/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 4. Newton’s Method 427/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 5. Equation of tangent line 527/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 6. Initial Guess of x 6 Actual root X X x0 (Initial guess) 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 7. Iteration 1 7 X Tangent line at x0 = -1 X x0x1 Actual root (Initial guess) 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 8. Iteration 2 8 x1 Tangent line at x1 X X x0 Actual root (Initial guess) 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 9. Example: Find the root. 9 Actual root X x0 = -1 X 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 10. Initial guess of x 10 The estimated root, 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 11. Iteration 1 11 i x xn+1 0 - 1 -1.5 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 12. Iteration 2 12 i x xn+1 0 - 1 -1.5 1 -1.5 -1.347826087 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 13. Iteration 3 13 i x xn+1 0 - 1 -1.5 1 -1.5 -1.347826087 2 -1.347826087 -1.325200399 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 14. Iteration 4 14 i x xn+1 0 - 1 -1.5 1 -1.5 -1.347826087 2 -1.347826087 -1.325200399 3 -1.325200399 -1.324718174 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 15. Iteration 5 15 i x xn+1 0 - 1 -1.5 1 -1.5 -1.347826087 2 -1.347826087 -1.325200399 3 -1.325200399 -1.324718174 4 -1.324718174 -1.324717957 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 16. Iteration 6 16 i x xn+1 0 - 1 -1.5 1 -1.5 -1.347826087 2 -1.347826087 -1.325200399 3 -1.325200399 -1.324718174 4 -1.324718174 -1.324717957 5 -1.324717957 -1.324717957 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 17. Iteration 6 17 i x xn+1 0 - 1 -1.5 1 -1.5 -1.347826087 2 -1.347826087 -1.325200399 3 -1.325200399 -1.324718174 4 -1.324718174 -1.324717957 5 -1.324717957 -1.324717957 STOP! 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 18. Visual Basic for Application (VBA) 18 Press Alt key and hold. Then, press F11 together to open the VBA Editor. 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 19. Add new Module 1927/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 20. Define a function 2027/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 21. Exercise 1 • Define function Newton with parameter “x” and return the estimation value for the root of with x0=-1. 2127/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 22. Exercise 1 • Define function Newton with parameter “x” and return the estimation value for the root of with x0=-1. 2227/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 23. Loop 2327/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 24. Exercise 2 • Modify the Newton function in Ex. 1 to use loop to calculate the root using 4 iterations. 2427/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 25. Exercise 2 • Modify the Newton function in Ex. 1 to use loop to calculate the root using 4 iterations. 2527/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com
  • 26. THANK YOU www.rizauddin.com 27/09/2019 Scientific Programming Using Excel VBA ::: rizauddin.com 26