Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
Numerical solution of ordinary differential equations by using Runge-Kutta Method of Order Two and Runge-Kutta Method of Order Four
How to write the C++ codes?
A reworking of my 2010 RubyConf lightning talk introducing Go via a concurrent implementation of MapReduce. This code is probably buggy as hell and the design awful but it's also a reasonably good intro to the full breadth of Go.
A reworking of my 2010 RubyConf lightning talk introducing Go via a concurrent implementation of MapReduce. This code is probably buggy as hell and the design awful but it's also a reasonably good intro to the full breadth of Go.
Being a slow interpreter, Python may drive a system to deliver utmost speed if some guidelines are followed. The key is to treat programming languages as syntactic sugar to the machine code. It expedites the workflow of timing, iterative design, automatic testing, optimization, and realize an HPC system balancing the time to market and quality of code.
Speed is the king. 10x productive developers change business. So does 10x faster code. Python is 100x slower than C++ but it only matters when you really use Python to implement number-crunching algorithms. We should not do that, and instead go directly with C++ for speed. It calls for strict disciplines of software engineering and code quality, but it should be noted that here the quality is defined by the runtime and the time to market.
The presentation focuses on the Python side of the development workflow. It is made possible by confining C++ in architecture defined by the Python code, which realizes most of the software engineering. The room for writing fast C++ code is provided by pybind11 and careful design of typed data objects. The data objects hold memory buffers exposed to Python as numpy ndarrays for direct access for speed.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
C++ TUTORIAL 9
1. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
QUESTION 1
Write a C++ program using Taylor’s series method to solve the equation
=3x+y2 to approximate y when x=0.1, given that y=1 when x=0.
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double x0=0,y0=1 , h=0.1,y1,y2,y3,y4, y;
y1=3*x0 + y0*y0;
y2=3+ 2*y0*y1;
y3=2*y1*y1 + 2*y0*y2;
y4=6*y1*y2 + 2*y0*y3;
y= y0+ (y1*h) + (y2*pow(h,2))/2 + (y3*pow(h,3))/6 + (y4*pow(h,4))/24;
cout << "The value of y when x=0.1 is " << setprecision(5) <<fixed << y << endl;
return 0;
}
//Output:
The value of y when x=0.1 is 1.12722
//Alternative way for question 1
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define h 0.1
double f(double x,double y)
{
return 3*x + y*y;
}
double ff(double x,double y)
{
3. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
QUESTION 2
Write a C++ program using Taylor’s series method to solve
+4y=x2 ,
y(0)=1 to approximate y(0.2).
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double x0=0,y0=1 , h=0.2,y1,y2,y3,y4, y;
y1= x0*x0 -4*y0;
y2= 2*x0- 4*y1;
y3= 2- 8*x0+16*y1; // y3= 2- 4*y2;
y4= -8+32*x0 -64*y1; // y4= -4*y3;
y= y0+ (y1*h) + (y2*pow(h,2))/2 + (y3*pow(h,3))/6 + (y4*pow(h,4))/24;
cout << "The value of y when x=0.2 is " << setprecision(5) <<fixed << y << endl;
return 0;
}
//Output:
The value of y when x=0.2 is 0.45387
5. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
cout << "ittxtty " << endl;
for ( i=0;i<=2;i++)
{
y[i+1]=y[i]+h*f(x,y[i] ) + (h*h/2)*ff(x,y[i]) + (pow(h,3)/6)*fff(x,y[i])+
(pow(h,4)/24)*ffff(x,y[i]) ;
cout << i << "tt" << setprecision(1)<<fixed << x << "tt" << setprecision(5) << fixed
<< y[i] << endl;
x= x+ h;
}
}
int main()
{
double x0,y[100];
cout << "Enter x0 and y0 : ";
cin >> x0 >> y[0];
taylor(x0,y);
return 0;
}
//Output:
Enter x0 and y0 : 0 1
i x y
0 0.0 1.00000
1 0.2 0.45387
2 0.4 0.21894
6. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
QUESTION 3
Write a C++ program to solve
= -xy2 , 푦(2)=1 in the interval 2< x <3
with h=0.1 using Euler’s method. Compare the results with exact
solution from 푦= 2/(x2 -2)
#include<iostream>
#include <cmath>
#include<iomanip>
using namespace std;
#define F(x,y) -x*y*y
void main()
{
double y0,y,x,x0,xn,h, exact,error;
cout <<"Enter the value of range(x0 and xn): ";
cin >> x0 >> xn;
cout << "Enter the value of y0: ";
cin >> y0;
cout <<"Enter the h: ";
cin >> h;
cout << "nnx0= "<< x0 << "tt" << "y0= " << y0;
x=x0;
y=y0;
while(x<xn)
{
7. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
y= y + h * F(x,y);
x=x+h;
exact = 2/(x*x-2);
error= exact-y;
cout << "nx= " << setprecision(1) <<fixed << x << "t";
cout << setprecision(4) <<fixed << exact<< "t" <<setprecision(4) <<fixed
<< y << "t";
cout <<setprecision(4) << fixed << fabs(error) << endl;
}
}
//Output:
Enter the value of range(x0 and xn): 2 3
Enter the value of y0: 1
Enter the h: 0.1
x0= 2 y0= 1
x= 2.1 0.8299 0.8000 0.0299
x= 2.2 0.7042 0.6656 0.0386
x= 2.3 0.6079 0.5681 0.0398
x= 2.4 0.5319 0.4939 0.0380
x= 2.5 0.4706 0.4354 0.0352
x= 2.6 0.4202 0.3880 0.0322
x= 2.7 0.3781 0.3488 0.0292
8. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
x= 2.8 0.3425 0.3160 0.0265
x= 2.9 0.3120 0.2880 0.0240
x= 3.0 0.2857 0.2640 0.0217
//Alternative way for question no 3
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
//Given dy/dx
float f(float(x),float(y))
{
return (-x*y*y);
}
int main()
{
double y[100],x[100], exact,error,percent_error;
int n,i;
float h;
//Entering the initial values of x & y
cout<<"Enter the value of x0: ";
cin>>x[0];
cout<<"Enter The Value of y0: ";
cin>>y[0];
9. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
cout<<"Enter the number of Iterations: ";
cin>>n;
cout<<"Enter The Value of Step Size: ";
cin>>h;
cout<<"nIterationstxtytExact valuetErrort Percentage Error"<<endl;
//Calculating the value of x
for(i=1;i<=n;i++)
{
x[i]=x[i-1]+h;
}
//Calculating the value of y
for(i=1;i<=n;i++)
{
y[i]=y[i-1]+(h*f(x[i-1],y[i-1]));
}
//Printing result
for(i=0;i<=n;i++)
{
exact = 2/(x[i]*x[i]-2);
error= exact-y[i];
percent_error= (fabs(error)/exact)*100;
cout << i<<"tt"<< setprecision(2) <<x[i]<<"t";
cout << setprecision(4)<< y[i] << "t" << exact << "tt" ;
cout << setprecision(4) <<fixed << fabs(error) << "t ";
10. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
cout << setprecision(5) << percent_error << endl;
}
return 0;
}
//Output:
Enter the value of x0: 2
Enter The Value of y0: 1
Enter the number of Iterations: 10
Enter The Value of Step Size: 0.1
Iterations x y Exact value Error Percentage Error
0 2 1 1 0.0000 0.00000
1 2.10 0.8000 0.8299 0.0299 3.60000
2 2.20 0.6656 0.7042 0.0386 5.48480
3 2.30 0.5681 0.6079 0.0398 6.54182
4 2.40 0.4939 0.5319 0.0380 7.14753
5 2.50 0.4354 0.4706 0.0352 7.48768
6 2.60 0.3880 0.4202 0.0322 7.66332
7 2.70 0.3488 0.3781 0.0292 7.73341
8 2.80 0.3160 0.3425 0.0265 7.73413
9 2.90 0.2880 0.3120 0.0240 7.68862
10 3.00 0.2640 0.2857 0.0217 7.61210
11. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
QUESTION 4
Write a C++ program to find y(1) from
= x+y , y(0)=1 using Euler’s
method by using h=0.2. The exact solution is y=-1-x+2ex
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
//Given dy/dx
float f(float(x),float(y))
{
return (x+y);
}
int main()
{
double y[100],x[100], exact,error,percent_error;
int n,i;
float h;
//Entering the initial values of x & y
cout<<"Enter the value of x0: ";
cin>>x[0];
cout<<"Enter The Value of y0: ";
cin>>y[0];
cout<<"Enter the number of Iterations: ";
12. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
cin>>n;
cout<<"Enter The Value of Step Size: ";
cin>>h;
cout<<"nIterationstxtytExact valuetErrort Percentage Error"<<endl;
//Calculating the value of x
for(i=1;i<=n;i++)
{
x[i]=x[i-1]+h;
}
//Calculating the value of y
for(i=1;i<=n;i++)
{
y[i]=y[i-1]+(h*f(x[i-1],y[i-1]));
}
//Printing result
for(i=0;i<=n;i++)
{
exact = -1-x[i] +2*exp(x[i]);
error= exact-y[i];
percent_error= (fabs(error)/exact)*100;
cout << i<<"tt"<< setprecision(1) <<x[i]<<"t";
cout << setprecision(4)<< y[i] << "t" << exact << "tt" ;
13. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
cout << setprecision(4) <<fixed << fabs(error) << "t ";
cout << setprecision(5) << percent_error << endl;
}
return 0;
}
//Output:
Enter the value of x0: 0
Enter The Value of y0: 1
Enter the number of Iterations: 5
Enter The Value of Step Size: 0.2
Iterations x y Exact value Error Percentage Error
0 0 1 1 0.0000 0.00000
1 0.2 1.2000 1.2428 0.0428 3.44427
2 0.4 1.4800 1.5836 0.1036 6.54497
3 0.6 1.8560 2.0442 0.1882 9.20821
4 0.8 2.3472 2.6511 0.3039 11.46256
5 1.0 2.9766 3.4366 0.4599 13.38324
QUESTION 5
Write a C++ program to solve
= -2xy2, y(0)=1 in the interval
0≤ x ≤0.5 with h=0.1 using Euler’s method. The exact value is
y= 1/(x2+1)
#include<iostream>
#include<cmath>
#include<iomanip>
14. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
using namespace std;
//Given dy/dx
float f(float(x),float(y))
{
return (-2*x*y*y);
}
int main()
{
double y[100],x[100], exact,error,percent_error;
int n,i;
float h;
//Entering the initial values of x & y
cout<<"Enter the value of x0: ";
cin>>x[0];
cout<<"Enter The Value of y0: ";
cin>>y[0];
cout<<"Enter the number of Iterations: ";
cin>>n;
cout<<"Enter The Value of Step Size: ";
cin>>h;
cout<<"nIterationstxtytExact valuetErrort Percentage Error"<<endl;
15. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
//Calculating the value of x
for(i=1;i<=n;i++)
{
x[i]=x[i-1]+h;
}
//Calculating the value of y
for(i=1;i<=n;i++)
{
y[i]=y[i-1]+(h*f(x[i-1],y[i-1]));
}
//Printing result
for(i=0;i<=n;i++)
{
exact = (1/(x[i]*x[i]+1));
error= exact-y[i];
percent_error= (fabs(error)/exact)*100;
cout << i<<"tt"<< setprecision(1) <<x[i]<<"t";
cout << setprecision(4)<< y[i] << "t" << exact << "tt" ;
cout << setprecision(4) <<fixed << fabs(error) << "t ";
cout << setprecision(5) << percent_error << endl;
}
return 0;
}
16. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
//Output :
Enter the value of x0: 0
Enter The Value of y0: 1
Enter the number of Iterations: 5
Enter The Value of Step Size: 0.1
Iterations x y Exact value Error Percentage Error
0 0 1 1 0.0000 0.00000
1 0.1 1.0000 0.9901 0.0099 1.00000
2 0.2 0.9800 0.9615 0.0185 1.92000
3 0.3 0.9416 0.9174 0.0242 2.63266
4 0.4 0.8884 0.8621 0.0263 3.05314
5 0.5 0.8253 0.8000 0.0253 3.15629
QUESTION 6
Write a C++ program to solve
= x+y2 with y(1)=0 at x=1.3 using
Euler’s Method
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
//Given dy/dx
float f(float(x),float(y))
{
return (x+ y*y);
}
17. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
int main()
{
double y[100],x[100];
int n,i;
float h;
//Entering the initial values of x & y
cout<<"Enter the value of x0: ";
cin>>x[0];
cout<<"Enter The Value of y0: ";
cin>>y[0];
cout<<"Enter the number of Iterations: ";
cin>>n;
cout<<"Enter The Value of Step Size: ";
cin>>h;
cout<<"nIterationstxty"<<endl;
//Calculating the value of x
for(i=1;i<=n;i++)
{
x[i]=x[i-1]+h;
}
//Calculating the value of y
for(i=1;i<=n;i++)
{
18. TUTORIAL 9; SJEM2231: STRUCTURED PROGRAMMING (C++)
y[i]=y[i-1]+(h*f(x[i-1],y[i-1]));
}
//Printing result
for(i=0;i<=n;i++)
{
cout << i<<"tt"<< setprecision(2) <<x[i]<< "t" << setprecision(5)<< y[i] <<
endl;
}
return 0;
}
//Output:
Enter the value of x0: 1
Enter The Value of y0: 0
Enter the number of Iterations: 3
Enter The Value of Step Size: 0.1
Iterations x y
0 1 0
1 1.1 0.1
2 1.2 0.211
3 1.3 0.33545