Difference between revisions of "Scilab/C4/Solving-Non-linear-Equations/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
Line 6: Line 6:
  
  
{| style="border-spacing:0;"
+
{|border=1
 
! <center>Visual Cue</center>
 
! <center>Visual Cue</center>
 
 
 
 
! <center>Narration</center>
 
! <center>Narration</center>
  
Line 24: Line 21:
  
 
* Solve '''nonlinear equations''' using numerical methods
 
* Solve '''nonlinear equations''' using numerical methods
* The methods we will be studying are
 
* '''Bisection method'''
 
* and '''Secant method'''
 
 
* We will also develop '''Scilab''' code to solve '''nonlinear equations '''
 
  
 +
The methods we will be studying are
 +
* '''Bisection method''' and
 +
* '''Secant method'''
  
 +
We will also develop '''Scilab''' code to solve '''nonlinear equations'''.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 4-System Requirements
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 4-System Requirements
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To record this tutorial, I am using  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To record this tutorial, I am using  
 
+
* '''Ubuntu 12.04''' as the operating system and
* '''Ubuntu 12.04''' as the operating system  
+
* '''Scilab 5.3.3''' version  
* and '''Scilab 5.3.3''' version  
+
 
+
 
+
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 5- Prerequisites
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 5- Prerequisites
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Before practising this tutorial, a learner should have  
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Before practising this tutorial, a learner should have  
 
 
* basic knowledge of '''Scilab '''and  
 
* basic knowledge of '''Scilab '''and  
 
* '''nonlinear equations'''
 
* '''nonlinear equations'''
  
For Scilab, please refer to the '''Scilab''' tutorials available on the '''Spoken Tutorial '''website.  
+
For '''Scilab''', please refer to the '''Scilab''' tutorials available on the '''Spoken Tutorial '''website.  
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 6
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 6
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| For a given '''function f''' , we have to find the value of''' x''' for which '''f of x is equal to zero.'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| For a given '''function f''', we have to find the value of''' x''' for which '''f of x''' is equal to zero.  
  
This solution x is called '''root of equation or zero of function f'''
+
This solution '''x''' is called '''root of equation''' or '''zero of function f'''.
  
This process is called '''root finding or zero finding'''
+
This process is called '''root finding''' or '''zero finding'''.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 7
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 7
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We begin by studying '''Bisection Method'''.
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We begin by studying '''Bisection Method'''.
 
 
 
* In '''bisection method,''' we calculate the '''initial bracket''' of the '''root'''.  
 
* In '''bisection method,''' we calculate the '''initial bracket''' of the '''root'''.  
 
* Then we iterate through the '''bracket''' and halve its length.  
 
* Then we iterate through the '''bracket''' and halve its length.  
* We repeat this proces until we find the solution of the equation.
+
* We repeat this process until we find the solution of the equation.
 
+
 
+
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 8
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 8
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us solve this function using '''Bisection method'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us solve this function using '''Bisection method'''.
 
+
  
 
Given  
 
Given  
  
'''function f equal to two sin x minus e to the power of x divided by four minus one in the interval minus five and minus three. '''
+
'''function f equal to two sin x minus e to the power of x divided by four minus one in the interval minus five and minus three'''
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Open '''Bisection.sci''' on Scilab Editor
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Open '''Bisection.sci''' on Scilab Editor
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| * Open '''Bisection dot sci '''on '''Scilab editor'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|  
* Let us look at the code for '''Bisection method'''
+
Open '''Bisection dot sci '''on '''Scilab editor'''.
* We define the function '''Bisection''' with input arguments '''a b f '''and '''tol'''
+
 
* Here '''a''' is the lower limit of the interval
+
Let us look at the code for '''Bisection method'''.
* '''b '''is the upper limit of the interval
+
 
 +
We define the function '''Bisection''' with input arguments '''a b f '''and '''tol'''.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight as per narration
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
 +
Here  
 +
* '''a''' is the lower limit of the '''interval'''
 +
* '''b '''is the upper limit of the '''interval'''
 
* '''f''' is the function to be solved
 
* '''f''' is the function to be solved
 
* and '''tol''' is the''' tolerance level'''
 
* and '''tol''' is the''' tolerance level'''
* We specify the maximum number of iterations to be equal to hundred.
 
* We find the '''midpoint of the interval '''and iterate till the value calculated is within the specified '''tolerance range'''.
 
  
  
 +
We specify the maximum number of iterations to be equal to hundred.
 +
 +
 +
We find the '''midpoint of the interval '''and iterate till the value calculated is within the specified '''tolerance range'''.
  
 
|-
 
|-
Line 97: Line 94:
  
  
'''Save and execute '''the file
+
Save and execute the file.
  
 
|-
 
|-
Line 103: Line 100:
  
  
On Scilab Console type,  
+
On Scilab Console, type,  
  
 
a=-5
 
a=-5
Line 110: Line 107:
  
 
b=-3
 
b=-3
 
Press enter
 
 
 
<nowiki>deff('[y]=f(x)','y=(2*(sin(x))-((%e^x)/4)-1')</nowiki>
 
 
Press enter
 
 
 
Tol=10^-5
 
 
Press enter
 
 
Bisection(a,b,f,Tol)
 
  
 
Press enter
 
Press enter
Line 129: Line 112:
  
  
Let us define the interval.  
+
Let us define the '''interval'''.  
  
  
Let '''a '''be equal to minus five  
+
Let '''a '''be equal to minus five.
  
Press enter
+
Press '''Enter'''.
  
  
 
Let '''b''' be equal to minus three.  
 
Let '''b''' be equal to minus three.  
  
Press enter
+
Press '''Enter'''.
  
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
 +
<nowiki>deff('[y]=f(x)','y=(2*(sin(x))-((%e^x)/4)-1')</nowiki>
  
Define the function using '''deff function'''.  
+
Press enter
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Define the function using '''deff function'''.  
  
 
We type  
 
We type  
Line 148: Line 135:
 
'''deff open paranthesis open single quote open square bracket y close square bracket equal to f of x close single quote comma open single quote y equal to two asterisk sin of x minus open paranthesis open paranthesis percentage e to the power of x close paranthesis divided by four close paranthesis minus one close single quote close paranthesis'''
 
'''deff open paranthesis open single quote open square bracket y close square bracket equal to f of x close single quote comma open single quote y equal to two asterisk sin of x minus open paranthesis open paranthesis percentage e to the power of x close paranthesis divided by four close paranthesis minus one close single quote close paranthesis'''
  
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
 +
Press '''Enter'''.
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To know more about '''deff function''', type '''help deff'''
  
To know more about '''deff function''', type help '''deff'''
+
Press '''Enter'''.
  
'''Press enter'''
+
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
  
 +
Tol=10^-5
  
Let '''tol '''be equal to 10 to the power of minus five
+
Press enter
  
'''Press enter'''
+
Bisection(a,b,f,Tol)
  
 +
Press enter
  
To solve the problem, type
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let '''tol '''be equal to 10 to the power of minus five.
  
 +
Press '''Enter'''.
  
'''Bisection open paranthesis a comma b comma f comma tol close paranthesis'''
 
  
'''Press enter'''
+
To solve the problem, type
  
 +
'''Bisection open paranthesis a comma b comma f comma tol close paranthesis'''
  
The root of the function is '''shown on the console'''
+
Press '''Enter'''.
 +
 
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The root of the function is shown on the console.
  
 
|-
 
|-
Line 174: Line 173:
  
  
In '''Secan't method, '''the derivative is approximated by finite  
+
In '''Secant's method, '''the derivative is approximated by finite difference using two successive '''iteration values.'''  
 
+
difference using two successive '''iteration values.'''  
+
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 13
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 13
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us solve this example using '''Secant method'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us solve this example using '''Secant method'''.
  
 
The function is '''f equal to x square minus six'''.  
 
The function is '''f equal to x square minus six'''.  
Line 189: Line 186:
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Open Secant.sci on Scilab Editor
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Open Secant.sci on Scilab Editor
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Before we solve the problem, let us look at the code for '''Secant meethod. '''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Before we solve the problem, let us look at the code for '''Secant method. '''
  
  
Open '''Secant dot sci '''on '''Scilab editor'''
+
Open '''Secant dot sci '''on '''Scilab editor'''.
  
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|Highlight as per narration
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We define the function '''secant '''with input arguments '''a, b '''and '''f'''.
  
We define the function '''secant '''with input arguments '''a, b '''and '''f'''
+
*'''a''' is first starting guess for the root
 +
*'''b''' is the second starting guess and  
 +
*'''f''' is the function to be solved.
  
 
+
|-
'''a''' is first starting guess for the root
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|Highlight as per narration
 
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We find the difference between the value at the current point and the previous point.  
 
+
'''b''' is the second starting guess and f is the function to be solved.  
+
 
+
 
+
We find the difference between the value at the current point and the previous point.  
+
  
  
 
We apply '''Secant's method '''and find the value of the root.
 
We apply '''Secant's method '''and find the value of the root.
  
 
+
|-
Finally we end the function
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|Highlight as per narration
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Finally we end the function.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Click on Execute and select Save and Execute
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Click on Execute and select Save and Execute
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let me '''save and execute '''the code.  
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let me save and execute the code.  
  
 
|-
 
|-
Line 225: Line 223:
  
 
Press enter
 
Press enter
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Switch to '''Scilab console'''.
  
  
a=2
+
Type '''clc'''.
  
Press enter
+
Press '''Enter'''.
  
 
+
|-
b=3
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| a=2
  
 
Press enter
 
Press enter
  
  
<nowiki>deff('[y]=g(x)','y=(x^2)-6')</nowiki>
+
b=3
  
 
Press enter
 
Press enter
  
 
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let me define the initial guesses for this example. Type
Secant(a,b,g)
+
 
+
Press enter
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Switch to '''Scilab console'''
+
 
+
 
+
Type '''clc'''
+
 
+
Press '''enter'''
+
 
+
 
+
Let me define the initial guesses for this example. Type
+
  
 
'''a '''equal to 2
 
'''a '''equal to 2
  
Press '''enter'''
+
Press '''Enter'''.
  
  
Line 264: Line 251:
 
'''b '''equal to 3
 
'''b '''equal to 3
  
Press '''enter'''
+
Press '''Enter'''.
  
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| <nowiki>deff('[y]=g(x)','y=(x^2)-6')</nowiki>
  
We define the function using '''deff function. '''
+
Press enter
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We define the function using '''deff function. '''
  
 
Type  
 
Type  
Line 273: Line 263:
 
'''deff open paranthesis open single quote open square bracket y close square bracket equal to g of x close single quote comma open single quote y equal to open paranthesis x to the power of two close paranthesis minus six close single quote close paranthesis'''
 
'''deff open paranthesis open single quote open square bracket y close square bracket equal to g of x close single quote comma open single quote y equal to open paranthesis x to the power of two close paranthesis minus six close single quote close paranthesis'''
  
'''Press enter'''
+
Press '''Enter'''.
  
 +
|-
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Secant(a,b,g)
 +
 +
Press enter
  
We call the function by typing  
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We call the function by typing  
  
 
'''Secant open paranthesis a comma b comma g close paranthesis. '''
 
'''Secant open paranthesis a comma b comma g close paranthesis. '''
  
'''Press enter'''
+
Press '''Enter'''.
  
  
 
The value of the root is shown on the '''console'''
 
The value of the root is shown on the '''console'''
 
 
 
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 14
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 14
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us summarize this tutorial
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us summarize this tutorial.
  
 
In this tutorial we have learnt to:
 
In this tutorial we have learnt to:
 
+
* Develop''' Scilab '''code for different solving methods
 
* Find the roots of '''nonlinear equation'''
 
* Find the roots of '''nonlinear equation'''
* Develop''' Scilab '''code for different solving methods
 
 
 
  
 
|-
 
|-
Line 318: Line 306:
 
* It summarises the Spoken Tutorial project  
 
* It summarises the Spoken Tutorial project  
 
* If you do not have good bandwidth, you can download and watch it <br/>  
 
* If you do not have good bandwidth, you can download and watch it <br/>  
 
 
 
  
 
|-
 
|-
Line 328: Line 313:
  
 
The Spoken Tutorial Project Team  
 
The Spoken Tutorial Project Team  
 
 
* Conducts workshops using spoken tutorials  
 
* Conducts workshops using spoken tutorials  
 
 
* Gives certificates for those who pass an online test  
 
* Gives certificates for those who pass an online test  
 
 
* For more details, please write to contact@spoken-tutorial.org  
 
* For more details, please write to contact@spoken-tutorial.org  
  
Line 339: Line 321:
  
 
* Conducts workshops using spoken tutorials  
 
* Conducts workshops using spoken tutorials  
 
 
* Gives certificates for those who pass an online test  
 
* Gives certificates for those who pass an online test  
 
 
* For more details, please write to contact at spoken hyphen tutorial dot org  
 
* For more details, please write to contact at spoken hyphen tutorial dot org  
 
 
  
 
|-
 
|-
Line 352: Line 330:
  
 
* Spoken Tutorial Project is a part of the Talk to a Teacher project  
 
* 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  
 
* It is supported by the National Mission on Education through ICT, MHRD, Government of India  
 
 
* More information on this Mission is available at  
 
* More information on this Mission is available at  
 
 
* [http://spoken-tutorial.org/NMEICT-Intro http://spoken-tutorial.org/NMEICT-Intro]  
 
* [http://spoken-tutorial.org/NMEICT-Intro http://spoken-tutorial.org/NMEICT-Intro]  
  
Line 364: Line 339:
 
* More information on this Mission is available at  
 
* More information on this Mission is available at  
 
* spoken hyphen tutorial dot org slash NMEICT hyphen Intro  
 
* spoken hyphen tutorial dot org slash NMEICT hyphen Intro  
 
 
  
 
|-
 
|-

Latest revision as of 18:45, 12 February 2014

Title of script: Solving Nonlinear Equations using Numerical Methods

Author: Shamika

Keywords: Nonlinear equation, root, zero


Visual Cue
Narration
Slide 1 Dear Friends,

Welcome to the spoken tutorial on “Solving Nonlinear Equations using Numerical Methods

Slide 2,3 -Objectives At the end of this tutorial, you will learn how to:
  • Solve nonlinear equations using numerical methods

The methods we will be studying are

  • Bisection method and
  • Secant method

We will also develop Scilab code to solve nonlinear equations.

Slide 4-System Requirements To record this tutorial, I am using
  • Ubuntu 12.04 as the operating system and
  • Scilab 5.3.3 version
Slide 5- Prerequisites Before practising this tutorial, a learner should have
  • basic knowledge of Scilab and
  • nonlinear equations

For Scilab, please refer to the Scilab tutorials available on the Spoken Tutorial website.

Slide 6 For a given function f, we have to find the value of x for which f of x is equal to zero.

This solution x is called root of equation or zero of function f.

This process is called root finding or zero finding.

Slide 7 We begin by studying Bisection Method.
  • In bisection method, we calculate the initial bracket of the root.
  • Then we iterate through the bracket and halve its length.
  • We repeat this process until we find the solution of the equation.
Slide 8 Let us solve this function using Bisection method.

Given

function f equal to two sin x minus e to the power of x divided by four minus one in the interval minus five and minus three

Open Bisection.sci on Scilab Editor

Open Bisection dot sci on Scilab editor.

Let us look at the code for Bisection method.

We define the function Bisection with input arguments a b f and tol.

Highlight as per narration

Here

  • a is the lower limit of the interval
  • b is the upper limit of the interval
  • f is the function to be solved
  • and tol is the tolerance level


We specify the maximum number of iterations to be equal to hundred.


We find the midpoint of the interval and iterate till the value calculated is within the specified tolerance range.

Click on Execute and select Save and Execute Let us solve the problem using this code.


Save and execute the file.

Switch to Scilab console


On Scilab Console, type,

a=-5

Press enter

b=-3

Press enter

Switch to Scilab console


Let us define the interval.


Let a be equal to minus five.

Press Enter.


Let b be equal to minus three.

Press Enter.

deff('[y]=f(x)','y=(2*(sin(x))-((%e^x)/4)-1')

Press enter

Define the function using deff function.

We type

deff open paranthesis open single quote open square bracket y close square bracket equal to f of x close single quote comma open single quote y equal to two asterisk sin of x minus open paranthesis open paranthesis percentage e to the power of x close paranthesis divided by four close paranthesis minus one close single quote close paranthesis

Press Enter.

To know more about deff function, type help deff

Press Enter.

Tol=10^-5

Press enter

Bisection(a,b,f,Tol)

Press enter

Let tol be equal to 10 to the power of minus five.

Press Enter.


To solve the problem, type

Bisection open paranthesis a comma b comma f comma tol close paranthesis

Press Enter.

The root of the function is shown on the console.
Slide 12 Let us study Secant's method.


In Secant's method, the derivative is approximated by finite difference using two successive iteration values.

Slide 13 Let us solve this example using Secant method.

The function is f equal to x square minus six.


The two starting guesses are , p zero equal to two and p one equal to three.

Open Secant.sci on Scilab Editor Before we solve the problem, let us look at the code for Secant method.


Open Secant dot sci on Scilab editor.

Highlight as per narration We define the function secant with input arguments a, b and f.
  • a is first starting guess for the root
  • b is the second starting guess and
  • f is the function to be solved.
Highlight as per narration We find the difference between the value at the current point and the previous point.


We apply Secant's method and find the value of the root.

Highlight as per narration Finally we end the function.
Click on Execute and select Save and Execute Let me save and execute the code.
Switch to Scilab console

Type on Scilab console


clc

Press enter

Switch to Scilab console.


Type clc.

Press Enter.

a=2

Press enter


b=3

Press enter

Let me define the initial guesses for this example. Type

a equal to 2

Press Enter.


Then type

b equal to 3

Press Enter.

deff('[y]=g(x)','y=(x^2)-6')

Press enter

We define the function using deff function.

Type

deff open paranthesis open single quote open square bracket y close square bracket equal to g of x close single quote comma open single quote y equal to open paranthesis x to the power of two close paranthesis minus six close single quote close paranthesis

Press Enter.

Secant(a,b,g)

Press enter

We call the function by typing

Secant open paranthesis a comma b comma g close paranthesis.

Press Enter.


The value of the root is shown on the console

Slide 14 Let us summarize this tutorial.

In this tutorial we have learnt to:

  • Develop Scilab code for different solving methods
  • Find the roots of nonlinear equation
Slide 15- Assignment Solve this problem on your own using the two methods we learnt today.
Show Slide 16

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 17

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 18

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
  • http://spoken-tutorial.org/NMEICT-Intro


* 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
On previous slide This is Ashwini Patil signing off. Thanks for joining.

Contributors and Content Editors

Lavitha Pereira, Nancyvarkey