Math Preperation Zone: Program Codes and Algorithms
+5
BIT0129-Tabassum
Saiful
BIT0117-Ibrahim
BIT0115-Efat
BIT0122-Amit
9 posters
IITDU Forum :: Academics (BIT) :: Semester 3 :: MATH 304
Page 1 of 2
Page 1 of 2 • 1, 2
Math Preperation Zone: Program Codes and Algorithms
[You must be registered and logged in to see this image.] Links will be upgraded depending on YOUR contributions
Hi guys
In this zone, we will all work together to share different algorithms(if absent in book) and flow charts as well as codes so that we can write everything in exam correctly.
Start sharing!!
*Some of you have slow Internet and might face problems viewing links. In that case, reply under this topic to send contents to your mail. I/Others will try to deliver them ASAP [You must be registered and logged in to see this image.] *
Programs/Flow Charts:
chapter 6
(note: I think all of us know the program codes of Chapter 6, still if you need it, I can post. Give more priorities to Flow Charts)
Chapter 8
Chapter 11
Differentiating Continuous Functions-[You must be registered and logged in to see this link.]/FlowChart
Chapter 12
the programs
**New Link which contains almost all flow charts is [You must be registered and logged in to see this link.] **
(thanks goes to saiful for sharing this excellent link , but be warned. the flowcharts are not algorithm oriented, these are more program oriented. that means those are not similar to the book we follow.)
Links will be upgraded depending on YOUR contributions
Hi guys
In this zone, we will all work together to share different algorithms(if absent in book) and flow charts as well as codes so that we can write everything in exam correctly.
Start sharing!!
*Some of you have slow Internet and might face problems viewing links. In that case, reply under this topic to send contents to your mail. I/Others will try to deliver them ASAP [You must be registered and logged in to see this image.] *
Programs/Flow Charts:
chapter 6
(note: I think all of us know the program codes of Chapter 6, still if you need it, I can post. Give more priorities to Flow Charts)
- Bisection method-[You must be registered and logged in to see this link.]/FlowChart
- False position method-Program/FlowChart
- Newton-Raphson Methhod-[You must be registered and logged in to see this link.]/FlowChart
- Secant Method-[You must be registered and logged in to see this link.]/FlowChart
- Fixed-Point Method-[You must be registered and logged in to see this link.]/FlowChart
Chapter 8
- Jacobi Iteration Method-[You must be registered and logged in to see this link.]/Flow Chart
- Gauss-Seidel Method-Program/FlowChart
- Method of Relaxation-Program/FlowChart
Chapter 11
Differentiating Continuous Functions-[You must be registered and logged in to see this link.]/FlowChart
Chapter 12
the programs
- Trapezoidal Rule-Program/FlowChart/[You must be registered and logged in to see this link.]
- Simpson't Rule-Program/FlowChart
**New Link which contains almost all flow charts is [You must be registered and logged in to see this link.] **
(thanks goes to saiful for sharing this excellent link , but be warned. the flowcharts are not algorithm oriented, these are more program oriented. that means those are not similar to the book we follow.)
Links will be upgraded depending on YOUR contributions
Last edited by BIT0122-Amit on Fri May 21, 2010 5:31 pm; edited 12 times in total
Re: Math Preperation Zone: Program Codes and Algorithms
bhai, code gula ektu uplaod kor
@AMIT............apni doya kore nijer kora kisu jinish o upload koiren
kebol onner ta na
coz, ............
@AMIT............apni doya kore nijer kora kisu jinish o upload koiren
kebol onner ta na
coz, ............
BIT0115-Efat- Service Release
- Course(s) :
- BIT
Blood Group : O+
Posts : 779
Points : 1120
Re: Math Preperation Zone: Program Codes and Algorithms
(note: I think all of us know the program codes of Chapter 6, still if you need it, I can post. Give more priorities to Flow Charts)
hey, I said if you need 'em, just mention what you need.
now tell me, exactly which codes do you want?
Re: Math Preperation Zone: Program Codes and Algorithms
all code .................
BIT0117-Ibrahim- Study Moderator
- Course(s) :
- BIT
Blood Group : B+
Posts : 96
Points : 234
Re: Math Preperation Zone: Program Codes and Algorithms
Jacobi.cpp
- Code:
#include<math.h>
#include<iostream>
#include<stdio.h>
#define EPS 0.000001
#define maxit 100
using namespace std;
void jacobi(int n, float a[10][10], float b [10], float x[10], int *count, int *status )
{
int i,j,key;
float sum, x0[10];
for(i=1; i<=n; i++)
x0[i]= b[i] / a[i][i];
*count = 1;
begin:
key = 0;
for(i=1; i<=n; i++)
{
sum = b[i];
for(j=1;j<=n;j++)
{
if(i==j)continue;
sum = sum - a[i][j] * x0[j];
}
x[i] = sum / a[i][j];
if(key==0)
{
if(fabs((x[i]- x0[i])/x[i])> EPS)
key = 1;
}
}
if(key == 1)
{
if(*count == maxit)
{
*status = 2;
return;
}
else
{
*status = 1;
for(i=1;i<=n;i++)
x0[i]= x[i];
}
count = count +1 ;
goto begin;
}
return;
}
int main(){
int i,j,n,count,status;
float a[10][10], b[10], x[10];
printf("\n Solution by Jacobi iteration\n");
printf("\n What is the size n of the system?\n ");
scanf("%d", &n);
printf("\nInput coefficient a(i,j), row by row \n");
for(i=1;i<=n;i++)
for(j=i;j<=n;j++)
scanf("%f", &a[i][j]);
printf("\nInput vector b\n");
for(i=1;i<=n;i++)
scanf("%f",&b[i]);
jacobi(n, a, b, x, &count, &status);
if(status==2)
{
printf("\n No converence in %d itrerations\n\n", maxit);
}
else
{
printf("\n\tSelection vector x \n\n");
for(i=1;i<=n;i++)
printf("%15.6f",x[i]);
printf("\n\n Iterations = %d", count);
}
return 0;
}
Last edited by Saiful on Thu May 20, 2010 2:10 pm; edited 1 time in total
Saiful- Beta Release
- Course(s) :
- BIT
Blood Group : A+
Posts : 50
Points : 88
Re: Math Preperation Zone: Program Codes and Algorithms
GaseIt.cpp
- Code:
#include<math.h>
#include<iostream>
#include<stdio.h>
#define EPS 0.000001
#define maxit 50
using namespace std;
void gaseid(int n, float a[10][10], float b [10], float x[10], int *count, int *status )
{
int i,j,key;
float sum, x0[10];
for(i=1; i<=n; i++)
x0[i]= b[i] / a[i][i];
*count = 1;
begin:
key = 0;
for(i=1; i<=n; i++)
{
sum = b[i];
for(j=1;j<=n;j++)
{
if(i==j)continue;
sum = sum - a[i][j] * x0[j];
}
x[i] = sum / a[i][j];
if(key==0)
{
if(fabs((x[i]- x0[i])/x[i])> EPS)
key = 1;
}
}
if(key == 1)
{
if(*count == maxit)
{
*status = 2;
return;
}
else
{
*status = 1;
for(i=1;i<=n;i++)
x0[i]= x[i];
}
count = count +1 ;
goto begin;
}
return;
}
int main(){
int i,j,n,count,status;
float a[10][10], b[10], x[10];
printf("\n Solution by Gauss-Shidel iteration\n");
printf("\n What is the size n of the system?\n ");
scanf("%d", &n);
printf("\nInput coefficient a(i,j), row by row \n");
printf("\n One row Each line\n");
for(i=1;i<=n;i++)
for(j=i;j<=n;j++)
scanf("%f", &a[i][j]);
printf("\nInput vector b\n");
for(i=1;i<=n;i++)
scanf("%f",&b[i]);
gaseid(n, a, b, x, &count, &status);
if(status==2)
{
printf("\n No converence in %d itrerations\n\n", maxit);
}
else
{
printf("\n\tSelection vector x \n\n");
for(i=1;i<=n;i++)
printf("%15.6f",x[i]);
printf("\n\n Iterations = %d", count);
}
return 0;
}
Last edited by Saiful on Thu May 20, 2010 2:11 pm; edited 1 time in total
Saiful- Beta Release
- Course(s) :
- BIT
Blood Group : A+
Posts : 50
Points : 88
Re: Math Preperation Zone: Program Codes and Algorithms
good work saiful
But there is a little problem.
You need to give codes like this:
Example:
Say, you want to write:
#include
so you need to write like this:
easy, eh?
Can you please do it Saiful? Or else, we will have programs which are like:
#include
#include
#include
But there is a little problem.
You need to give codes like this:
- Code:
[code]The C codes here[/code]
Example:
Say, you want to write:
- Code:
#include <stdio.h>
#include
so you need to write like this:
- Code:
[code]
#include<stdio.h>
//what ever codes you have here
int main(void){
return 0;
}
[/code]
easy, eh?
Can you please do it Saiful? Or else, we will have programs which are like:
#include
#include
#include
Re: Math Preperation Zone: Program Codes and Algorithms
Hello friend go to this page and search Google books for flowchart
This site is very useful now for our.
Ei site sob dea ass e ja tomader need:
[You must be registered and logged in to see this link.]
This site is very useful now for our.
Ei site sob dea ass e ja tomader need:
[You must be registered and logged in to see this link.]
Last edited by Saiful on Thu May 20, 2010 2:00 pm; edited 1 time in total
Saiful- Beta Release
- Course(s) :
- BIT
Blood Group : A+
Posts : 50
Points : 88
Re: Math Preperation Zone: Program Codes and Algorithms
Here goes me!!
Secant Method:
Secant Method:
- Code:
/*Secant Method for determining the root of non linear equations*/
/*By Amit*/
/*Algorithm method from Numerical Methods by E.Balaguruswamy*/
#include<stdio.h>
#include<math.h>
#define Err 0.000001
#define MAXIT 50
#define F(x) (x)*(x)+(x)-2
int main(void)
{
int counter=1;
int con = 1;
int flag = 0;
float x1, x2, x3, root=0;
float f1, f2=0;
printf("Enter your x1: ");
scanf("%f",&x1);
printf("\nEnter your x2: ");
scanf("%f",&x2);
f1 = F(x1);
f2 = F(x2);
while (con)
{
if((fabs(f1-f2))<Err)
{
printf("Error: Division by zero\n");
con = 0;
break;
}
x3 = (((f2*x1)-(f1*x2))/(f2-f1));
if(fabs((x3-x2)/(x3))>Err)
{
if(counter==MAXIT ){
printf("\nError: no convergence in %d iterations\n",MAXIT);
con=0;
break;
}
x1=x2;
f1=f2;
x2=x3;
f2=F(x3);
counter ++;
}
else
{
con=0;
root = x3;
flag = 1;
break;
}
}
if(flag)
{
printf("\nroot is %f",root);
printf("\nFunction value at root is %f",F(root));
printf("\nNUmber of iterations %d\n",counter);
}
return 0;
}
Last edited by BIT0122-Amit on Thu May 20, 2010 4:59 pm; edited 1 time in total
Re: Math Preperation Zone: Program Codes and Algorithms
Newton RaphSon Method
- Code:
/*Newton RaphSon Method for determining the root of non linear equations*/
/*By Amit*/
/*Algorithm method from Numerical Methods by E.Balaguruswamy*/
#include<stdio.h>
#include<math.h>
#define Err 0.000001
#define F(x) (x)*(x)+(x)-2
#define DF(x) 2*(x)+1
#define MAXIT 100
int main(void)
{
int counter=1;
int con = 1;
float x0, x1=0;
float fx;
float xn;
float fdx;
printf("Enter your value of X: ");
scanf("%f",&x0) ;
printf("\n");
while (con)
{
fx=F(x0);
fdx=DF(x0);
xn=x0-(fx/fdx);
if(fabs((xn-x0)/xn)<Err)
{
printf("\nThe root is %f",xn);
printf("\nThe value of function using root is %f",F(xn));
printf("\nThe number of iterations to reach root is %d\n",counter);
con = 0;
}
else
{
x0=xn;
counter++;
if(counter>MAXIT)
{
printf("\nThe solution does not converge in\n");
con=0;
}
}
}
return 0;
}
Re: Math Preperation Zone: Program Codes and Algorithms
Fixed Position Method:
- Code:
/*
Fixed Point Method for determining the roots of non linear equations
By Amit
Algorithm method from Numerical Methods by E.Balaguruswamy
*/
#include <stdio.h>
#include <math.h>
#define Err 0.000001
#define F(x) (x)*(x)+(x)-2
int main(void){
float x0, x1, x2, root, f0, f1, f2=0;
int counter=0;
int con;
printf("Enter your x1: ");
scanf("%f",&x1);
printf("\nEnter your x2: ");
scanf("%f",&x2);
f1=F(x1);
f2=F(x2);
if((f1*f2)>0)
{
printf("Does not brace root \n");
counter++;
return 0;
}
while(con)
{
counter=counter +1 ;
//counter++;
x0=x1-f1*(x2-x1)/(f2-f1);
f0=F(x0);
if(f1*f0<0)
{
x2=x0;
f2=f0;
}
else
{
x1=x0;
f1=f0;
}
printf("%f \t %f\n",x1,x2);
if(fabs((x1-x2)/x2) < Err)
{
root = (x1+x2)/2;
con=0;
}
}
printf("The root is %e\n",root);
printf("the number of iteration is %d\n",counter);
printf("The value of F(root) is %f\n", F(root));
return 0;
}
Last edited by BIT0122-Amit on Thu May 20, 2010 4:59 pm; edited 2 times in total
Re: Math Preperation Zone: Program Codes and Algorithms
Bisection Method:
- Code:
#include <stdio.h>
#include <math.h>
#define EPS 0.000001
#define F(x) ((x)*(x))+(x)-2
int main(){
float x1, x2, x0=0.0;
float f1=0.0;
float f2=0.0;
float f0=0.0;
float root=0.0;
int counter =0;
int con=1;
printf("Enter your x1: ");
scanf("%f",&x1);
printf("\nEnter your x2: ");
scanf("%f",&x2);
f1=F(x1);
f2=F(x2);
printf("\nthe value of F1 is %f",f1);
printf("\nthe value of F2 is %f",f2);
if ((f1*f2)>0)
{
printf("\nThe values do not brace any roots\nProgram exiting.");
return 0;
}
else
{
while (con)
{ counter ++;
x0=((x1+x2)/2);
printf("\nx0 = %f",x0);
f0=F(x0);
printf("\tf0 = %f",f0);
//please look at this part carefully. this part is absent in Book's algorithm
if(f0==0){
root = x0;
break;
}
if ((f1*f0)<0)
{
x2=x0;
}else
{
x1=x0;
f1=f0;
}
if(fabs((x1-x2)/x2) < EPS)
{
root = (x1+x2)/2;
con=0;
}
}
}
printf("\nThe value of the root is : %e\n",root);
printf("\nthe value of the function using the root is %e\n",F(root));
printf("\nthe value of the counter is %d\n",counter);
return 0;
}
Re: Math Preperation Zone: Program Codes and Algorithms
Hey saiful, I have gone through the link you gave.
Problem is, thew flow charts are not exactly algorithm oriented, they are more program oriented.
Problem is, thew flow charts are not exactly algorithm oriented, they are more program oriented.
Re: Math Preperation Zone: Program Codes and Algorithms
:S Err... I think I deleted Toma's post by mistake... :S or somehow it disappeared??
She gave the Jacobi code here... I tried to edit it. and then perhaps by mistake deleted it.
anyway, the jacobi code by Toma is given:
She gave the Jacobi code here... I tried to edit it. and then perhaps by mistake deleted it.
anyway, the jacobi code by Toma is given:
- Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main(void){
int n = 3, key, i, j;
double a[3][3] = {
2, 1, 1,
3, 5, 2,
2, 1, 4
};
int b[3] = {5, 15, 8};
double x0[3], x[3], sum;
clrscr();
for(i=0; i<n; i++)
x0[i] = b[i]/a[i][i];
again:
key = 0;
for(i=0; i<n; i++){
sum = b[i];
for(j=0; j<n; j++){
if(i!=j)
sum -= (a[i][j]*x0[j]);
}
x[i] = sum/a[i][i];
if(fabs((x[i]-x0[i]))>.0000001)
key = 1;
if(key==1){
x0[i] = x[i];
goto again;
}
}
for(i=0; i<n; i++)
printf("%f\n", x[i]);
getch();
return 0;
}
Re: Math Preperation Zone: Program Codes and Algorithms
Thank you all who have contributed here
আমার মত ফাঁকিবাজদের খুবই কাজে আসবে [You must be registered and logged in to see this image.]
আমার মত ফাঁকিবাজদের খুবই কাজে আসবে [You must be registered and logged in to see this image.]
Re: Math Preperation Zone: Program Codes and Algorithms
awesome guys awesome..............ei to hoye gese
ei jonnoi to amra toder eto pran vore doa kori [You must be registered and logged in to see this image.]
ei jonnoi to amra toder eto pran vore doa kori [You must be registered and logged in to see this image.]
BIT0115-Efat- Service Release
- Course(s) :
- BIT
Blood Group : O+
Posts : 779
Points : 1120
Re: Math Preperation Zone: Program Codes and Algorithms
Thanx frnds...for your nice contribution [You must be registered and logged in to see this image.]
@Saiful->Mama tumito pura kopaitasoooo...mashallah....keep it up. [You must be registered and logged in to see this image.]
@Saiful->Mama tumito pura kopaitasoooo...mashallah....keep it up. [You must be registered and logged in to see this image.]
BIT0109-Jobaer- Beta Release
- Course(s) :
- BIT
Blood Group : B+
Posts : 91
Points : 191
Re: Math Preperation Zone: Program Codes and Algorithms
jobaer, if you have anything that can help us, please do share
Re: Math Preperation Zone: Program Codes and Algorithms
Simple Trapezoidal Rule:
- Code:
/*Simple Trapezoid Rule for determining the integration of formula*/
/*By Amit*/
/*Algorithm method from Numerical Methods by E.Balaguruswamy*/
/*
======special note for gcc users==========
use an -lm switch to compile this program correctly as the switch manually links the exp function used here.
for example:
gcc trapezoid.c -lm
*/
#include<stdio.h>
#include<math.h>
float F(float x){
float f ;
f = 1.0-(exp(-x/2.0));
return f;
}
int main(void){
int n,i;
float a,b,h,c,sum,ict;
printf("give intial value of x: ");
scanf("%f",&a);
printf("\ngive the final value of x: ");
scanf("%f",&b);
printf("\nenter the segmentation width: ");
scanf("%f",&h);
n=(b-a)/h;
sum = ( F(a) + F(b) )/2.0;
for(i=1;i<=n-1;i++){
sum = sum + F(a+i*h);
}
ict = sum*h;
printf("\n");
printf("the integration between %f and %f ",a,b);
printf("\nwhere h=%e is %f\n",h,ict);
printf("\n");
}
Re: Math Preperation Zone: Program Codes and Algorithms
@Amit::::
[You must be registered and logged in to see this image.] oita amii delete korchi..not u.. [You must be registered and logged in to see this image.]
[You must be registered and logged in to see this image.] oita amii delete korchi..not u.. [You must be registered and logged in to see this image.]
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: Math Preperation Zone: Program Codes and Algorithms
Hmm... nice catch.BIT0107-toma wrote:@Amit::::
[You must be registered and logged in to see this image.] oita amii delete korchi..not u.. [You must be registered and logged in to see this image.]
Thanks to a minor mistake, any one was able to delete his/her own post :s leading this forum to some potential structural damage.
It has been fixed (after going through all the forum subsections... ouch... my hand!! )I suppose the delete button is absent to all the users now.
let me know if you can find it
Re: Math Preperation Zone: Program Codes and Algorithms
Efat,
I uploaded whatever I had and will upload whatever I am going to do tomorrow. Give some flow charts dude
I seriously need 'em...
seriously!!
bhai, code gula ektu uplaod kor
@AMIT............apni doya kore nijer kora kisu jinish o upload koiren
kebol onner ta na
I uploaded whatever I had and will upload whatever I am going to do tomorrow. Give some flow charts dude
I seriously need 'em...
seriously!!
Re: Math Preperation Zone: Program Codes and Algorithms
someone plz help with the flow charts.............the google book is too colossal to load through the net speed of one & only digital hall(!!!!!!!!!!!!!) of Bangladesh..........
BIT0108-mostafa- Release Candidate
- Course(s) :
- BIT
Blood Group : O+
Posts : 118
Points : 184
Re: Math Preperation Zone: Program Codes and Algorithms
I think I can help... brb after trying to .. errr.... get contents from book.
Re: Math Preperation Zone: Program Codes and Algorithms
Hey mostafa, download this [You must be registered and logged in to see this link.]
It contains some,not all, and not few flowcharts.
both downloading and unzipping passwords are
Click on spoiler to view.
In case you can't open any jpg file, try renaming the extension to png. I kind of messed up the extension
It contains some,not all, and not few flowcharts.
both downloading and unzipping passwords are
Click on spoiler to view.
- Spoiler:
foriit
In case you can't open any jpg file, try renaming the extension to png. I kind of messed up the extension
Page 1 of 2 • 1, 2
Similar topics
» Codes and algorithms for printing for contests
» Different Sorting algorithms illustrated in C
» Implementation of Different OS Algorithms by BIT0101 and BIT0122
» advantage and disadvantage of process scheduling algorithms
» Math 204 Help
» Different Sorting algorithms illustrated in C
» Implementation of Different OS Algorithms by BIT0101 and BIT0122
» advantage and disadvantage of process scheduling algorithms
» Math 204 Help
IITDU Forum :: Academics (BIT) :: Semester 3 :: MATH 304
Page 1 of 2
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford