Scilab/C4/Integration/English

From Script | Spoken-Tutorial
Revision as of 10:52, 13 June 2013 by Lavitha Pereira (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of script: Numerical Methods for Integration

Author: Shamika

Keywords: Integration, Numerical Methods, integral


Visual Cue
Narration
Slide 1 Dear Friends,

Welcome to the Spoken Tutorial on “ Composite Numerical Integration

Slide 2,3 -Learning Objective Slide At the end of this tutorial, you will learn how to:
  • Develop Scilab code for different Composite Numerical Integration algorithms
  • Divide the integral into equal intervals
  • Apply the algorithm to each interval
  • Calculate the composite value of the integral


Slide 4-System Requirement slide * To record this tutorial, I am using Ubuntu 12.04 as the operating system with Scilab 5.3.3 version


Slide 5- Prerequisites slide * Before practising this tutorial, a learner should have basic knowledge of Scilab and Integration using Numerical Methods
  • For Scilab, please refer to the relevant tutorials available on the Spoken Tutorial website.


Slide 6- Numerical Integration Numerical Integration is the:
  • Study of how the numerical value of an integral can be found
  • It is used when exact mathematical integration is not available
  • It approximates a definite integral from values of the
    integrand


Slide 7,8- Composite Trapezoidal Rule-I Composite Trapezoidal Rule is
  • The extension of trapezoidal rule
  • We divide the interval a comma b into n equal intervals
  • Then,
  • h equal to b minus a divided by n is the common length of the intervals
  • Then composite trapezoidal rule is given by
    [The integral of the function F of x in the interval a to b is approximately equal to h multiplied by the sum of the values of the function at x zero to x n



Slide 9- Example


* Let us solve an example using composite trapezoidal rule:
  • Assume the number of intervals n is equal to 10.


Show the code for Trap_composite.sci on Scilab Editor * Let us look at the code for Composite Trapezoidal Rule on Scilab Editor
  • We first define the function with parameters f , a , b , n. f refers to the function we have to solve, a is the lower limit of the integral, b is the upper limit of the integral and n is the number of intervals.
  • linspace function is used to create 10 equal intervals between 0 and 1
  • We find the value of the integral and store it in I1


Click on Execute on Scilab editor and choose Save and Execute the code * Click on Execute on Scilab editor and choose Save and Execute the code


Switch to Scilab Console


deff ('[y]=f(x)','y=1/(2*x+1)')


Trap_composite(f, 0, 1, 10)

* Define the example function by typing:
  • d e f f open paranthesis open single quote open square bracket y close square bracket is equal to f of x close quote comma open quote y is equal to one by open paranthesis two asterisk x plus one close paranthesis close quote close paranthesis
  • Press enter
  • Type
  • Trap underscore composite open paranthesis f comma zero comma one comma ten close paranthesis
  • Press enter
  • The answer is displayed on the console


Slide 10, 11- Composite Simpson's Rule In Composite simpson's rule, we
  • decompose the interval [a comma b] into n is greater than 1 subintervals of equal length
  • Apply Simpson's rule to each interval
  • We get the value of the integral to be
    [h by 3 multiplied by the sum of f zero, 4 into f one , 2 into f two to f n]


Slide 12- Example


* Let us solve an example using Composite Simpson's rule
  • We are given a function one by one plus x cube d x in the interval one to two
  • Let the number of intervals be 20


Switch to Scilab Editor and show the code for Simp_composite.sci * Let us look at the code for Composite simpson's rule
  • We first define the function with parameters f , a , b , n.
    f refers to the function we have to solve, a is the lower limit of the integral, b is the upper limit of the integral and n is the number of intervals.
  • We find two sets of points
  • We find the value of the function with one set and multiply it with 2
  • With the other set we find the value and multiply it with 4
  • We sum these values and multiply it with h by 3 and store the final value in I
  • Let us execute the code


Click on Execute and choose

Save and execute the file

Simp_composite.sci

* Save and execute the file
  • Simp underscore composite dot s c i


Switch to Scilab Console

Type


clc


deff ('[y]=f(x)','y=sin*x+sin*(2*x)')


Simp_composite( f, 0, %pi, 20)

* Let me clear the screen first.
  • Define the function given in the example by typing
  • [d e f f open paranthesis open single quote open square bracket y close square bracket is equal to f of x close quote comma open quote y is equal to sine asterisk x plus sine asterisk open paranthesis two asterisk x close paranthesis close quote close paranthesis]
  • Press enter
  • Type Simp underscore composite open paranthesis f comma one comma two comma twenty close paranthesis
  • Press enter
  • The answer is displayed on the console


Slide 13, 14- Composite Midpoint Rule Let us now look at Composite Midpoint Rule. It
  • Integrates polynomials of degree one or less
  • Divides the interval [ a comma b ]into n subintervals of equal width
  • Finds the midpoint of each interval indicated by x i
  • We find the sum of the values of the integral at each midpoint



Slide 15- Example


Let us solve this problem using Composite Midpoint Rule
  • We are given a function one minus x square d x in the interval zero to one point five
  • We assume n is equal to 20


Switch to Scilab Editor


Show the file mid_composite.sci


* Let us look at the code for Composite Midpoint rule
  • We first define the function with parameters f , a , b , n.
    f refers to the function we have to solve, a is the lower limit of the integral, b is the upper limit of the integral and n is the number of intervals.
  • We find the midpoint of each interval
  • Find the value of integral at each midpoint and then find the sum and store it in I.
  • Let us now solve the example


Click on Execute and choose

Save and execute the file mid_composite.sci

* Save and execute the file mid underscore composite dot s c i


On the Scilab Console type:


clc


deff ('[y]=f(x)','y=1-x^2')


Type mid_composite(f, 0, 1.5, 20)

* Let me clear the screen
  • We define the function given in the example by typing
  • [d e f f open paranthesis open single quote open square bracket y close square bracket is equal to f of x close quote comma open quote y is equal to one minus x square close quote close paranthesis]
  • Press enter
  • Then type
    [mid underscore composite open paranthesis f comma zero comma one point five comma twenty close paranthesis]
  • Press enter
  • The answer is displayed on the console


Slide 16- Summary Let us summarize this tutorial. In this tutorial we have learnt to:
  • Develop Scilab code for numerical integration
  • Find the value of an integral


Show Slide 17

Title: About the Spoken Tutorial Project

  • It summarises the Spoken Tutorial project
  • If you do not have good bandwidth, you can download and watch it


* Watch the video available at the following link
  • It summarises the Spoken Tutorial project
  • If you do not have good bandwidth, you can download and watch it


Show Slide 18

Title: Spoken Tutorial Workshops

The Spoken Tutorial Project Team

  • Conducts workshops using spoken tutorials
  • Gives certificates for those who pass an online test
  • For more details, please write to contact@spoken-tutorial.org


The Spoken Tutorial Project Team
  • Conducts workshops using spoken tutorials
  • Gives certificates for those who pass an online test
  • For more details, please write to contact at spoken hyphen tutorial dot org


Show Slide 19

Title: Acknowledgement

  • Spoken Tutorial Project is a part of the Talk to a Teacher project
  • It is supported by the National Mission on Education through ICT, MHRD, Government of India
  • More information on this Mission is available at


* Spoken Tutorial Project is a part of the Talk to a Teacher project
  • It is supported by the National Mission on Education through ICT, MHRD, Government of India
  • More information on this Mission is available at
  • spoken hyphen tutorial dot org slash NMEICT hyphen Intro


Contributors and Content Editors

Lavitha Pereira, Nancyvarkey