Monday, July 31, 2017

How to solve windows license expires

Go to command prompt-->Run as Administrator-->slmgr -rearm-->Enter-->Restart your system..
Now enjoy......

Tuesday, July 25, 2017

Power method for finding the eigen value and the eigen vector using Perl Language

#Power method for finding the eigen value and the eigen vector using Perl Language.........

=comment
    Md. Alamgir Hossain
    Dept. of Computer Science & Engineering
    Jessore University of Science & Technology.
=cut
=comment
First Enter the order of your matrix.......
Now enter the matrix values by row wise one-by-one...
=cut

    print"Enter the order of matrix : \n";
    $n = <>;
    print"Enter matrix elements row-wise one-by-one : \n";
    for($i=1; $i<=$n; $i++)
    {
        for($j=1; $j<=$n; $j++)
        {
            $arr[$i][$j]=<>;
        }
    }
    print"\nOur initial guess for the  column vector is : 1,0,0 for 3 order matrix, 1,0 for 2 order matrix and so on.......\n";
    $x[1] = 1;
    for($k=2; $k<=$n; $k++)
    {
        $x[$k] = 0;
    }
    do
    {
        for($i=1; $i<=$n; $i++)
        {
            $z[$i]=0;
            for($j=1; $j<=$n; $j++)
            {
                $z[$i] = $z[$i]+($arr[$i][$j]*$x[$j]);
            }
        }
        $zmax=abs($z[1]);
        for($i=2; $i<=$n; $i++)
        {
            if((abs($z[$i]))>$zmax){
                $zmax=abs($z[$i]);
                }
        }
        for($i=1; $i<=$n; $i++)
        {
            $z[$i] = $z[$i]/$zmax;
        }
        for($i=1; $i<=$n; $i++)
        {
            $e[$i]=0;
            $e[$i]=abs((abs($z[$i]))-(abs($x[$i])));
        }
        $emax=$e[1];
        for($i=2; $i<=$n; $i++)
        {
            if($e[$i]>$emax){
                $emax=$e[$i];
                }
        }
        for($i=1; $i<=$n; $i++)
        {
            $x[$i]=$z[$i];
        }
    }
    while($emax>0.001);
    print"\n The largest eigen value for the matrix is  : ";
    print "$zmax";
    print"\n\nThe required eigen vector is :\n";
    print "----------------------------------\n";
    for($i=1; $i<=$n; $i++)
    {
        print "$z[$i]\n";
    }
    print "---------------------------------\n";
    print "\n\n";
   
   
=comment
    -----------------------------Input--------------
    3
   
    25
    1
    0
   
    2
    1
    3
   
    3
    6
    2
------------------------------------Output-------------------------
 The largest eigen value for the matrix is  : 25.1021914256925

 The required eigen vector is :
----------------------------------
1
0.10239485477622
0.156370588030618
---------------------------------

=cut

How to write multiple line comment in perl language

#How to write multiple line comment in perl language...........

=comment
Md. Alamgir Hossain
Dept. of Computer Science & Engineering
Jessore University of Science & Technology
=cut
print "Alamgir Hossain,CSE, JUST\n\n";

Saturday, July 22, 2017

Runge Kutta Method implementation using Perl Lamguage

#Alamgir, CSE, JUST
#------------------------------------Start from here............................
#---------Enter the value in this order............
#Enter the value of x0 :
#Enter the value of y0 :
#Inter the value of x(n) :
#If you want to enter the value of h press 1 otherwise press any key....
#If you press 1, you need to Enter the value of h :
#Otherwise it can take the value of h automatically...
#Press 2 for 2nd order, 3 for 3rd order, 4 for 4th order.....

sub func
{
    ($x,$y) = @_;
    #Enter he function{(dy/dx),y1} in here..........
    #return (($x*$x)*($y*$y));
    #return ($x*$y);
    return -$y;
   # $res = ((2*$x*$y)+exp($x))/(($x*$x)+($x*exp($x)));
    #return $res;
}

sub senond_order
{
    ($x,$y) = @_;
    $res1 = $x+$y;
    print"\n\nThe result for Second Order is : $res1\n\n";
}
sub third_order
{
    ($x,$y) = @_;
    $res2 = $x+$y;
    print"\n\nThe result for Third Order is : $res2\n\n";
}
sub fourth_order
{
    ($x,$y) = @_;
    $res3 = $x+$y;
    print"\n\nThe result for Fourth Order is : $res3\n\n";
    print "\n\n";
}


    $h = 0.0;
    print"Enter the value of x0 : \n";
    $x0 = <>;
    print"Enter the value of y0 : \n";
    $y0;
    $y0 = <>;

    print"Inter the value of x(n) : \n";
    $xn = <>;
    print"If you want to enter the value of h press 1 otherwise press any key....\n";

    $pr = <>;
    $h2;
    if($pr==1){
        print"\nEnter the value of h : \n";
        $h2 = <>;
        $h = $h2;
    }
    else{
        $h = $xn-$x0;
    }
  
    $k1,$k2;
    $k1 = $h*&func($x0,$y0);
    $k2 = $h*&func(($x0+($h/2)),($y0+($k1/2)));


    print"Press 2 for 2nd order, 3 for 3rd order, 4 for 4th order.....\n";
    $pv;
    $pv = <>;
    if($pv==2){
        &senond_order($y0,$k2);
    }
     elsif($pv==3){
         $k3 = $h*&func(($x0+$h),($y0+2*$k2-$k1));
         $dh = ($k1 + 4*$k2 + $k3)/6;
        &third_order($y0,$dh);
    }
      elsif($pv==4){
         $k3 = $h*&func(($x0+($h/2)),($y0+($k2/2)));
         $k4 = $h*&func($x0+$h,$y0+$k3);
         $dh = ($k1 + 2*$k2 + 2*$k3 + $k4)/6;

        &fourth_order($y0,$dh);
    }
    else{
        print "\n\nYou should follow/enter the correct value Because your choose number is not correct..\n\n";
    }
   

How to write a function in perl language

#Alamgir Hossain, CSE, JUST

sub bisection
{
$x=@_;
return (($x**3)+(3*$x)-5);
}

$res=&bisection(50);
print $res;

How to write a function that takes two value in perl language

#Alamgir, CSE, JUST

sub function
{
($x,$y) = @_;

return ((2*$x)+23+$y);

}

$res = &function(20,10);
print "Resulr is : $res";

How to use e^x or exp in perl language

#Alamgir, CSE, JUST

$x = 5;

$res  = exp($x);
print "$res\n\n";

How to input and print string with value in perl language


#Alamgir, CSE, JUST
print "Enter the value : \n";
$x = <>;

print "The entered value is : $x\n\n";

If else condition in perl language


#Alamgir, CSE, JUST
$x = 10;

if($x>10){

    print "False\n";
}
elsif($x==10){
    print "Correct\n";
}
else{
    print "Oh!!!!!!\n";
    }

Runge-Kutta method implementation using CPP language for all order


                        ///Runge-Kutta method implementation using CPP.............


/*Md. Alamgir Hossain
Dept. of Computer Science & Engineering.
Jessore University of Science & Technology.
*/
#include<bits/stdc++.h>
using namespace std;

void senond_order(float x,float y)
{
    cout<<"The result for Second Order is : \n"<<(x+y);
}
void third_order(float x,float y)
{
    cout<<"The result for Third Order is : \n"<<(x+y);
}
void fourth_order(float x,float y)
{
    cout<<"The result for Fourth Order is : \n"<<(x+y);
}
float func(float x, float y)
{
    ///Enter he function(dy/dx) in here..........
    //return ((x*x)*(y*y));

    float res = ((2*x*y)+exp(x))/((x*x)+(x*exp(x)));
    return res;
}

int main()
{
    float h = 0.0;
    cout<<"Enter the value of x0 : ";
    float x0;
    cin>>x0;

    cout<<"Enter the value of y0 : ";
    float y0;
    cin>>y0;

    cout<<"Inter the value of x(n) : ";
    float xn;
    cin>>xn;
    cout<<"If you want to enter the value of h press 1 otherwise press any key....";
    float pr;
    cin>>pr;
    float h2;
    if(pr==1){
        cout<<"\nEnter the value of h : ";
        cin>>h2;
        h=h2;
    }
    else{
        h = xn-x0;
    }

    float k1,k2;
    k1 = h*func(x0,y0);
    k2 = h*func((x0+(h/2)),(y0+(k1/2)));


    cout<<"Press 2 for 2nd order, 3 for 3rd order, 4 for 4th order....."<<endl;
    int pv;
    cin>>pv;
    if(pv==2){
        senond_order(y0,k2);
    }
    if(pv==3){
        float k3 = h*func((x0+h),(y0+2*k2-k1));
        float dh = (k1 + 4*k2 + k3)/6;

        third_order(y0,dh);
    }
     if(pv==4){
        float k3 = h*func((x0+(h/2)),(y0+(k2/2)));
        float k4 = h*func(x0+h,y0+k3);
        float dh = (k1 + 2*k2 + 2*k3 + k4)/6;

        fourth_order(y0,dh);
    }

    return 0;
}

Friday, July 21, 2017

Insertion sort algorithm implementation using CPP language


/*Md. Alamgir Hossain
 Dept. of Computer Science & Engineering.
Jessore University of Science & Technology.
 */
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[100];
    int n;
    cout<<"Enter how many numbers you want to sort : "<<endl;
    cin>>n;

    cout<<"Enter "<<n<<" numbers : ";
    for(int i=0;i<n;i++){

        cin>>arr[i];
    }

    for(int j=1;j<n;j++){
        int k=j;

        while(k>0&&arr[k-1]>arr[k]){
            int value = arr[k];
            arr[k] = arr[k-1];
            arr[k-1] = value;
            k--;
        }
    }

    cout<<"Sorted array is : \n\n";
    for(int i=0;i<n;i++){
        cout<<arr[i]<<"\t";
    }

    cout<<"\n\n";
    return 0;
}

///Cpmplexity : o(n^2) && o(n)

Friday, July 7, 2017

Guass Forward Interpolation Formula implementation using perl language

# Md. Alamgir Hossain
#Dept. of Computer Science & Engineering
#Jessore University of Science & Technology

        #-----------------------Guass Forward Interpolation Formula Implementation Using Perl-------------

=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;
 }

$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 "-----------------------------------------------------------\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])){
        $x0 = $x[$i];
        $ii = $i;
        $x1 = $x[$i+1];
        $i2 = $i+1;
    }
}
$p = ($xn-$x0)/($x1-$x0);

$hv = $x1-$x0;

$y0 = $y[0][$ii];
$y1 = $y[1][$ii];
$y2 = $y[2][$ii-1];
$y3 = $y[3][$ii-1];
$y4 = $y[4][$ii-2];
$y5 = $y[5][$ii-2];
$p1 = $p*($p-1);
$p2 = $p1*($p+1);
$p3 = $p2*($p-2);
$p4 = $p3*($p+2);

$f1 = ($p*$y1);
$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";#Needed for Guass forward Difference
print "X is : $xn\n";
print "h is : $hv\n\n";
print "P is : $p\n";
print "\n\nFinal Answer is : $f\n\n\n\n";

Newton Rapson method implementation using perl language

#Md. Alamgir Hossain
#Dept. of Computer Science & Engineering
#Jessore University of Science & Technology


#Newton Rapson method implementation using perl language......


#---------------------------The given function----------------

sub Function
{
  ($x) = @_;

  #Using return keyword you can check your desired function/equation............

  #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;

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 ";
        print "$i";
       
        print " Root is : ";
        print ($h);
        print "\n";
        $x0=$x1;
        $root=$h;
        $ite = $i;
        if($h<.01){
        last;
    }
}  print "\n";
   print "After ";
   print ($ite);
   print " iteration the Approximate Root is : ";
   print ($root);
exit;

Matrix multiplication using cpp language

/*Md. Alamgir Hossain
Dept. of Computer Science & Engineering
Jessore University of Science & Technology

*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,p,q;
    int first[100][100];
    int second[100][100];
    int res[100][100];

    cout<<"Enter first Matrix row and column number : ";
    cin>>m>>n;
    cout<<"\nEnter second Matrix row and column number : ";
    cin>>p>>q;

    if(n!=p){
        cout<<"\nMultiplication is Not possible. Try again with valid row and column number........"<<endl;
    }
    else{
        cout<<"\nMultiplication possible..........."<<endl;
        cout<<"\nEnter first Matrix values : \n";
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                cin>>first[i][j];
            }
        }
        cout<<"\nEnter second Matrix values : \n";
        for(int i=0;i<p;i++){
            for(int j=0;j<q;j++){
                cin>>second[i][j];
            }
        }
        int sum=0;
        for(int i=0;i<m;i++){
            for(int j=0;j<q;j++){
                for(int k=0;k<p;k++){
                    sum=sum+first[i][k]*second[k][j];
                }
                res[i][j]=sum;
                sum=0;
            }
        }
        cout<<"\nResult matrix is : "<<endl;
        for(int i=0;i<m;i++){
            for(int j=0;j<q;j++){
                cout<<res[i][j]<<"\t";
            }
            cout<<endl;
        }
    }
    return 0;
}
/*
Enter first Matrix row and column number : 2 2

Enter second Matrix row and column number : 2 2
Multiplication possible...........

Enter first Matrix values :
4 5
7 8

Enter second Matrix values :
3 5
6 8

Result matrix is :
42      60
69      99

*/