Monday, April 30, 2018

Gauss Elimination Method


a11x1  +  a12x2 +  a13 x3      = b1
a21x1  +  a22x2 + a23x3        =b2
a31x1  + a32x2  + a33x3        =b3

[a11         a12         a13]   [x1]        [b1]
[a21             a22       a23]   [x2]    =  [b2]
[a31         a32         a33]   [x3]        [b3]

To  eliminate coefficient of x1 from 2nd and 3rd Row Recursive formula :-

[ Riai1 × Ri                    for [ I = 2 & 3]
        a11

[a11        a12          a13]  [x1]         [b1]
[a21        a22          a23]  [x2]    =   [b2]
[a31        a32          a33]  [x3]          [b3]

To eliminate coefficients of x2 from 3rd row
[Riai2 × R2]
       a22

Ques:-
           2x1  +  2x2  +  2x3  =  14
              x1  +  6x2   -    x3  =  13
             2x1  -   x2   +  2x3  =   5
Sol:-

To eliminate coefficient of x1 from 2nd and 3rd row.

For |i=2|
            R2a21 ×  R1
                   a11

  a21 = a211 × a11
                      2
         = 1 – 1 × 2
                 2
|a21=0|

a22= a22a21 × a12
               a11

   = 6 – 1 × 8
           2

|a22 = 2|

a23= a23 × a21  × a13
               a11

      = - 1 – 1 × 2
                2
|a23=- 2|

[2      8        2] [x1]        [14]
[0       2     -2]  [x2]   =   [13]
[2      -1      2]  [x3]        [5]

For |i = 3|

        R3a31 × R1
              a11

a31 = a31 a31 × a11
                 a11

      = 2 – 2 × 2
              2
|a31 = 0|

a32 = a32a31 × a12
                a11

       = - 1 – (-1) × 8
                   2
|a32= -9|

a33 = a33 a31 × a13
                 a11

       = 2 – 2  × 2
               2
|a33=0|

b3 = b3a31 × b1  => 5 – 2 ×14
             a11                  2 
                     
     = 5 – 14

|b3= -9|

[2       8        2]  [x1]        [14]
[0       2       -2]  [x2]   =   [ 6 ]
[0      -9        6]  [x3]        [-9]
To eliminate x2 from 3rd row.

| Ri ai2 × R2 |
          a22

for |i = 3|

       R3 a32 × R2
              a22
 a32 = a32 a32 × a22
                  a22

        = - 9 – (-9) × 2
                   2
|a32=0|

a33 = a33 a32 × a23
                 a22

      = 0 – (-9) ×(-2)
                2
|a33= - 9|

b3 = b3a32  × b2
             a22

     = - 9 – (-9) × 6
                 2

     = -9 – (-27)

|b3= 18|

[2       8        2]  [x1]       [14]
[0       2       -2]  [x2]  =   [ 6 ]
[0       0       -9]  [x3]       [18]

-       9x3 = 18
  x3 = - 18
            9
|x3= 2|

  2x2 + (2x3)  = 6
  2x2 – 2x3     = 6
    x2x3       = 3
           x2      = 3 – 2

|x2 = 1|

2x1   +   8x2   +   2x3   =   14
2x1   +  8(1)  +   2(-2)=   14
2x1   =  14 – 8 + 4
   x1  = 10
            2
|x1 = 5|

[x1 = 5   ,   x2 = 1   ,   x3 = -2 ]

Sunday, April 29, 2018

Newton Rapshon Method


Formula:-

          x = xn –  f(xn)
                          f '(xn')

Ques.1:-
              x2 – 5x + 2
           f(x) = x2 – 5x + 2
           f '(x) = 2x – 5

           x0 = 0 – 0 + 2 = 2                       (+ ve)
           x1 = 1 – 5 + 2 = -4 +2 = - 2        (- ve)

so a root of f(x)=0 , lies b/w 0 and 1.

So, the mid value in 0 and 1 is 0.5
  
          So,
                  x0 = 0.5 

1st        

      x1 = x0 – f(x0)
                        f '(x0)

             = 0.5 – (0.5)2 – 5(0.5) + 2
                                2(0.5) – 5 

       [x1 = 0.4375]

2nd
        x2 = x1 – f(x1)
                          f '(x1)

              = 0.4375 – (0.4375)2 – 5(0.4375) + 2
                                       2(0.4375) – 5

              =0.4375  –  0.191406 – 2.1875 + 2
                                          0.875 – 5

              =0.4375 – 0.0039
                               -4.125
  
              =0.437 + 0.00094

         [x2= 0.4379]

Clearly, x1 = x2   . Hence the required root is 0.437


Saturday, April 28, 2018

Secant Method


 Que:- x3 = 5x + 1

  x2 = x1 – [x1 – x0       ]  f(x1)
                        f(x1) – f(x0)

Sol:-
       f(0)= 0 - 0 +1 = 1
       f(1)= 1 - 5 + 1= -3

Ist
  x0 = 0             ,            f(x0) = 1
  x1 = 1              ,            f(x1) = - 3

x2 = x1 – [x1 – x0       ]  f(x1)
                f(x1) – f(x0)
  
= 1 – [ 1 – 0    ] – 3                         
           -3 – 1

= 1 – [ -3 ]
          -4
x2= 1 – 3  = 1 – 0.75 = 0.25
           4
|x2= 0.25|
F(x2) = (0.25)3 – 5(0.25) + 1
         = 0.015625 – 1.25 + 1
|f(x2)= - 0.234375|

2nd

x3 = x2 – [x2 – x1       ]  f(x2)
               f(x2) – f(x1)

x2 = 0.25      ,         f(x2) = - 0.234
x1 = 1           ,          f(x1)= - 3

x3 =  0.25 – [ 0.25 – 1 ] (-0.234)
                  -0.234 – (-3)

= 0.25 – [- 0.75] (-0.234)
               2.766

= 0.25 – [0.1755]
                2.766

x3 = 0.25 – 0.06344=0.18656

     |x3 = 0.18656|

f(x3) = (0.18656)3 – 5(0.18656) + 1

         = 6.4900 – 0.93265 + 1

|f(x3) = 6.55735|

3rd
    x4 = x3 – [x3 – x2       ]  f(x3)
                        f(x3) – f(x2)

x3= 0.18656    , f(x3)= 6.55735
x2 = 0.25         , f(x2) = -0.234

x4 = 0.18656 – [0.18656 – 0.25] (6.55735)
                         6.55734 + 0.234

     = 0.18656 – [-0.06344](6.55735)
                            6.79135
   
     = 0.18656 – [-0.4159]
                            6.7913

     = 0.18656 + 0.06124

|x4 = 0.2478|

f(x4) = (0.024978)3 – 5(0.2478) + 1
         = 0.015216 – 1.239 + 1
|f(x4) = -0.223784|

4th

   x5 = x4 – [x4 – x3       ]  f(x4)
                     f(x4) – f(x3)

x4 = 0.2478      ,     f(x4) = -0.223784
x3 = 0.18656    ,     f(x3) = 6.5573

x5 = 0.2478 – [0.2478 – 0.18656] (-0.2237)
                        -0.2237 – 6.5573

     = 0.2478 – [- 0.01369]
                        -6.781

     = 0.2478 – 2.01887

|x5 = -1.77107|
                                                       and so on …..





Friday, April 27, 2018

Program Of bisection Method


# include <stdio.h>
# include <conio.h>
#include  < math.h>
# include <process.h>
#include <string.h>

# define EPS  0.00000005
# define  f(x)     x3 – x – 1
   void  Bisect ()
   int count  = 1 , n
   float root = 1;
  void main ()
  {
     clrscr (),
   priftf(“\n solution by Bisection method\n”);
    printf(“Equation”);
    printf(“\n\t\t\t x3 –x – 1 =0 \n\n”)
    printf(“Enter the no. of iteration:”);
    scanf(“%d”,&n);
    Bisect ();
    getch ();
 }
     void Bisect ()
 {
      float x0, x1, x2 ;
      float f0, f1, f2 ;
      int I =0 ;
     for (x2 = 1; x2++)
{
     f2  =  f(x2);
     if (f2 < 0);
     {
         Break ;
      }
}
     printf(“\n\t\t_ _ _ _ _ _ _ _ _ _ _ _ _”);
     printf(“\n\t\t   Root  = %  f ”,x0);
     printf(“\n\t\t  ITERATION = %d\n”, count -1 );
      printf(“\t\t_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ”);
      getch();
}

         Algorithm of Bisection Method
Step1:- Start of the program.
Step2:- I/P the various x1, x2, for the task.
Step3:- Check f(x1) * f(x2) < 0
Step4:- If yes proceed.
Step5:- If no exit & print error message.
Step6:- Repeat 7 – 11 if condition not satisfied.
Step7:-  x0= (x1 + x2)/2
Step8:- if f(x0) * f(x1) < 0
Step9:- x2 = x0
Step10:- ELSE
Step11:-   x1 = x0
Step12:-   Condition
Step13:- |(x1 – x2 ) /x1 | < max. possible error or f(x0) = 0.
Step14:-    printf o/p
Step15 :-   End of program.


Thursday, April 26, 2018

Find the relative percentage error in an error representation of/ by 1.33


Sol:
epTrue value – approx. value × 100

                     True value
True value = 4
                   3
Approx. value= 1.33

So,

True value – approx. value
     = 4 – 1.33
        3
     = 0.0033
So,

  ep0.0033 × 100
         1.3333
      = 0.249975

2. add .4327 E 7 and .0048 E 8
Sol:- 
   =   .4327 E 7 and.0048 E 8
   = .04327 E 8 and .0048 E 8
   = 0.0048 E 8 

3. subtract .8756 E-3 from .4492 E -9  
Sol:- 
       = .8756 E -3 from .0044 E -3
                   = .8712 E -3 

4. Division .6259 E 12 ÷ .0018 E 6
Sol:- 
 = .6259 E12-6
      .0018 E
   = .6259 E6
      .0018
      = 347.72 E 6
         = .34772 E 9

5. Multiplication .9999 E -99 and .1148 E 96
Sol:-
   =  .9999 × .1148 E-94+96

        = 0.1147 E +2