SlideShare a Scribd company logo
1 of 4
CHRISS T. EUGENIO
ES 84- F89W56
clc
//(NEWTON-RAPHSON METHOD)
//Given afunction f(x), evaluate f'(x) symbolically.
function y=f(x)
y = 75*%e^(-1.5*x) + 20*%e^(-0.075*x) - 15
endfunction
function y=g(x)
y = -112.5*%e^(-1.5*x) - 1.5*%e^(-0.075*x)
endfunction
//Allow user to input an initial estimate of the root
xi= input("initalestimate of the root:")
//Graph of the given function
x=[-2:0.5:6]
plot(x,f(x),'blue-')
a=gca()
a.x_location = "origin"
a.y_location = "origin"
mprintf("niteration tt xi tt f(xi) tt f`(xi) tt ea n")
//User-defined function for getting % absolute relative approximate error
function [ea]=PARAError(x, y)
ea=abs((y-x)/y)*100
endfunction
//Initialization, Stopping criterion, es (0.5% in this case)
i= 1
es= 0.5
ea= 100
mprintf("n%dttt%ft%ft%ft%fn",i-1,xi, f(xi),g(xi) , ea)
y=0
plot(xi,f(xi), '.red')
//Loop for approximating the estimate root of the function
while(ea>es)
xi_old = xi
fxi= f(xi_old)
gxi= g(xi_old)
xi= xi_old - (fxi/gxi)
xi_new = xi
ea = PARAError(xi_old,xi_new)
i=i+1
mprintf("n%dttt%ft%ft%ft%fn",i-1,xi,fxi, gxi , ea)
y=0
plot(xi_new,f(xi_new), '.red')
end
//Final estimate of the root plotted in the graph in yellow bullet
y=0
plot(xi_new,f(xi_new), '.yellow')
mprintf("nThe approximate time required toreduce the concentration to 15 is %fnn",xi_new)
//(SECANT METHOD)
//Allow user to input two initial guesses of the root (does not necessarily bracket the root)
x1= input("x1:")
x2= input("x2:")
//Graph of the function
x=[-2:0.5:6]
plot(x,f(x),'blue-')
a=gca()
a.x_location = "origin"
a.y_location = "origin"
mprintf("niteration tt x1 tt x2 tt f(x1) tt f(x2) tt xr tt f(xr) tt ea n"); //heading of the table
//Initialization, Stopping criterion, es (0.5% in this case)
i= 1
es= 0.5
ea= 100
//Loop for approximating the estimate root of the function
while(ea>es)
fx1 = f(x1)
fx2 = f(x2)
xr = x2 - ((fx2*(x2-x1))/(fx2-fx1))
fxr = f(xr)
ea = PARAError(xr,x2)
i=i+1
mprintf("n%dttt%ft%ft%ft%ft%ft%ft%f",i-1,x1,x2,fx1,fx2,xr, fxr, ea)
x1=x2
x2=xr
y=0
plot(xr,f(xr),'.red')
end
//Final estimate of the root plotted in the graph in yellow bullet
y=0
plot(xr,f(xr),'.yellow')
mprintf("nnThe approximate time required toreduce the concentration to 15 is %fnn",xr)
Es84
Es84

More Related Content

What's hot (20)

C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
Tercer Punto
Tercer PuntoTercer Punto
Tercer Punto
 
Cpl
CplCpl
Cpl
 
StackArray stack3
StackArray stack3StackArray stack3
StackArray stack3
 
Primer Punto
Primer PuntoPrimer Punto
Primer Punto
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest Descent
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
Quinto Punto Parte A
Quinto Punto Parte AQuinto Punto Parte A
Quinto Punto Parte A
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked List
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
LAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAMLAB PROGRAMS SARASWATHI RAMALINGAM
LAB PROGRAMS SARASWATHI RAMALINGAM
 
Runge kutta C programme
Runge kutta C programmeRunge kutta C programme
Runge kutta C programme
 
week-18x
week-18xweek-18x
week-18x
 
week-11x
week-11xweek-11x
week-11x
 
week-16x
week-16xweek-16x
week-16x
 
week-10x
week-10xweek-10x
week-10x
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Martha
MarthaMartha
Martha
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
 

Similar to Es84

Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in CAmbili Baby
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C CodeSyed Ahmed Zaki
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Tracy Lee
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานknang
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For GoogleEleanor McHugh
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab CompletoRicardo Grandas
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programsAmit Kapoor
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdfsrxerox
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyanAndreeKurtL
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docxhyacinthshackley2629
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltasjesquerrev1
 

Similar to Es84 (20)

Numerical Methods in C
Numerical Methods in CNumerical Methods in C
Numerical Methods in C
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
 
Sary
SarySary
Sary
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
C Language Lecture 17
C Language Lecture 17C Language Lecture 17
C Language Lecture 17
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018
 
C++ TUTORIAL 7
C++ TUTORIAL 7C++ TUTORIAL 7
C++ TUTORIAL 7
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Trabajo Scilab
Trabajo ScilabTrabajo Scilab
Trabajo Scilab
 
Taller De Scilab
Taller De ScilabTaller De Scilab
Taller De Scilab
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐาน
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
Ejercicios Scilab Completo
Ejercicios Scilab CompletoEjercicios Scilab Completo
Ejercicios Scilab Completo
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
 
S1 3 derivadas_resueltas
S1 3 derivadas_resueltasS1 3 derivadas_resueltas
S1 3 derivadas_resueltas
 

Recently uploaded

Karachi Escorts | +923070433345 | Escort Service in Karachi
Karachi Escorts | +923070433345 | Escort Service in KarachiKarachi Escorts | +923070433345 | Escort Service in Karachi
Karachi Escorts | +923070433345 | Escort Service in KarachiAyesha Khan
 
Kishangarh Call Girls : ☎ 8527673949, Low rate Call Girls
Kishangarh Call Girls : ☎ 8527673949, Low rate Call GirlsKishangarh Call Girls : ☎ 8527673949, Low rate Call Girls
Kishangarh Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad EscortsIslamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escortswdefrd
 
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi NcrSapana Sha
 
Turn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel JohnsonTurn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel Johnsonthephillipta
 
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?kexey39068
 
Faridabad Call Girls : ☎ 8527673949, Low rate Call Girls
Faridabad Call Girls : ☎ 8527673949, Low rate Call GirlsFaridabad Call Girls : ☎ 8527673949, Low rate Call Girls
Faridabad Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | DelhiFULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | DelhiMalviyaNagarCallGirl
 
Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...
Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...
Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...dajasot375
 
Alex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson StoryboardAlex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson Storyboardthephillipta
 
FULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | DelhiMalviyaNagarCallGirl
 
9654467111 Call Girls In Noida Sector 62 Short 1500 Night 6000
9654467111 Call Girls In Noida Sector 62 Short 1500 Night 60009654467111 Call Girls In Noida Sector 62 Short 1500 Night 6000
9654467111 Call Girls In Noida Sector 62 Short 1500 Night 6000Sapana Sha
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comthephillipta
 
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call GirlsJagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
Russian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts ServiceRussian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts Servicedoor45step
 
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl serviceDelhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl serviceashishs7044
 
Retail Store Scavanger Hunt - Foundation College Park
Retail Store Scavanger Hunt - Foundation College ParkRetail Store Scavanger Hunt - Foundation College Park
Retail Store Scavanger Hunt - Foundation College Parkjosebenzaquen
 
Greater Noida Call Girls : ☎ 8527673949, Low rate Call Girls
Greater Noida Call Girls : ☎ 8527673949, Low rate Call GirlsGreater Noida Call Girls : ☎ 8527673949, Low rate Call Girls
Greater Noida Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
FULL ENJOY - 9953040155 Call Girls in Noida | Delhi
FULL ENJOY - 9953040155 Call Girls in Noida | DelhiFULL ENJOY - 9953040155 Call Girls in Noida | Delhi
FULL ENJOY - 9953040155 Call Girls in Noida | DelhiMalviyaNagarCallGirl
 

Recently uploaded (20)

Karachi Escorts | +923070433345 | Escort Service in Karachi
Karachi Escorts | +923070433345 | Escort Service in KarachiKarachi Escorts | +923070433345 | Escort Service in Karachi
Karachi Escorts | +923070433345 | Escort Service in Karachi
 
Kishangarh Call Girls : ☎ 8527673949, Low rate Call Girls
Kishangarh Call Girls : ☎ 8527673949, Low rate Call GirlsKishangarh Call Girls : ☎ 8527673949, Low rate Call Girls
Kishangarh Call Girls : ☎ 8527673949, Low rate Call Girls
 
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad EscortsIslamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
Islamabad Call Girls # 03091665556 # Call Girls in Islamabad | Islamabad Escorts
 
Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)
Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)
Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)
 
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
9654467111 Full Enjoy @24/7 Call Girls In Saket Delhi Ncr
 
Turn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel JohnsonTurn Lock Take Key Storyboard Daniel Johnson
Turn Lock Take Key Storyboard Daniel Johnson
 
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
How Can You Get Dubai Call Girls +971564860409 Call Girls Dubai?
 
Faridabad Call Girls : ☎ 8527673949, Low rate Call Girls
Faridabad Call Girls : ☎ 8527673949, Low rate Call GirlsFaridabad Call Girls : ☎ 8527673949, Low rate Call Girls
Faridabad Call Girls : ☎ 8527673949, Low rate Call Girls
 
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | DelhiFULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
FULL ENJOY - 9953040155 Call Girls in Paschim Vihar | Delhi
 
Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...
Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...
Call Girl in Bur Dubai O5286O4116 Indian Call Girls in Bur Dubai By VIP Bur D...
 
Alex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson StoryboardAlex and Chloe by Daniel Johnson Storyboard
Alex and Chloe by Daniel Johnson Storyboard
 
FULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in New Ashok Nagar | Delhi
 
9654467111 Call Girls In Noida Sector 62 Short 1500 Night 6000
9654467111 Call Girls In Noida Sector 62 Short 1500 Night 60009654467111 Call Girls In Noida Sector 62 Short 1500 Night 6000
9654467111 Call Girls In Noida Sector 62 Short 1500 Night 6000
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
 
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call GirlsJagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
Jagat Puri Call Girls : ☎ 8527673949, Low rate Call Girls
 
Russian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts ServiceRussian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 104 Noida✨8375860717⚡Escorts Service
 
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl serviceDelhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
Delhi Room Call Girls : ☎ 8527673949, Low rate Call girl service
 
Retail Store Scavanger Hunt - Foundation College Park
Retail Store Scavanger Hunt - Foundation College ParkRetail Store Scavanger Hunt - Foundation College Park
Retail Store Scavanger Hunt - Foundation College Park
 
Greater Noida Call Girls : ☎ 8527673949, Low rate Call Girls
Greater Noida Call Girls : ☎ 8527673949, Low rate Call GirlsGreater Noida Call Girls : ☎ 8527673949, Low rate Call Girls
Greater Noida Call Girls : ☎ 8527673949, Low rate Call Girls
 
FULL ENJOY - 9953040155 Call Girls in Noida | Delhi
FULL ENJOY - 9953040155 Call Girls in Noida | DelhiFULL ENJOY - 9953040155 Call Girls in Noida | Delhi
FULL ENJOY - 9953040155 Call Girls in Noida | Delhi
 

Es84

  • 1. CHRISS T. EUGENIO ES 84- F89W56 clc //(NEWTON-RAPHSON METHOD) //Given afunction f(x), evaluate f'(x) symbolically. function y=f(x) y = 75*%e^(-1.5*x) + 20*%e^(-0.075*x) - 15 endfunction function y=g(x) y = -112.5*%e^(-1.5*x) - 1.5*%e^(-0.075*x) endfunction //Allow user to input an initial estimate of the root xi= input("initalestimate of the root:") //Graph of the given function x=[-2:0.5:6] plot(x,f(x),'blue-') a=gca() a.x_location = "origin" a.y_location = "origin" mprintf("niteration tt xi tt f(xi) tt f`(xi) tt ea n") //User-defined function for getting % absolute relative approximate error function [ea]=PARAError(x, y) ea=abs((y-x)/y)*100 endfunction //Initialization, Stopping criterion, es (0.5% in this case) i= 1 es= 0.5 ea= 100 mprintf("n%dttt%ft%ft%ft%fn",i-1,xi, f(xi),g(xi) , ea) y=0 plot(xi,f(xi), '.red') //Loop for approximating the estimate root of the function while(ea>es) xi_old = xi fxi= f(xi_old) gxi= g(xi_old) xi= xi_old - (fxi/gxi) xi_new = xi ea = PARAError(xi_old,xi_new) i=i+1 mprintf("n%dttt%ft%ft%ft%fn",i-1,xi,fxi, gxi , ea) y=0 plot(xi_new,f(xi_new), '.red') end //Final estimate of the root plotted in the graph in yellow bullet y=0 plot(xi_new,f(xi_new), '.yellow')
  • 2. mprintf("nThe approximate time required toreduce the concentration to 15 is %fnn",xi_new) //(SECANT METHOD) //Allow user to input two initial guesses of the root (does not necessarily bracket the root) x1= input("x1:") x2= input("x2:") //Graph of the function x=[-2:0.5:6] plot(x,f(x),'blue-') a=gca() a.x_location = "origin" a.y_location = "origin" mprintf("niteration tt x1 tt x2 tt f(x1) tt f(x2) tt xr tt f(xr) tt ea n"); //heading of the table //Initialization, Stopping criterion, es (0.5% in this case) i= 1 es= 0.5 ea= 100 //Loop for approximating the estimate root of the function while(ea>es) fx1 = f(x1) fx2 = f(x2) xr = x2 - ((fx2*(x2-x1))/(fx2-fx1)) fxr = f(xr) ea = PARAError(xr,x2) i=i+1 mprintf("n%dttt%ft%ft%ft%ft%ft%ft%f",i-1,x1,x2,fx1,fx2,xr, fxr, ea) x1=x2 x2=xr y=0 plot(xr,f(xr),'.red') end //Final estimate of the root plotted in the graph in yellow bullet y=0 plot(xr,f(xr),'.yellow') mprintf("nnThe approximate time required toreduce the concentration to 15 is %fnn",xr)