Tuesday, October 24, 2017

Online Examination system source code.........

 Here is the source code for online exam system using PHP, MYSQL,AJAX, JAVASCRIPT etc....

Source code for Online Exam System

Saturday, October 14, 2017

Summation of square value up to n in assembly language

;Alamgir, CSE, JUST
;1^2+2^2+3^2+4^2+---------

MOV Cx, 10 ; 10 is your n value
MOV bx, 00

myloop:   
MOV Ax, Cx
MUL Ax
ADD Ax, bx
MOV bx, Ax
LOOP myloop

Monday, October 9, 2017

Newtons divided difference interpolation formula implementation using perl language

#-Newtons divided difference interpolation formula implementation using perl language-----

=comment

    -----Input Instruction------

    Enter the number of records

    Now enter the value of x and corresponding y

    Finally enter the value of x for finding y.

=cut

    #-------------main code start---------

   

  print "\Enter how many record you to enter : ";

  $n = <>;

  $k = 0;

  print "Enter the value of x with corresponding y : \n";

  for($i=0; $i<$n; $i++)

  {

   $x[$i] = <>; # Input x[]

   $y[$k][$i]= <>; # Input y[]

  }

  print "\n\nEnter X for finding f(x): ";

  $p = <>;

 

  # Mechanism for difference table-----------

  for($i=1;$i<$n;$i++)

  {

    $k=$i;

    for($j=0;$j<($n-$i);$j++)

    {

     $y[$i][$j]=($y[$i-1][$j+1]-$y[$i-1][$j])/($x[$k]-$x[$j]);

     $k++;

    }

  }

  # Print difference table-----------

print "\n\n--------------------------------Difference table for Newtons Divided Formula Formula--------------------------------------\n";

print "------------------------------------------------------------------------------------------------------------------------------------------\n";

print "     X\t\t";

for($i=0;$i<$n;$i++){

    print "Y($i)\t\t";

}

print "\n------------------------------------------------------------------------------------------------------------------------------------------\n";


  for($i=0;$i<$n;$i++)

  {

    printf("\n %.4lf\t",$x[$i]);

    for($j=0;$j<($n-$i);$j++)

    {

     printf("           %.3lf             ",$y[$j][$i]);

    }

   print "\n";

  }


  $i=0;

  do

  {

   if(($x[$i]<$p) && ($p<$x[$i+1])){

    $k=1;

    }

   else{

    $i++;

    }

  }while($k != 1);

 

  $f=$i;

  $sum=0;

  for($i=0;$i<($n-1);$i++)

  {

   $k=$f;

   $temp=1;

   for($j=0;$j<$i;$j++)

   {

    $temp = $temp * ($p - $x[$k]);

    $k++;

   }

    $sum = $sum + ($temp*($y[$i][$f]));

  }

  printf("\n\nFinal answer f(%.2f) = %f\n\n",$p,$sum);

  print "-------------THANK YOU------------\n";

 

=comment

--------------Input example-----------

    5

    0 1

    1 3

    3 49

    4 129

    7 813

    .3

    Ans : (0.30) = 1.831000

=cut

Sunday, October 8, 2017

Guass Backward Interpolation Formula Implementation Using Perl

#--------Guass Backward Interpolation Formula Implementation Using Perl-------------
#Md. Alamgir Hossain
#Dept. of Computer Science & Engineering
#Jessore University of Science & Technology
=comment
    Enter the number of records
    Now enter the value of x with corresponding y
    Now enter the value of X for finding y.
=cut

 sub fact
 {
  ($zz)=@_;
   $fct=1;
   for($i=1;$i<=$zz;$i++){
   $fct=$fct*$i;
  }
    return $fct;
 }
 print "Enter the number of records : \n";
$n = <>;

#Enter x with y

for($i=0;$i<$n;$i++)
{
    $x[$i] = <>;
    $y[0][$i] = <>;
}

for($i=1;$i<$n;$i++){
    for($j=0;$j<($n-$i);$j++){
        $y[$i][$j] = $y[$i-1][$j+1] - $y[$i-1][$j];
    }
}
print "-------------Difference Table for Guass Backward Formula--------------------\n";
print "-----------------------------------------------------------\n";
print "  X\t";
for($i=0;$i<$n;$i++){
    print "Y($i)\t";
}
print "\n----------------------------------------------------------\n";

for($i=0;$i<$n;$i++){
    printf ("\n%.3lf\t",$x[$i]);
  
    for($j=0;$j<($n-$i);$j++){
        printf ("%.3lf\t",$y[$j][$i]);
    }
    print "\n";
}
print "\n\n";
#-------Enter the finding value----------
$xn = <>;
$x0;
$x1;
$ii;
$i2;
for($i=0;$i<($n-1);$i++){
    if(($xn>=$x[$i])&&($xn<=$x[$i+1])){
        $ii = $i+1;
        $x0 = $x[$ii];
    }
}

$hv = $x[1]-$x[0];
$p = ($xn-$x0)/$hv;

$y0 = $y[0][$ii];
$y1 = $y[1][$ii-1];
$y2 = $y[2][$ii-1];
$y3 = $y[3][$ii-2];
$y4 = $y[4][$ii-2];
$y5 = $y[5][$ii-1];

$p1 = $p*($p+1);
$p2 = $p1*($p-1);
$p3 = $p2*($p+2);
$p4 = $p3*($p-2);

$f1 = ($p*$y1);
$f2 = ($p1*$y2)/&fact(2);
$f3 = ($p2*$y3)/&fact(3);
$f4 = ($p3*$y4)/&fact(4);
$f5 = ($p4*$y5)/&fact(5);

$f = $y0+$f1+$f2+$f3+$f4+$f5;
print "\nX0 is : $x0\n";
print "X is : $xn\n";
print "h is : $hv\n\n";
print "P is : $p\n";
print "\n\nFinal Answer for the given x is : $f\n\n\n\n";

=comment
    4
    2 3.818
    3 2.423
    4 -1.027
    5 -2.794
    3.5
  
=cut

Stirling interpolaltion formula implementation using perl language

#----------Stirlings Interpolation Formula Implementation Using Perl----------
=comment
    Md. Alamgir Hossain
   Dept. of Computer Science & Engineering
  Jessore University of Science & Technology
=cut
=comment
------------------Input Instruction---------
    Enter the number of records
    Now enter the value of x with corresponding y
    Now enter the value of X for finding y.
=cut
#Main code start from here----------
#Sub function fact for finding factorial----------
 sub fact
 {
  ($zz)=@_;
   $fct=1;
   for($i=1;$i<=$zz;$i++){
   $fct=$fct*$i;
  }
    return $fct;
 }
 print "Enter how many records : \n";
$n = <>;
#Enter x with y
print "Enter the value of x with corresponding y : \n";
for($i=0;$i<$n;$i++)
{
    $x[$i] = <>;#For x
    $y[0][$i] = <>;#For y
}
print "Enter the finding x : \n";
$xn = <>;
#Mechanism for central difference table----
for($i=1;$i<$n;$i++){
    for($j=0;$j<($n-$i);$j++){
        $y[$i][$j] = $y[$i-1][$j+1] - $y[$i-1][$j];
    }
}
#print difference table---------
print "--------Central Difference table for Stirlings Interpolation------------\n";
print "-----------------------------------------------------------\n";
print "  X\t";
for($i=0;$i<$n;$i++){
    print "Y($i)\t";
}
print "\n----------------------------------------------------------\n";

for($i=0;$i<$n;$i++){
    printf ("\n%.3lf\t",$x[$i]);#print value of x
   
    for($j=0;$j<($n-$i);$j++){
        printf ("%.3lf\t",$y[$j][$i]);#print y
    }
    print "\n";
}
print "\n\n";

$x0;
$x1;
$ii;
$i2;
for($i=0;$i<($n-1);$i++){
    if(($xn>=$x[$i])&&($xn<=$x[$i+1])){
        $x0 = $x[$i];
        $ii = $i;
        $x1 = $x[$i+1];
        $i2 = $i+1;
    }
}
$p = ($xn-$x0)/($x1-$x0);#finding p

$hv = $x1-$x0;

$y0 = $y[0][$ii];
$y1 = $y[1][$ii];
$y11 = $y[1][$ii-1];
$y2 = $y[2][$ii-1];
$y3 = $y[3][$ii-1];
$y31 = $y[3][$ii-2];
$y4 = $y[4][$ii-2];
$y5 = $y[5][$ii-2];
$y51 = $y[5][$ii-3];
$y6 = $y[6][$ii-3];

$p1 = $p*$p;
$p2 = $p*(($p*$p)-1);
$p3 = $p1*(($p*$p)-1);
$p4 = $p2*($p1-4);
$p5 = $p3*($p1-4);

$f1 = ($p*($y1+$y11))/2;
$f2 = ($p1/2)*$y2;
$f3 = ($p2/&fact(3))*(($y3+$y31)/2);
$f4 = ($p3/&fact(4))*($y4);
$f5 = ($p4/&fact(5))*(($y5+$y51)/2);
$f6 = ($p5/&fact(6))*$y6;

$f = $y0+$f1+$f2+$f3+$f4+$f5+$f6;#Final law
print "\nX0 is : $x0\n";
print "X is : $xn\n";
print "h is : $hv\n\n";
print "P is : $p\n";
print "\n\nFinal Answer is : $f\n\n";

print "-------------Thank You----------\n\n";

=comment
--------------Input Example-----------
    5
    2 5
    4 49
    6 181
    8 449
    10 901
    7
    Final Answer is : 295
=cut

Saturday, October 7, 2017

Newton Raphson method in perl language

#Newton Rapson method implementation using perl language......
=comment
    Alamgir Hossain, CSE, JUST
=cut
#---------------------------The given function----------------
sub Function
{
  ($x) = @_;
  return ($x*$x)-2*$x;
  #return (2*$x)-3*sin($x)-5;
}
#--------------------------Drive Function-----------------
sub DriveFunc
{
  ($x) = @_;
  return (2*$x-2);
  #return 2-3*cos($x);
}

$iteration = 10,$x0 = 10,$h=0;#You can change the iteration & x0 values-----
print "--------One by one iteration and root value chart--------\n\n";
$root, $ite;
for($i=1;$i<=$iteration;$i++)
{
        $h=&Function($x0)/&DriveFunc($x0);
        $x1 = $x0 - $h;
        print "After iteration $i the Root is : $h\n";
        $x0=$x1;
        $root=$h;
        $ite = $i;
        if($h<.01){
        last;
    }

   print "\nAfter $ite iteration the Approximate Root is : $root\n\n";
   print "-------------------Thank You---------------------\n\n";
exit;

Inverse lagrange interpolation formula theory, algorithm and flowchart with a lot of example





Inverse Lagrange’s Interpolation Formula

Theory :

  .



Example :


1. Use Lagrange’s inverse interpolation formula to obtain the value of t, when A=85 from the following table-------------

T
2
5
8
14
A
94.8
87.9
81.3
68.7
           
       Ans : 6.30383001716033

2. Lagrange’s formula inversely to obtain the value of ɸ, when F(ɸ)=0.3887, from the following table----------

ɸ
210
230
250
F(ɸ)
0.3706
0.4068
0.4433

Ans : 220.020463153135





3. Find the value of x corresponding to y=1000, by using inverse interpolation, from the given data.
X
3
5
7
9
Y
6
24
58
108

                   Ans : 6139.30475615886

4. Find the age-corresponding to the annuity value 13.6 given 

Age(x)
30
35
40
45
5 0
Annuity value(y)
15.9
14.9
14.1
13.3
12.5

Ans : 43.1418504901961
           
5. The following table gives the value of the probability integral equal to 0.5

X
0.46
0.47
0.48
0.49
F(x)
0.4846555
0.4937452
0.5027498
0.51166833

Ans : 0.476936

6. Apply Lagrange’s formula inversely to obtain the root of the equation f(x)=0,given 
f(30)=-30, f(34)=-13, f(38)=3, f(42)=18.
           Ans : 37.230373
           
7. Apply Lagrange’s inverse interpolation, from the data given below, find the value of x , when y=13.5.    
X
93.0
96.2
100.0
104.2
108.7
Y
11.38
12.80
14.70
17.07
19.91

                      Ans : 97.555746


 Algorithm for Inverse Lagrange interpolation formula--------

 












 Flow chart for Inverse Lagrange Interpolation formula :