Difference between revisions of "Scilab/C4/SolvingNonlinearEquations/English"
(Created page with ''''Title of script''': '''Solving Nonlinear Equations using Numerical Methods''' '''Author: Shamika''' '''Keywords: Nonlinear equation, root, zero''' { style="borderspacing…') 

Line 25:  Line 25:  
* Solve '''nonlinear equations''' using numerical methods  * Solve '''nonlinear equations''' using numerical methods  
* The methods we will be studying are  * The methods we will be studying are  
−  * Bisection method  +  * '''Bisection method''' 
−  * and Secant method  +  * and '''Secant method''' 
* We will also develop '''Scilab''' code to solve '''nonlinear equations '''  * We will also develop '''Scilab''' code to solve '''nonlinear equations '''  
Line 63:  Line 63:  
−  * 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 proces until we find the solution of the equation.  
Line 80:  Line 80:  
    
 style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:none;padding:0.097cm;" Open '''Bisection.sci''' on Scilab Editor   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:none;padding:0.097cm;" Open '''Bisection.sci''' on Scilab Editor  
−   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" * Open Bisection dot sci on Scilab editor  +   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" * Open '''Bisection dot sci '''on '''Scilab editor''' 
−  * Let us look at the code for Bisection method  +  * Let us look at the code for '''Bisection method''' 
−  * We define the function Bisection with input arguments a b f and tol  +  * We define the function '''Bisection''' with input arguments '''a b f '''and '''tol''' 
−  * Here a is the lower limit of the interval  +  * Here '''a''' is the lower limit of the interval 
−  * b is the upper 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  +  * and '''tol''' is the''' tolerance level''' 
* We specify the maximum number of iterations to be equal to hundred.  * 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 find the '''midpoint of the interval '''and iterate till the value calculated is within the specified '''tolerance range'''. 
Line 97:  Line 97:  
−  Save and execute the file  +  '''Save and execute '''the file 
    
Line 126:  Line 126:  
Press enter  Press enter  
−   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Switch to Scilab console  +   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Switch to '''Scilab console''' 
Line 132:  Line 132:  
−  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  
Line 154:  Line 154:  
−  Let '''tol '''be equal to  +  Let '''tol '''be equal to 10 to the power of minus five 
'''Press enter'''  '''Press enter'''  
Line 171:  Line 171:  
    
 style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:none;padding:0.097cm;" Slide 12   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:none;padding:0.097cm;" Slide 12  
−   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Let us study Secant's method.  +   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Let us study '''Secant's method'''. 
In '''Secan't method, '''the derivative is approximated by finite  In '''Secan't method, '''the derivative is approximated by finite  
−  difference using two successive  +  difference using two successive '''iteration values.''' 
−  +  
−  +  
−  +  
−  +  
    
Line 189:  Line 185:  
−  The two starting guesses are , '''p zero '''equal to two and '''p one '''equal to three.  +  The two '''starting guesses''' are , '''p zero '''equal to two and '''p one '''equal to three. 
    
Line 196:  Line 192:  
−  Open Secant dot sci on Scilab editor  +  Open '''Secant dot sci '''on '''Scilab editor''' 
−  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  +  '''a''' is first starting guess for the root 
−  b is the second starting guess and f is the function to be solved.  +  '''b''' is the second starting guess and f is the function to be solved. 
Line 218:  Line 214:  
    
 style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:none;padding:0.097cm;" Click on Execute and select Save and Execute   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:none;padding:0.097cm;" Click on Execute and select Save and Execute  
−   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Let me save and execute the code.  +   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Let me '''save and execute '''the code. 
    
Line 249:  Line 245:  
Press enter  Press enter  
−   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Switch to Scilab console  +   style="bordertop:none;borderbottom:1pt solid #000000;borderleft:1pt solid #000000;borderright:1pt solid #000000;padding:0.097cm;" Switch to '''Scilab console''' 
−  Type clc  +  Type '''clc''' 
−  Press enter  +  Press '''enter''' 
Line 261:  Line 257:  
'''a '''equal to 2  '''a '''equal to 2  
−  Press enter  +  Press '''enter''' 
Line 268:  Line 264:  
'''b '''equal to 3  '''b '''equal to 3  
−  Press enter  +  Press '''enter''' 
Line 287:  Line 283:  
−  The value of the root is shown on the console  +  The value of the root is shown on the '''console''' 
Revision as of 17:20, 12 February 2014
Title of script: Solving Nonlinear Equations using Numerical Methods
Author: Shamika
Keywords: Nonlinear equation, root, zero



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:

Slide 4System Requirements  To record this tutorial, I am using

Slide 5 Prerequisites  Before practising this tutorial, a learner should have
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.

Slide 8  Let us solve this function using Bisection method
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

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

Switch to Scilab console
a=5 Press enter b=3 Press enter
Press enter
Press enter Bisection(a,b,f,Tol) Press enter 
Switch to Scilab console
Press enter
Press enter
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
Press enter
Press enter

Slide 12  Let us study Secant's method.
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.

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

Click on Execute and select Save and Execute  Let me save and execute the code. 
Switch to Scilab console
Type on Scilab console
Press enter
Press enter
Press enter
Press enter
Press enter 
Switch to Scilab console
Press enter
a equal to 2 Press enter
b equal to 3 Press enter
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 open paranthesis a comma b comma g close paranthesis. Press enter

Slide 14  Let us summarize this tutorial
In this tutorial we have learnt to:

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

* Watch the video available at the following link

Show Slide 17
Title: Spoken Tutorial Workshops The Spoken Tutorial Project Team

The Spoken Tutorial Project Team

Show Slide 18
Title: Acknowledgement

* Spoken Tutorial Project is a part of the Talk to a Teacher project

On previous slide  This is Ashwini Patil signing off. Thanks for joining. 