SlideShare a Scribd company logo
1 of 9
SCIENTIFIC COMPUTING
Programming language used - MATLAB
Saurabh S. Ramteke
Contents
Bisection Method.......................................................................................2
Newton Raphson Method..........................................................................3
Regula-Falsi................................................................................................4
Euler’s Explicit ..........................................................................................5
Euler’s Implicit ..........................................................................................6
Heun’s Method – R-K order 2..................................................................7
Range-Kutta order 4/Classical Method ...................................................8
Bisection Method
%% Bisection
clear all
clc
syms x
func = input("Input the Function in terms of x: ");
f = inline (func);
a = input("1st Guess: ");
b = input("2nd Guess: ");
tolX = 0.0001;
count = 0;
c = 0;
iterMax = 10;
for i=1:iterMax
c = (a + b)/2;
if(f(a)*f(c)<0)
b = c;
else
a = c;
end
count = count + 1;
if (abs(b - a) <= tolX)
break;
end
end
fprintf("Root = %f",(a+b)/2 )
Newton Raphson Method
%% Newton raphson
clear all
clc
%% Initilization
tolX = 0.0001;
temp = input("Enter initial approximation: ");
x = temp;
count = 0;
%% User defined Function
syms x % syms - symbol x and not a variable
func = input("Enter the fn as a variable of x: ");
% like exp(x) - 2(x)^3 - (x) - should be inside
paranthesis
f = inline(func);
df = diff(f(x));
fprime = inline(df);
%% Iterations
maxIter = 10;
for i = 1:maxIter
x0 = temp;
x = x0 - f(x)/fprime(x);
err = abs(x - x0);
if(err < tolX)
break;
end
count = count + 1;
end
Regula-Falsi
clear all
clc
syms x
func = input("Input the function: ");
f = inline(func);
iterMax = 10;
tolX = 0.0001;
a = input("1st Initial guess: ");
b = input("2nd Initial guess: ");
c = 0;
count = 0;
for i=1:iterMax
c = a - ((b-a))/(f(b)-f(a))*f(a);
if(f(a)*f(b)<0)
return;
end
count = count + 1;
if (abs(b-a) <= tolX)
break;
end
end
fprintf("The root value %f", c);
Euler’s Explicit
clear all
clc
%% Given
x0 = input("Lower Bound: ");
y0 = input("IV of y at x=0: ");
xn = input("Upper bound: ");
h = input("Input Step-size: ");
n= (xn-x0)/h;
%% Initialize solutions
x = [x0:h:xn]'; %transpose - column matrix (default -
row)
y = zeros(n+1,1); % m*n matrix of zeros - initializtion
% n+1 * 1 - n+1 rows, 1column
y(1)=y0; % Array indexing in matlab starts with 1
%% Euler's Explicit Method
for i=1:n
f = x(i)/y(i); % how to take user defined fn - learn
it.
y(i+1) = y(i) + h*f;
end
%% plot
plot(x,y);
%% Error
actualsoln = sqrt(x.^2 + 1.^2) % . - element by element
mulitply
err =abs(actualsoln - y);
Euler’s Implicit
clear all
clc
%% Given
x0 = input("Lower Bound: ");
y0 = input("IV of y at x=0: ");
xn = input("Upper bound: ");
h = input("Input Step-size: ");
n= (xn-x0)/h;
%% Initialize solutions
x = [x0:h:xn]'; %transpose - column matrix (default -
row)
Y = zeros(n+1,1); % m*n matrix of zeros - initializtion
% n+1 * 1 => n+1 rows, 1column
Y(1)=y0; % Array indexing in matlab starts with 1
%% Euler's Implicit Method
for i=1:n
T = x(i)+ h;
%anonynomous function - fsolve
% y - y(i) - h * f => f = x/y
y = fsolve(@(y) y - Y(i)-h*x/y, Y(i));
x(i+1) = T;
Y(i+1) = y;
end
%% plot
plot(x,y);
%% Error
actualsoln = sqrt(x.^2 + 1.^2) % . - element by element
mulitply
err =abs(actualsoln - y);
Heun’s Method – R-K order 2
clear all
clc
%% Given
x0 = input("Lower Bound: ");
y0 = input("IV of y at x=0: ");
xn = input("Upper bound: ");
h = input("Input Step-size: ");
n= (xn-x0)/h;
%% Initialize solutions
x = [x0:h:xn]'; %transpose - column matrix (default -
row)
y = zeros(n+1,1); % m*n matrix of zeros - initializtion
% n+1 * 1 => n+1 rows, 1column
y(1)=y0; % Array indexing in matlab starts with 1
%% Heun's Method/ Euler-Cauchy
for i=1:n
k1 = x(i)/y(i);
xNew = x(i) + h;
yNew = y(i) + h*k1;
k2 = xNew/yNew;
y(i+1) = y(i) + (1/2)*(k1 + k2);
end
%% plot
plot(x,y);
%% Error
actualsoln = sqrt(x.^2 + 1.^2) % . - element by element
mulitply
err =abs(actualsoln - y);
Range-Kutta order 4/Classical Method
clear all
clc
%% Given
x0 = input("Lower Bound: ");
y0 = input("IV of y at x=0: ");
xn = input("Upper bound: ");
h = input("Input Step-size: ");
n= (xn-x0)/h;
%% Initialize solutions
x = [x0:h:xn]'; %transpose - column matrix (default -
row)
y = zeros(n+1,1); % m*n matrix of zeros - initializtion
% n+1 * 1 => n+1 rows, 1column
y(1)=y0; % Array indexing in matlab starts with 1
%% Range-Kutta 4th order - Classical Method
for i=1:n
k1 = x(i)/y(i);
k2 = (x(i) + h/2)/(y(i) + k1/2);
k3 = (x(i) + h/2)/(y(i) + k2/2);
k4 = (x(i) + h)/(y(i) + k3);
y(i+1) = y(i) + (1/6)*(k1 + 2*k2 + 2*k3 + k4);
end
%% plot
plot(x,y);
%% Error
actualsoln = sqrt(x.^2 + 1.^2) % . - element by element
mulitply
err =abs(actualsoln - y);

More Related Content

Similar to scientific computing

Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlabsheetslibrary
 
Solution of non-linear equations
Solution of non-linear equationsSolution of non-linear equations
Solution of non-linear equationsZunAib Ali
 
Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlabZunAib Ali
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfaartechindia
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with cYagya Dev Bhardwaj
 
Newton raphson method
Newton raphson methodNewton raphson method
Newton raphson methodBijay Mishra
 
Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdfasenterprisestyagi
 
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfUse the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfacteleshoppe
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical MethodsTeja Ande
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Scienceresearchinventy
 
3D Math Primer: CocoaConf Atlanta
3D Math Primer: CocoaConf Atlanta3D Math Primer: CocoaConf Atlanta
3D Math Primer: CocoaConf AtlantaJanie Clayton
 
Fourier series example
Fourier series exampleFourier series example
Fourier series exampleAbi finni
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAAhmed Gamal Abdel Gawad
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxSALU18
 
3D Math Without Presenter Notes
3D Math Without Presenter Notes3D Math Without Presenter Notes
3D Math Without Presenter NotesJanie Clayton
 

Similar to scientific computing (20)

Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlab
 
Solution of non-linear equations
Solution of non-linear equationsSolution of non-linear equations
Solution of non-linear equations
 
Non linearequationsmatlab
Non linearequationsmatlabNon linearequationsmatlab
Non linearequationsmatlab
 
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfIncorporate the SOR method in the multigridTest-m and apply the multig.pdf
Incorporate the SOR method in the multigridTest-m and apply the multig.pdf
 
Numerical differentation with c
Numerical differentation with cNumerical differentation with c
Numerical differentation with c
 
Newton raphson method
Newton raphson methodNewton raphson method
Newton raphson method
 
Please use the same variables and only write the TODO part #!-usr-bi.pdf
Please use the same variables and only write the TODO part   #!-usr-bi.pdfPlease use the same variables and only write the TODO part   #!-usr-bi.pdf
Please use the same variables and only write the TODO part #!-usr-bi.pdf
 
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdfUse the same variable names and write the function F - Force(x-ks-kc-l.pdf
Use the same variable names and write the function F - Force(x-ks-kc-l.pdf
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
Research Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and ScienceResearch Inventy : International Journal of Engineering and Science
Research Inventy : International Journal of Engineering and Science
 
Error analysis
Error analysisError analysis
Error analysis
 
3D Math Primer: CocoaConf Atlanta
3D Math Primer: CocoaConf Atlanta3D Math Primer: CocoaConf Atlanta
3D Math Primer: CocoaConf Atlanta
 
Fourier series example
Fourier series exampleFourier series example
Fourier series example
 
PhysicsSIG2008-01-Seneviratne
PhysicsSIG2008-01-SeneviratnePhysicsSIG2008-01-Seneviratne
PhysicsSIG2008-01-Seneviratne
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
 
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docxerror 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
 
Dsp manual
Dsp manualDsp manual
Dsp manual
 
5.n nmodels i
5.n nmodels i5.n nmodels i
5.n nmodels i
 
3D Math Without Presenter Notes
3D Math Without Presenter Notes3D Math Without Presenter Notes
3D Math Without Presenter Notes
 
Numerical methods presentation 11 iteration method
Numerical methods presentation 11 iteration methodNumerical methods presentation 11 iteration method
Numerical methods presentation 11 iteration method
 

More from saurabhramteke7

Design of experiments and stochastic process
Design of experiments and stochastic processDesign of experiments and stochastic process
Design of experiments and stochastic processsaurabhramteke7
 
Computer oriented optimization
Computer oriented optimizationComputer oriented optimization
Computer oriented optimizationsaurabhramteke7
 
UPSC Mnemonic for quick revision
UPSC Mnemonic for quick revisionUPSC Mnemonic for quick revision
UPSC Mnemonic for quick revisionsaurabhramteke7
 

More from saurabhramteke7 (6)

Design of experiments and stochastic process
Design of experiments and stochastic processDesign of experiments and stochastic process
Design of experiments and stochastic process
 
Linear regressions
Linear regressionsLinear regressions
Linear regressions
 
curve fitting
curve fittingcurve fitting
curve fitting
 
Computer oriented optimization
Computer oriented optimizationComputer oriented optimization
Computer oriented optimization
 
Scientific Computing
Scientific ComputingScientific Computing
Scientific Computing
 
UPSC Mnemonic for quick revision
UPSC Mnemonic for quick revisionUPSC Mnemonic for quick revision
UPSC Mnemonic for quick revision
 

Recently uploaded

Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service LucknowAminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknowmakika9823
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...Pooja Nehwal
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Digi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxDigi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxTanveerAhmed817946
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 

Recently uploaded (20)

Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service LucknowAminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
Aminabad Call Girl Agent 9548273370 , Call Girls Service Lucknow
 
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...{Pooja:  9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
{Pooja: 9892124323 } Call Girl in Mumbai | Jas Kaur Rate 4500 Free Hotel Del...
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Digi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptxDigi Khata Problem along complete plan.pptx
Digi Khata Problem along complete plan.pptx
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 

scientific computing

  • 1. SCIENTIFIC COMPUTING Programming language used - MATLAB Saurabh S. Ramteke
  • 2. Contents Bisection Method.......................................................................................2 Newton Raphson Method..........................................................................3 Regula-Falsi................................................................................................4 Euler’s Explicit ..........................................................................................5 Euler’s Implicit ..........................................................................................6 Heun’s Method – R-K order 2..................................................................7 Range-Kutta order 4/Classical Method ...................................................8
  • 3. Bisection Method %% Bisection clear all clc syms x func = input("Input the Function in terms of x: "); f = inline (func); a = input("1st Guess: "); b = input("2nd Guess: "); tolX = 0.0001; count = 0; c = 0; iterMax = 10; for i=1:iterMax c = (a + b)/2; if(f(a)*f(c)<0) b = c; else a = c; end count = count + 1; if (abs(b - a) <= tolX) break; end end fprintf("Root = %f",(a+b)/2 )
  • 4. Newton Raphson Method %% Newton raphson clear all clc %% Initilization tolX = 0.0001; temp = input("Enter initial approximation: "); x = temp; count = 0; %% User defined Function syms x % syms - symbol x and not a variable func = input("Enter the fn as a variable of x: "); % like exp(x) - 2(x)^3 - (x) - should be inside paranthesis f = inline(func); df = diff(f(x)); fprime = inline(df); %% Iterations maxIter = 10; for i = 1:maxIter x0 = temp; x = x0 - f(x)/fprime(x); err = abs(x - x0); if(err < tolX) break; end count = count + 1; end
  • 5. Regula-Falsi clear all clc syms x func = input("Input the function: "); f = inline(func); iterMax = 10; tolX = 0.0001; a = input("1st Initial guess: "); b = input("2nd Initial guess: "); c = 0; count = 0; for i=1:iterMax c = a - ((b-a))/(f(b)-f(a))*f(a); if(f(a)*f(b)<0) return; end count = count + 1; if (abs(b-a) <= tolX) break; end end fprintf("The root value %f", c);
  • 6. Euler’s Explicit clear all clc %% Given x0 = input("Lower Bound: "); y0 = input("IV of y at x=0: "); xn = input("Upper bound: "); h = input("Input Step-size: "); n= (xn-x0)/h; %% Initialize solutions x = [x0:h:xn]'; %transpose - column matrix (default - row) y = zeros(n+1,1); % m*n matrix of zeros - initializtion % n+1 * 1 - n+1 rows, 1column y(1)=y0; % Array indexing in matlab starts with 1 %% Euler's Explicit Method for i=1:n f = x(i)/y(i); % how to take user defined fn - learn it. y(i+1) = y(i) + h*f; end %% plot plot(x,y); %% Error actualsoln = sqrt(x.^2 + 1.^2) % . - element by element mulitply err =abs(actualsoln - y);
  • 7. Euler’s Implicit clear all clc %% Given x0 = input("Lower Bound: "); y0 = input("IV of y at x=0: "); xn = input("Upper bound: "); h = input("Input Step-size: "); n= (xn-x0)/h; %% Initialize solutions x = [x0:h:xn]'; %transpose - column matrix (default - row) Y = zeros(n+1,1); % m*n matrix of zeros - initializtion % n+1 * 1 => n+1 rows, 1column Y(1)=y0; % Array indexing in matlab starts with 1 %% Euler's Implicit Method for i=1:n T = x(i)+ h; %anonynomous function - fsolve % y - y(i) - h * f => f = x/y y = fsolve(@(y) y - Y(i)-h*x/y, Y(i)); x(i+1) = T; Y(i+1) = y; end %% plot plot(x,y); %% Error actualsoln = sqrt(x.^2 + 1.^2) % . - element by element mulitply err =abs(actualsoln - y);
  • 8. Heun’s Method – R-K order 2 clear all clc %% Given x0 = input("Lower Bound: "); y0 = input("IV of y at x=0: "); xn = input("Upper bound: "); h = input("Input Step-size: "); n= (xn-x0)/h; %% Initialize solutions x = [x0:h:xn]'; %transpose - column matrix (default - row) y = zeros(n+1,1); % m*n matrix of zeros - initializtion % n+1 * 1 => n+1 rows, 1column y(1)=y0; % Array indexing in matlab starts with 1 %% Heun's Method/ Euler-Cauchy for i=1:n k1 = x(i)/y(i); xNew = x(i) + h; yNew = y(i) + h*k1; k2 = xNew/yNew; y(i+1) = y(i) + (1/2)*(k1 + k2); end %% plot plot(x,y); %% Error actualsoln = sqrt(x.^2 + 1.^2) % . - element by element mulitply err =abs(actualsoln - y);
  • 9. Range-Kutta order 4/Classical Method clear all clc %% Given x0 = input("Lower Bound: "); y0 = input("IV of y at x=0: "); xn = input("Upper bound: "); h = input("Input Step-size: "); n= (xn-x0)/h; %% Initialize solutions x = [x0:h:xn]'; %transpose - column matrix (default - row) y = zeros(n+1,1); % m*n matrix of zeros - initializtion % n+1 * 1 => n+1 rows, 1column y(1)=y0; % Array indexing in matlab starts with 1 %% Range-Kutta 4th order - Classical Method for i=1:n k1 = x(i)/y(i); k2 = (x(i) + h/2)/(y(i) + k1/2); k3 = (x(i) + h/2)/(y(i) + k2/2); k4 = (x(i) + h)/(y(i) + k3); y(i+1) = y(i) + (1/6)*(k1 + 2*k2 + 2*k3 + k4); end %% plot plot(x,y); %% Error actualsoln = sqrt(x.^2 + 1.^2) % . - element by element mulitply err =abs(actualsoln - y);