SlideShare a Scribd company logo
1 of 9
Download to read offline
This problem illustrates one of the possible pitfalls of blindly applying numerical methods
without paying attention to the theoretical aspects of the differential equation itself. Consider the
equation ty' + 3y - 9t^2 = 0. Use the MATLAB program myeuler.m from Chapter 8 to compute
the Euler Method approximation to the solution with initial condition y(-0.5) = 3.15, using step
size h = 0.2 and n = 10 steps The program will generate a lot of ordered pairs (x_i, .y_i). Use plot
to graph the piecewise linear function connecting the points (x_i, y_i). Now modify the program
to implement the Improved Euler Method. Can you make sense of your answers? Next, use
ode45 to find an approximate solution on the interval (-0.5, 0.5), and plot it with plot. Print out
the values of the solution at the points -0.06: 0.02: 0.06. What is the interval on which the
approximate solution is defined? Solve the equation explicitly and graph the solutions for the
initial conditions y(0) = 0, y(-0.5) = 3.15, y(0, 5) = 3.15, y(-0.5) = -3.45, and y(0.5) = -3.45. Now
explain your results in (a)-(c). Could we have known, without solving the equation, whether to
expect meaningful results in parts (a) and (b)? Why? Can you explain how ode45 avoids making
the same mistake?
Solution
clc
clear all
close all
x=input('Enter the first sequence: ');
l1=input('Enter the lower limit: ');
u1=input('Enter the upper limit: ');
x1=l1:1:u1;
h=input('Enter the second sequence: ');
l2=input('Enter the lower limit: ');
u2=input('Enter the upper limit: ');
h1=l2:1:u2;
l=l1+l2;
u=u1+u2;
n=l:1:u;
s=numel(n);
i=1;
for i=1:s
y(i)=0;
for k=1:numel(x)
if (i+1-k)<=0
y(i)=y(i)+(x(k)*0);
else if (i+1-k)>numel(h)
y(i)=y(i)+(x(k)*0);
else
y(i)=y(i)+(x(k)*h(i+1-k));
k=k+1;
end
end
end
i=i+1;
end
disp(y);
subplot(2,2,1);stem(x1,x);
title('First sequence');xlabel('n');ylabel('x(n)');
subplot(2,2,2);stem(h1,h);
title('Second Sequence');xlabel('n');ylabel('h(n)');
subplot(2,2,[3 4]);stem(n,y);
title('Convoluted sequence');xlabel('n');ylabel('y(n)');
Comment only
X = input('Enter x: '); %input vector X and H
H = input('Enter h: ') ;
LenX = length(X); %defining their lenghts
LenH = length(H);
y = zeros(1,LenX+LenH); %defing vector y of zeroes and of size
% lenth of X + length of H
t = zeros(1,LenH); % definign a vector t of same length as H
for i = 1:LenH+LenX-1 % Running a for loop from 1 to length of Y -1
if i<=LenX % till I IS Lesser then length of X i.e overlap about to begin
t(1)= X(i); % put x(i) on t(1) later it is shifted forwards in the vector t i.e. later t(2)=t(1)
for j = 1:LenH % in the if condition a for loop from 1 to length of H
y(i) = y(i) + H(j)*t(j); % summing for all H(j)*t(j) and putting it at y(1) or y(2) or Y(i) in first
iteration
% i.e. for i=1 only firt multiplication would
% be non zero rest all zeroes.
end
for k = LenH:-1:2 % shifting old value of t(i) to t(i+1) now there would me 1+ non zeroes values
in t
% this cycle would continue until i is lesser then
% length X i.e. overlap increasing every iteration less
% and less non zero vales in t every iteration
t(k) = t(k-1);
end
else % now when all of the T is non zero which means 100% overlap in else overlap would start
to decrease between T and H
% T is basically X
t(1)= 0;
for j = 1:LenH % Now we start filling up Zeroes in T i.e. overlap began to decrease now and
each iteration it would decrease
% i.e T moving to left until there is no more
% over lap
y(i) = y(i) + (H(j)*t(j)); % in this for loop we multiply all respective vales of h and t and add the
% putting it at y(1) or y(2) or Y(i) in first iteration
end
for k = LenH:-1:2 %% here just like similar loop above t where we were filling up t with vales of
x
%now we are filling up zeroos in t i.e. over lap decreasing
t(k) = t(k-1);
end
end
end
ly=length(y)
indices=[ly]
for i=1:ly
indices(i)=i;
end
disp (y); %displays vector y.
disp (indices); % displays vector indices.
stem(y);
ylabel('Y[n]');
xlabel('[n]');
title('Convolution without conv function');
Comment only
x = input('Enter x: ');
h = input('Enter h: ') ;
Ni = length(x);
Nh = length(h);
y = zeros(1,Ni+Nh);
t = zeros(1,Nh);
for i = 1:Ni+Nh-1
if i<=Ni
t(1)= x(i);
for j = 1:Nh
y(i) = y(i) + h(j)*t(j);
end
for k = Nh:-1:2
t(k) = t(k-1);
end
else
t(1)= 0;
for j = 1:Nh
y(i) = y(i) + (h(j)*t(j));
end
for k = Nh:-1:2
t(k) = t(k-1);
end
end
end
stem(y);
Comment only
function [y] = myconv( x,h )
m=length(x);
n=length(h);
x=[x,zeros(1,n)];
h=[h,zeros(1,m)];
for i=1:n+m-1
y(i)=0;
for j=1:m
if(i-j+1>0)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end
clc
clear all
close all
x=input('Enter the first sequence: ');
l1=input('Enter the lower limit: ');
u1=input('Enter the upper limit: ');
x1=l1:1:u1;
h=input('Enter the second sequence: ');
l2=input('Enter the lower limit: ');
u2=input('Enter the upper limit: ');
h1=l2:1:u2;
l=l1+l2;
u=u1+u2;
n=l:1:u;
s=numel(n);
i=1;
for i=1:s
y(i)=0;
for k=1:numel(x)
if (i+1-k)<=0
y(i)=y(i)+(x(k)*0);
else if (i+1-k)>numel(h)
y(i)=y(i)+(x(k)*0);
else
y(i)=y(i)+(x(k)*h(i+1-k));
k=k+1;
end
end
end
i=i+1;
end
disp(y);
subplot(2,2,1);stem(x1,x);
title('First sequence');xlabel('n');ylabel('x(n)');
subplot(2,2,2);stem(h1,h);
title('Second Sequence');xlabel('n');ylabel('h(n)');
subplot(2,2,[3 4]);stem(n,y);
title('Convoluted sequence');xlabel('n');ylabel('y(n)');
Comment only28 Jan 2014assad
X = input('Enter x: '); %input vector X and H
H = input('Enter h: ') ;
LenX = length(X); %defining their lenghts
LenH = length(H);
y = zeros(1,LenX+LenH); %defing vector y of zeroes and of size
% lenth of X + length of H
t = zeros(1,LenH); % definign a vector t of same length as H
for i = 1:LenH+LenX-1 % Running a for loop from 1 to length of Y -1
if i<=LenX % till I IS Lesser then length of X i.e overlap about to begin
t(1)= X(i); % put x(i) on t(1) later it is shifted forwards in the vector t i.e. later t(2)=t(1)
for j = 1:LenH % in the if condition a for loop from 1 to length of H
y(i) = y(i) + H(j)*t(j); % summing for all H(j)*t(j) and putting it at y(1) or y(2) or Y(i) in first
iteration
% i.e. for i=1 only firt multiplication would
% be non zero rest all zeroes.
end
for k = LenH:-1:2 % shifting old value of t(i) to t(i+1) now there would me 1+ non zeroes values
in t
% this cycle would continue until i is lesser then
% length X i.e. overlap increasing every iteration less
% and less non zero vales in t every iteration
t(k) = t(k-1);
end
else % now when all of the T is non zero which means 100% overlap in else overlap would start
to decrease between T and H
% T is basically X
t(1)= 0;
for j = 1:LenH % Now we start filling up Zeroes in T i.e. overlap began to decrease now and
each iteration it would decrease
% i.e T moving to left until there is no more
% over lap
y(i) = y(i) + (H(j)*t(j)); % in this for loop we multiply all respective vales of h and t and add
the
% putting it at y(1) or y(2) or Y(i) in first iteration
end
for k = LenH:-1:2 %% here just like similar loop above t where we were filling up t with vales
of x
%now we are filling up zeroos in t i.e. over lap decreasing
t(k) = t(k-1);
end
end
end
ly=length(y)
indices=[ly]
for i=1:ly
indices(i)=i;
end
disp (y); %displays vector y.
disp (indices); % displays vector indices.
stem(y);
ylabel('Y[n]');
xlabel('[n]');
title('Convolution without conv function');
Comment only23 Sep 2013Aghil Vinayak
x = input('Enter x: ');
h = input('Enter h: ') ;
Ni = length(x);
Nh = length(h);
y = zeros(1,Ni+Nh);
t = zeros(1,Nh);
for i = 1:Ni+Nh-1
if i<=Ni
t(1)= x(i);
for j = 1:Nh
y(i) = y(i) + h(j)*t(j);
end
for k = Nh:-1:2
t(k) = t(k-1);
end
else
t(1)= 0;
for j = 1:Nh
y(i) = y(i) + (h(j)*t(j));
end
for k = Nh:-1:2
t(k) = t(k-1);
end
end
end
stem(y);
Comment only30 Mar 2013sonali21 Feb 2013Rama Krishna Tata17 Feb 2013Abdul-Rauf
Mujahid
function [y] = myconv( x,h )
m=length(x);
n=length(h);
x=[x,zeros(1,n)];
h=[h,zeros(1,m)];
for i=1:n+m-1
y(i)=0;
for j=1:m
if(i-j+1>0)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end

More Related Content

Similar to This problem illustrates one of the possible pitfalls of blindly appl.pdf

MATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docx
MATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docxMATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docx
MATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docx
andreecapon
 
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
acteleshoppe
 

Similar to This problem illustrates one of the possible pitfalls of blindly appl.pdf (20)

MATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docx
MATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docxMATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docx
MATH 200-004 Multivariate Calculus Winter 2014Chapter 12.docx
 
A Proof of the Generalized Riemann Hypothesis
A Proof of the Generalized Riemann HypothesisA Proof of the Generalized Riemann Hypothesis
A Proof of the Generalized Riemann Hypothesis
 
A Proof of the Generalized Riemann Hypothesis
A Proof of the Generalized Riemann HypothesisA Proof of the Generalized Riemann Hypothesis
A Proof of the Generalized Riemann Hypothesis
 
Ma2002 1.14 rm
Ma2002 1.14 rmMa2002 1.14 rm
Ma2002 1.14 rm
 
linear transformation and rank nullity theorem
linear transformation and rank nullity theorem linear transformation and rank nullity theorem
linear transformation and rank nullity theorem
 
Mit18 330 s12_chapter5
Mit18 330 s12_chapter5Mit18 330 s12_chapter5
Mit18 330 s12_chapter5
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Lecture5
Lecture5Lecture5
Lecture5
 
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALESNONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
NONLINEAR DIFFERENCE EQUATIONS WITH SMALL PARAMETERS OF MULTIPLE SCALES
 
Ma2002 1.6 rm
Ma2002 1.6 rmMa2002 1.6 rm
Ma2002 1.6 rm
 
Trapezoidal Method IN Numerical Analysis
Trapezoidal Method IN  Numerical AnalysisTrapezoidal Method IN  Numerical Analysis
Trapezoidal Method IN Numerical Analysis
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
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
 
Limits of some transcendental functions
Limits of some transcendental functionsLimits of some transcendental functions
Limits of some transcendental functions
 
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdfTwo Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdf
 
Matlab assignment
Matlab assignmentMatlab assignment
Matlab assignment
 
stochastic processes assignment help
stochastic processes assignment helpstochastic processes assignment help
stochastic processes assignment help
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search Techniques
 
summary.pdf
summary.pdfsummary.pdf
summary.pdf
 
Matlab programs
Matlab programsMatlab programs
Matlab programs
 

More from arihantmum

I need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfI need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdf
arihantmum
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdf
arihantmum
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
arihantmum
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdf
arihantmum
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdf
arihantmum
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdf
arihantmum
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
arihantmum
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdf
arihantmum
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
arihantmum
 

More from arihantmum (20)

In 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfIn 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdf
 
In a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfIn a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdf
 
I need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfI need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdf
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfHeading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
 
Explain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfExplain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdf
 
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfExplain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdf
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
 
Describe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfDescribe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdf
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdf
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdf
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdf
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
 
Amon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfAmon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdf
 
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfA box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdf
 
A bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfA bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdf
 
Xavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfXavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdf
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
 

Recently uploaded

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 

This problem illustrates one of the possible pitfalls of blindly appl.pdf

  • 1. This problem illustrates one of the possible pitfalls of blindly applying numerical methods without paying attention to the theoretical aspects of the differential equation itself. Consider the equation ty' + 3y - 9t^2 = 0. Use the MATLAB program myeuler.m from Chapter 8 to compute the Euler Method approximation to the solution with initial condition y(-0.5) = 3.15, using step size h = 0.2 and n = 10 steps The program will generate a lot of ordered pairs (x_i, .y_i). Use plot to graph the piecewise linear function connecting the points (x_i, y_i). Now modify the program to implement the Improved Euler Method. Can you make sense of your answers? Next, use ode45 to find an approximate solution on the interval (-0.5, 0.5), and plot it with plot. Print out the values of the solution at the points -0.06: 0.02: 0.06. What is the interval on which the approximate solution is defined? Solve the equation explicitly and graph the solutions for the initial conditions y(0) = 0, y(-0.5) = 3.15, y(0, 5) = 3.15, y(-0.5) = -3.45, and y(0.5) = -3.45. Now explain your results in (a)-(c). Could we have known, without solving the equation, whether to expect meaningful results in parts (a) and (b)? Why? Can you explain how ode45 avoids making the same mistake? Solution clc clear all close all x=input('Enter the first sequence: '); l1=input('Enter the lower limit: '); u1=input('Enter the upper limit: '); x1=l1:1:u1; h=input('Enter the second sequence: '); l2=input('Enter the lower limit: '); u2=input('Enter the upper limit: '); h1=l2:1:u2; l=l1+l2; u=u1+u2; n=l:1:u; s=numel(n); i=1; for i=1:s y(i)=0; for k=1:numel(x)
  • 2. if (i+1-k)<=0 y(i)=y(i)+(x(k)*0); else if (i+1-k)>numel(h) y(i)=y(i)+(x(k)*0); else y(i)=y(i)+(x(k)*h(i+1-k)); k=k+1; end end end i=i+1; end disp(y); subplot(2,2,1);stem(x1,x); title('First sequence');xlabel('n');ylabel('x(n)'); subplot(2,2,2);stem(h1,h); title('Second Sequence');xlabel('n');ylabel('h(n)'); subplot(2,2,[3 4]);stem(n,y); title('Convoluted sequence');xlabel('n');ylabel('y(n)'); Comment only X = input('Enter x: '); %input vector X and H H = input('Enter h: ') ; LenX = length(X); %defining their lenghts LenH = length(H); y = zeros(1,LenX+LenH); %defing vector y of zeroes and of size % lenth of X + length of H t = zeros(1,LenH); % definign a vector t of same length as H for i = 1:LenH+LenX-1 % Running a for loop from 1 to length of Y -1 if i<=LenX % till I IS Lesser then length of X i.e overlap about to begin t(1)= X(i); % put x(i) on t(1) later it is shifted forwards in the vector t i.e. later t(2)=t(1) for j = 1:LenH % in the if condition a for loop from 1 to length of H y(i) = y(i) + H(j)*t(j); % summing for all H(j)*t(j) and putting it at y(1) or y(2) or Y(i) in first iteration % i.e. for i=1 only firt multiplication would % be non zero rest all zeroes. end
  • 3. for k = LenH:-1:2 % shifting old value of t(i) to t(i+1) now there would me 1+ non zeroes values in t % this cycle would continue until i is lesser then % length X i.e. overlap increasing every iteration less % and less non zero vales in t every iteration t(k) = t(k-1); end else % now when all of the T is non zero which means 100% overlap in else overlap would start to decrease between T and H % T is basically X t(1)= 0; for j = 1:LenH % Now we start filling up Zeroes in T i.e. overlap began to decrease now and each iteration it would decrease % i.e T moving to left until there is no more % over lap y(i) = y(i) + (H(j)*t(j)); % in this for loop we multiply all respective vales of h and t and add the % putting it at y(1) or y(2) or Y(i) in first iteration end for k = LenH:-1:2 %% here just like similar loop above t where we were filling up t with vales of x %now we are filling up zeroos in t i.e. over lap decreasing t(k) = t(k-1); end end end ly=length(y) indices=[ly] for i=1:ly indices(i)=i; end disp (y); %displays vector y. disp (indices); % displays vector indices. stem(y); ylabel('Y[n]'); xlabel('[n]'); title('Convolution without conv function');
  • 4. Comment only x = input('Enter x: '); h = input('Enter h: ') ; Ni = length(x); Nh = length(h); y = zeros(1,Ni+Nh); t = zeros(1,Nh); for i = 1:Ni+Nh-1 if i<=Ni t(1)= x(i); for j = 1:Nh y(i) = y(i) + h(j)*t(j); end for k = Nh:-1:2 t(k) = t(k-1); end else t(1)= 0; for j = 1:Nh y(i) = y(i) + (h(j)*t(j)); end for k = Nh:-1:2 t(k) = t(k-1); end end end stem(y); Comment only function [y] = myconv( x,h ) m=length(x); n=length(h);
  • 5. x=[x,zeros(1,n)]; h=[h,zeros(1,m)]; for i=1:n+m-1 y(i)=0; for j=1:m if(i-j+1>0) y(i)=y(i)+x(j)*h(i-j+1); end end end clc clear all close all x=input('Enter the first sequence: '); l1=input('Enter the lower limit: '); u1=input('Enter the upper limit: '); x1=l1:1:u1; h=input('Enter the second sequence: '); l2=input('Enter the lower limit: '); u2=input('Enter the upper limit: '); h1=l2:1:u2; l=l1+l2; u=u1+u2; n=l:1:u; s=numel(n); i=1; for i=1:s y(i)=0; for k=1:numel(x) if (i+1-k)<=0 y(i)=y(i)+(x(k)*0); else if (i+1-k)>numel(h) y(i)=y(i)+(x(k)*0); else y(i)=y(i)+(x(k)*h(i+1-k)); k=k+1;
  • 6. end end end i=i+1; end disp(y); subplot(2,2,1);stem(x1,x); title('First sequence');xlabel('n');ylabel('x(n)'); subplot(2,2,2);stem(h1,h); title('Second Sequence');xlabel('n');ylabel('h(n)'); subplot(2,2,[3 4]);stem(n,y); title('Convoluted sequence');xlabel('n');ylabel('y(n)'); Comment only28 Jan 2014assad X = input('Enter x: '); %input vector X and H H = input('Enter h: ') ; LenX = length(X); %defining their lenghts LenH = length(H); y = zeros(1,LenX+LenH); %defing vector y of zeroes and of size % lenth of X + length of H t = zeros(1,LenH); % definign a vector t of same length as H for i = 1:LenH+LenX-1 % Running a for loop from 1 to length of Y -1 if i<=LenX % till I IS Lesser then length of X i.e overlap about to begin t(1)= X(i); % put x(i) on t(1) later it is shifted forwards in the vector t i.e. later t(2)=t(1) for j = 1:LenH % in the if condition a for loop from 1 to length of H y(i) = y(i) + H(j)*t(j); % summing for all H(j)*t(j) and putting it at y(1) or y(2) or Y(i) in first iteration % i.e. for i=1 only firt multiplication would % be non zero rest all zeroes. end for k = LenH:-1:2 % shifting old value of t(i) to t(i+1) now there would me 1+ non zeroes values in t % this cycle would continue until i is lesser then % length X i.e. overlap increasing every iteration less % and less non zero vales in t every iteration t(k) = t(k-1); end
  • 7. else % now when all of the T is non zero which means 100% overlap in else overlap would start to decrease between T and H % T is basically X t(1)= 0; for j = 1:LenH % Now we start filling up Zeroes in T i.e. overlap began to decrease now and each iteration it would decrease % i.e T moving to left until there is no more % over lap y(i) = y(i) + (H(j)*t(j)); % in this for loop we multiply all respective vales of h and t and add the % putting it at y(1) or y(2) or Y(i) in first iteration end for k = LenH:-1:2 %% here just like similar loop above t where we were filling up t with vales of x %now we are filling up zeroos in t i.e. over lap decreasing t(k) = t(k-1); end end end ly=length(y) indices=[ly] for i=1:ly indices(i)=i; end disp (y); %displays vector y. disp (indices); % displays vector indices. stem(y); ylabel('Y[n]'); xlabel('[n]'); title('Convolution without conv function'); Comment only23 Sep 2013Aghil Vinayak x = input('Enter x: '); h = input('Enter h: ') ; Ni = length(x); Nh = length(h); y = zeros(1,Ni+Nh);
  • 8. t = zeros(1,Nh); for i = 1:Ni+Nh-1 if i<=Ni t(1)= x(i); for j = 1:Nh y(i) = y(i) + h(j)*t(j); end for k = Nh:-1:2 t(k) = t(k-1); end else t(1)= 0; for j = 1:Nh y(i) = y(i) + (h(j)*t(j)); end for k = Nh:-1:2 t(k) = t(k-1); end end end stem(y); Comment only30 Mar 2013sonali21 Feb 2013Rama Krishna Tata17 Feb 2013Abdul-Rauf Mujahid function [y] = myconv( x,h ) m=length(x); n=length(h); x=[x,zeros(1,n)]; h=[h,zeros(1,m)]; for i=1:n+m-1 y(i)=0; for j=1:m