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

TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...
TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...
TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...door45step
 
Al Barsha Housewife Call Girls +971509530047 Al Barsha Call Girls
Al Barsha Housewife Call Girls +971509530047 Al Barsha Call GirlsAl Barsha Housewife Call Girls +971509530047 Al Barsha Call Girls
Al Barsha Housewife Call Girls +971509530047 Al Barsha Call Girlshayawit234
 
UNIT 5-6 anh văn chuyên nganhhhhhhh.docx
UNIT 5-6 anh văn chuyên nganhhhhhhh.docxUNIT 5-6 anh văn chuyên nganhhhhhhh.docx
UNIT 5-6 anh văn chuyên nganhhhhhhh.docxssuser519b4b
 
Escort Service in Al Rigga +971509530047 UAE
Escort Service in Al Rigga +971509530047 UAEEscort Service in Al Rigga +971509530047 UAE
Escort Service in Al Rigga +971509530047 UAEvecevep119
 
8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available
8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available
8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Availabledollysharma2066
 
Karol Bagh Call Girls : ☎ 8527673949, Low rate Call Girls
Karol Bagh Call Girls : ☎ 8527673949, Low rate Call GirlsKarol Bagh Call Girls : ☎ 8527673949, Low rate Call Girls
Karol Bagh Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
New_Cross_Over (Comedy storyboard sample)
New_Cross_Over (Comedy storyboard sample)New_Cross_Over (Comedy storyboard sample)
New_Cross_Over (Comedy storyboard sample)DavonBrooks
 
Benjamin Portfolio Process Work Slideshow
Benjamin Portfolio Process Work SlideshowBenjamin Portfolio Process Work Slideshow
Benjamin Portfolio Process Work Slideshowssuser971f6c
 
Russian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts ServiceRussian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts Servicedoor45step
 
Escort Service in Al Barsha +971509530047 UAE
Escort Service in Al Barsha +971509530047 UAEEscort Service in Al Barsha +971509530047 UAE
Escort Service in Al Barsha +971509530047 UAEvecevep119
 
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
 
Escort Service in Al Nahda +971509530047 UAE
Escort Service in Al Nahda +971509530047 UAEEscort Service in Al Nahda +971509530047 UAE
Escort Service in Al Nahda +971509530047 UAEvecevep119
 
Russian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts ServiceRussian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts Servicedoor45step
 
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
 
Strip Zagor Extra 322 - Dva ortaka.pdf
Strip   Zagor Extra 322 - Dva ortaka.pdfStrip   Zagor Extra 322 - Dva ortaka.pdf
Strip Zagor Extra 322 - Dva ortaka.pdfStripovizijacom
 
Value Aspiration And Culture Theory of Architecture
Value Aspiration And Culture Theory of ArchitectureValue Aspiration And Culture Theory of Architecture
Value Aspiration And Culture Theory of ArchitectureDarrenMasbate
 
Kashmiri Gate Call Girls : ☎ 8527673949, Low rate Call Girls
Kashmiri Gate Call Girls : ☎ 8527673949, Low rate Call GirlsKashmiri Gate Call Girls : ☎ 8527673949, Low rate Call Girls
Kashmiri Gate Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
Kristy Soto's Industrial design Portfolio
Kristy Soto's Industrial design PortfolioKristy Soto's Industrial design Portfolio
Kristy Soto's Industrial design PortfolioKristySoto
 
Hauz Khas Call Girls : ☎ 8527673949, Low rate Call Girls
Hauz Khas Call Girls : ☎ 8527673949, Low rate Call GirlsHauz Khas Call Girls : ☎ 8527673949, Low rate Call Girls
Hauz Khas Call Girls : ☎ 8527673949, Low rate Call Girlsashishs7044
 
How to order fake Lakeland University diploma?
How to order fake Lakeland University diploma?How to order fake Lakeland University diploma?
How to order fake Lakeland University diploma?melodolykelton
 

Recently uploaded (20)

TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...
TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...
TOP BEST Call Girls In SECTOR 62 (Noida) ꧁❤ 8375860717 ❤꧂ Female Escorts Serv...
 
Al Barsha Housewife Call Girls +971509530047 Al Barsha Call Girls
Al Barsha Housewife Call Girls +971509530047 Al Barsha Call GirlsAl Barsha Housewife Call Girls +971509530047 Al Barsha Call Girls
Al Barsha Housewife Call Girls +971509530047 Al Barsha Call Girls
 
UNIT 5-6 anh văn chuyên nganhhhhhhh.docx
UNIT 5-6 anh văn chuyên nganhhhhhhh.docxUNIT 5-6 anh văn chuyên nganhhhhhhh.docx
UNIT 5-6 anh văn chuyên nganhhhhhhh.docx
 
Escort Service in Al Rigga +971509530047 UAE
Escort Service in Al Rigga +971509530047 UAEEscort Service in Al Rigga +971509530047 UAE
Escort Service in Al Rigga +971509530047 UAE
 
8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available
8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available
8377087607, Door Step Call Girls In Gaur City (NOIDA) 24/7 Available
 
Karol Bagh Call Girls : ☎ 8527673949, Low rate Call Girls
Karol Bagh Call Girls : ☎ 8527673949, Low rate Call GirlsKarol Bagh Call Girls : ☎ 8527673949, Low rate Call Girls
Karol Bagh Call Girls : ☎ 8527673949, Low rate Call Girls
 
New_Cross_Over (Comedy storyboard sample)
New_Cross_Over (Comedy storyboard sample)New_Cross_Over (Comedy storyboard sample)
New_Cross_Over (Comedy storyboard sample)
 
Benjamin Portfolio Process Work Slideshow
Benjamin Portfolio Process Work SlideshowBenjamin Portfolio Process Work Slideshow
Benjamin Portfolio Process Work Slideshow
 
Russian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts ServiceRussian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 40 Noida✨8375860717⚡Escorts Service
 
Escort Service in Al Barsha +971509530047 UAE
Escort Service in Al Barsha +971509530047 UAEEscort Service in Al Barsha +971509530047 UAE
Escort Service in Al Barsha +971509530047 UAE
 
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
 
Escort Service in Al Nahda +971509530047 UAE
Escort Service in Al Nahda +971509530047 UAEEscort Service in Al Nahda +971509530047 UAE
Escort Service in Al Nahda +971509530047 UAE
 
Russian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts ServiceRussian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts Service
Russian⚡ Call Girls In Sector 39 Noida✨8375860717⚡Escorts 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
 
Strip Zagor Extra 322 - Dva ortaka.pdf
Strip   Zagor Extra 322 - Dva ortaka.pdfStrip   Zagor Extra 322 - Dva ortaka.pdf
Strip Zagor Extra 322 - Dva ortaka.pdf
 
Value Aspiration And Culture Theory of Architecture
Value Aspiration And Culture Theory of ArchitectureValue Aspiration And Culture Theory of Architecture
Value Aspiration And Culture Theory of Architecture
 
Kashmiri Gate Call Girls : ☎ 8527673949, Low rate Call Girls
Kashmiri Gate Call Girls : ☎ 8527673949, Low rate Call GirlsKashmiri Gate Call Girls : ☎ 8527673949, Low rate Call Girls
Kashmiri Gate Call Girls : ☎ 8527673949, Low rate Call Girls
 
Kristy Soto's Industrial design Portfolio
Kristy Soto's Industrial design PortfolioKristy Soto's Industrial design Portfolio
Kristy Soto's Industrial design Portfolio
 
Hauz Khas Call Girls : ☎ 8527673949, Low rate Call Girls
Hauz Khas Call Girls : ☎ 8527673949, Low rate Call GirlsHauz Khas Call Girls : ☎ 8527673949, Low rate Call Girls
Hauz Khas Call Girls : ☎ 8527673949, Low rate Call Girls
 
How to order fake Lakeland University diploma?
How to order fake Lakeland University diploma?How to order fake Lakeland University diploma?
How to order fake Lakeland University diploma?
 

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)