Sponsored links: Algebra eBooks
 

Related

quit

Run Example
(%i1)radexpand:all;
(%o1)                                 all
(%i2) besselexpand:true;
(%o2)                                true
(%i3) assume (q>
0);
(%o3)                               [q > 0]
(%i4) assume (hbarc>
0);
(%o4)                             [hbarc > 0]
(%i5) assume(ce>
0);
(%o5)                              [ce > 0]
(%i6) k:q/hbarc;
                                       q
(%o6)                                -----
                                     hbarc
(%i7) v(r):= r/(r**4+ce);
                                           r
(%o7)                           v(r) := -------
                                         4
                                        r  + ce
(%i8) f(r):=r**(3/2)*v(r)*bessel_j(1/2,k*r);
                               3/2               1
(%o8)                 f(r) := r    v(r) bessel_j(-, k r)
                                                 2
(%i9) r0:integrate(f(r),r,0,inf);
                                        inf  2      q r
                                       /    r  sin(-----)
                                       [           hbarc
                   sqrt(2) sqrt(hbarc) I    ------------- dr
                                       ]        4
                                       /       r  + ce
                                        0
(%o9)              -----------------------------------------
                               sqrt(%pi) sqrt(q)
(%i10) res:r0/(2*%pi)**(3/2)/hbarc**(5/2)/q**(1/2);
                              inf  2      q r
                             /    r  sin(-----)
                             [           hbarc
                             I    ------------- dr
                             ]        4
                             /       r  + ce
                              0
(%o10)                       ---------------------
                                     2      2
                                2 %pi  hbarc  q
(%i11)                                                                                                                                                                                                                                                                                        rex:factor(res);
                              inf  2      q r
                             /    r  sin(-----)
                             [           hbarc
                             I    ------------- dr
                             ]        4
                             /       r  + ce
                              0
(%o11)                       ---------------------
                                     2      2
                                2 %pi  hbarc  q
(%i12)                                                                                                                                                                           print(" V(r)=",v(r));
          r
 V(r)= ------- 
        4
       r  + ce
                                       r
(%o12)                              -------
                                     4
                                    r  + ce
(%i13)                                                                         print("         ");
          
(%o13)                                      
(%i14) print(" V(q)=",rex);
        inf  2      q r
       /    r  sin(-----)
       [           hbarc
       I    ------------- dr
       ]        4
       /       r  + ce
        0
 V(q)= --------------------- 
               2      2
          2 %pi  hbarc  q
                              inf  2      q r
                             /    r  sin(-----)
                             [           hbarc
                             I    ------------- dr
                             ]        4
                             /       r  + ce
                              0
(%o14)                       ---------------------
                                     2      2
                                2 %pi  hbarc  q
(%i15) quit();
Run Example
n: 18;
(%o1)                                 18
(%i2) g:for i from 2 thru n-1 do (if (mod(n,i)<
1) then (print(0),quit(g)) else print(1));
0 
Run Example
/*Name: GEROME P. MASIGLATSection: EF-2LCourse/College: BSCS/CASDate: July 31, 2013Exercise #4*//*GIVEN*/f(x):= x^6 - 7*(x^4) + 15*(x^2) - 9;
                                  6      4       2
(%o1)                    f(x) := x  - 7 x  + 15 x  - 9
(%i2) macheps:1;
(%o2)                                  1
(%i3) x0: 1.3;
(%o3)                                 1.3
(%i4) 	x1: 1.4;
(%o4)                                 1.4
(%i5) x2: 1.5;
(%o5)                                 1.5
(%i6) /*FOR THE FIRST ITERATION*/i:1;
(%o6)                                  1
(%i7) h0 : x1 - x0;
(%o7)                                 0.1
(%i8) h1 : x2 - x1;
(%o8)                                 0.1
(%i9) d0: (f(x1)-f(x0))/h0;
(%o9)                         - 1.457729999999986
(%i10) d1: (f(x2)-f(x1))/h1;
(%o10)                        - 3.352110000000007
(%i11) a: (d1-d0)/(h1+h0);
(%o11)                        - 9.47190000000011
(%i12) b: a*h1+d1;
(%o12)                        - 4.299300000000019
(%i13) c: f(x2);
(%o13)                             0.703125
(%i14) d: sqrt(b^2-4*a*c);
(%o14)                         6.717417602025385
(%i15) if abs(b-d)<
abs(b+d) then d:abs(d) else d:-(abs(d));
(%o15)                        - 6.717417602025385
(%i16) x3: x2+(-2*c/(b+d));
(%o16)                         1.627646913608956
(%i17) ea: abs((x3-x2)/x3)*100;
(%o17)                         7.84242040099018
(%i18) display("i	x1	x2	x3	h0	h1	d0	d1	a	b	c	d	ea");
     i	x1	x2	x3	h0	h1	d0	d1	a	b	c	d	ea = i	x1	x2	x3	h0	h1	d0	d1	a	b	c	d	ea

(%o18)                               done
(%i19) /*Displays the values of iteration count 1*/display(i,	x0,	x1,	x2,	x3,	h0,	h1,	d0,	d1,	a,	b,	c,	d, ea);
                                     i = 1

                                   x0 = 1.3

                                   x1 = 1.4

                                   x2 = 1.5

                            x3 = 1.627646913608956

                                   h0 = 0.1

                                   h1 = 0.1

                           d0 = - 1.457729999999986

                           d1 = - 3.352110000000007

                            a = - 9.47190000000011

                            b = - 4.299300000000019

                                 c = 0.703125

                            d = - 6.717417602025385

                             ea = 7.84242040099018

(%o19)                               done
(%i20) /*FOR THE NEXT ITERATIONS*/for i:2 while ea>
macheps do (	x0: x1,	x1: x2,	x2: x3,			/*COMPUTES THE NEEDED VALUES*/	h0:x1 - x0,	h1:x2 - x1,	d0: (f(x1)-f(x0))/h0,	d1: (f(x2)-f(x1))/h1,	a: (d1-d0)/(h1+h0),	b: a*h1+d1,	c: f(x2),	d: sqrt(b^2-4*a*c),	if abs(b-d)<
abs(b+d) then d:abs(d) else d:-(abs(d)),	x3: x2+(-2*c/(b+d)),	ea: abs((x3-x2)/x3)*100,		/*IF THE EXACT ROOT IS FOUND*/	if f(x3)=0 then (display(x3), quit()), 	/*PRINTS THE VALUES FOR THE CURRENT ITERATION*/	display(i,	x0,	x1,	x2,	x3,	h0,	h1,	d0,	d1,	a,	b,	c,	d,	ea)		 );
                                     i = 2

                                   x0 = 1.4

                                   x1 = 1.5

                            x2 = 1.627646913608956

                            x3 = 1.674268288983182

                                   h0 = 0.1

                             h1 = 0.12764691360896

                           d0 = - 3.352110000000007

                           d1 = - 3.918692786298668

                            a = - 2.488866540364861

                            b = - 4.236388918560841

                              c = 0.2029159604473

                            d = - 4.468457681030245

                            ea = 2.784582117513574

                                     i = 3

                                   x0 = 1.5

                            x1 = 1.627646913608956

                            x2 = 1.674268288983182

                            x3 = 1.703487504703645

                             h0 = 0.12764691360896

                            h1 = 0.046621375374226

                           d0 = - 3.918692786298668

                           d1 = - 2.854063122053562

                             a = 6.109141660005908

                            b = - 2.569246535508104

                             c = 0.069855612292301

                            d = - 2.212237879446948

                             ea = 1.71525858803091

                                     i = 4

                            x0 = 1.627646913608956

                            x1 = 1.674268288983182

                            x2 = 1.703487504703645

                            x3 = 1.720047222933731

                            h0 = 0.046621375374226

                            h1 = 0.029219215720463

                           d0 = - 2.854063122053562

                            d1 = - 1.76395713952306

                             a = 14.37364829039212

                            b = - 1.343970409436033

                             c = 0.018314168110926

                            d = - 0.86792327818154

                             ea = 0.96274788327273

(%o20)                               done
(%i21) /*PRINTS THE APPROXIMATE ROOT*/display("APPROXIMATE ROOT:", x3);
                     APPROXIMATE ROOT: = APPROXIMATE ROOT:

                            x3 = 1.720047222933731

(%o21)                               done
(%i22) 

Related Help

Help for Quit