File r34.1/lib/numeric.log artifact a8c591b3cd part of check-in b63c4190d7


REDUCE 3.4.1, 15-Jul-92 ...

1: 
(NUMERIC)


on errcont;


bounds (x,x=(1 .. 2));


1 .. 2

bounds (2*x,x=(1 .. 2));


2 .. 4

bounds (x**3,x=(1 .. 2));


  - 1
------ .. 8
  8

bounds (x*y,x=(1 .. 2),y=(-1 .. 0));


         1
 - 2 .. ---
         2

bounds (x**3+y,x=(1 .. 2),y=(-1 .. 0));


  - 9
------ .. 8
  8

bounds (x**3/y,{x=(1 .. 2),y=(-1 .. -0.5)});


          1
 - 16 .. ---
          4

bounds (x**3/y,x=(1 .. 2),y=(-1 .. -0.5));


          1
 - 16 .. ---
          4

   % unbounded expression (pole at y=0)
bounds (x**3/y,x=(1 .. 2),y=(-1 .. 0.5));


***** unbounded in range 


on rounded;


bounds(e**x,x=(1 .. 2));


2.71828182846 .. 7.38905609893

bounds((1/2)**x,x=(1 .. 2));


0.5 .. 0.25

off rounded;



bounds(abs x,x=(1 .. 2));


1 .. 2

bounds(abs x,x=(-3 .. 2));


0 .. 3

bounds(abs x,x=(-3 .. -2));


2 .. 3


bounds(sin x,x=(1 .. 2));


 - 1 .. 1

 
on rounded;



bounds(sin x,x=(1 .. 2));


0.841470984808 .. 1

bounds(sin x,x=(1 .. 10));


 - 1 .. 1

bounds(sin x,x=(1001 .. 1002));


0.167266541974 .. 0.919990597586


bounds(log x,x=(1 .. 10));


0 .. 2.30258509299


bounds(tan x,x=(1 .. 1.1));


1.55740772465 .. 1.96475965725


bounds(cot x,x=(1 .. 1.1));


0.508968105239 .. 0.642092615934

bounds(asin x,x=(-0.6 .. 0.6));


 - 0.643501108793 .. 0.643501108793

bounds(acos x,x=(-0.6 .. 0.6));


0.927295218002 .. 2.21429743559


bounds(sqrt(x),x=(1 .. 1.1));


1 .. 1.04880884817

bounds(x**(7/3),x=(1 .. 1.1));


1 .. 1.2490589397

bounds(x**y,x=(1 .. 1.1),y=(2 .. 4));


0.870336363636 .. 1.4641

 
off rounded;




% MINIMA  (steepest descent)

% Rosenbrock function (minimum extremely hard to find).
fktn := 100*(x1^2-x2)^2 + (1-x1)^2;


              4         2        2                2
FKTN := 100*X1  - 200*X1 *X2 + X1  - 2*X1 + 100*X2  + 1

num_min(fktn, x1=-1.2, x2=1, accuracy=6);


{0.000000218702240318,{X1=0.999532844964,X2=0.99906807244}}


% infinitely many local minima
num_min(sin(x)+x/5, x=1);


{ - 1.33422674663,{X= - 1.77215430279}}


% bivariate polynomial
num_min(x^4 + 3 x^2 * y + 5 y^2 + x + y, x=0.1, y=0.2);


{ - 0.832523282274,{X= - 0.889601609042,Y= - 0.33989805551}}



% ROOTS (non polynomial: damped Newton)

 num_solve (cos x -x, x=0,accuracy=6);


*** precision increased to 13 

{X=0.739085133385}


   % automatically randomized starting point
num_solve (cos x -x,x, accuracy=6);


{X=0.739085134394}
  
 
   % syntactical errors: forms do not evaluate to purely 
   % numerical values
num_solve (cos x -x, x=a);


***** A invalid as number

num_solve (cos x -a, x=0);


***** A invalid as number

***** error during function evaluation (e.g. singularity) 


num_solve (sin x = 0, x=3);


*** precision increased to 13 

{X=3.1415926533}


  % blows up: no real solution exists
num_solve(sin x = 2, x=1);


***** Newton method does not converge 


  % solution in complex plane(only fond with complex starting point):
on complex;


*** Domain mode ROUNDED changed to COMPLEX-ROUNDED 

num_solve(sin x = 2, x=1+i);


{X=1.5707963268 + 1.31695789692*I}

off complex;


*** Domain mode COMPLEX-ROUNDED changed to ROUNDED 


  % blows up for derivative 0 in starting point 
num_solve(x^2-1, x=0);

***** zero divisor in quotient

***** error during function evaluation (e.g. singularity) 


  % succeeds because of perturbed starting point
num_solve(x^2-1, x=0.1);


{X=1.00000000643}


  % bivariate equation system
num_solve({sin x=cos y, x + y = 1},{x=1,y=2});


{X= - 4.99778688329,Y=5.99778688329}

on evallhseqp;

  % So both sides of equation evaluate.
sub(ws,{sin x=cos y, x + y = 1});


{0.959549703325=0.959549556645,1=1}

 
 
% INTEGRALS
 
num_int( x**2,x=(1 .. 2),accuracy=3);


2.33333333333


   % critical function: almost flat line with one
   % high narrow needle.
needle := 1/(10**-4 + x**2);


                1
NEEDLE := --------------
            2      1
           X  + -------
                 10000

num_int(needle,x=(-1 .. 1),accuracy=3);


312.165724458
           % 312.16

num_int(exp(-x**2),x=(-10 .. 10),accuracy=3);


1.7724717458
     % 1.772

num_int(exp(-x**2),x=(-10**2 .. 10**2));


*** ROUNDBF turned on to increase accuracy 

1.74618555047
         % 1.7461
off roundbf;



   % cases with singularities

num_int(1/sqrt x ,x=(0 .. 1));

***** zero divisor in quotient

requested accuracy cannot be reached within iteration limit

critical area of function near to {X=0.0}

current error estimate: 0.00337429826955

1.99997531551
          % 1.999

num_int(1/sqrt abs x ,x=(-1 .. 1));

***** zero divisor in quotient

requested accuracy cannot be reached within iteration limit

critical area of function near to {X=0.0}

current error estimate: 0.00870788028243

3.99992568283
     % 3.999

   % simple multidimensional integrals
num_int(x+y,x=(0 .. 1),y=(2 .. 3));


3.0


num_int(sin(x+y),x=(0 .. 1),y=(0 .. 1));


0.773147731572


 
% APPROXIMATION
 
  %approximate sin x by a cubic polynomial 
num_fit(sin x,{1,x,x**2,x**3},x=for i:=0:20 collect 0.1*i);


*** precision increased to 15 

                     3                   2
{ - 0.0847539695007*X  - 0.134641944761*X  + 1.06263064633*X

  - 0.00519313406389,

 { - 0.00519313406389,1.06263064633, - 0.134641944761,

   - 0.0847539695007}}

 
  % approximate x**2 by a harmonic series in the interval [0,1]
num_fit(x**2,1 . for i:=1:5 join {sin(i*x), cos(i*x)},
               x=for i:=0:10 collect i/10);


{ - 0.196187855271*SIN(5*X) + 0.874456227951*SIN(4*X)

  - 0.38159923677*SIN(3*X) - 3.3562268088*SIN(2*X)

  + 5.34063539945*SIN(X) - 0.13327743733*COS(5*X)

  + 1.56208432179*COS(4*X) - 5.82407625714*COS(3*X)

  + 9.95627217794*COS(2*X) - 11.0565397235*COS(X) + 5.49553691049,

 {5.49553691049,5.34063539945, - 11.0565397235, - 3.3562268088,9.9562

  7217794, - 0.38159923677, - 5.82407625714,0.874456227951,1.56208432

  179, - 0.196187855271, - 0.13327743733}}

 
  % approximate a set of points by a polynomial
pts:=for i:=1 step 0.1 until 3 collect i$


vals:=for each p in pts collect (p+2)**3$


num_fit(vals,{1,x,x**2,x**3},x=pts);


      3                  2
{1.0*X  + 5.99999999998*X  + 12.0*X + 7.99999999998,{7.99999999998,12

    .0,5.99999999998,1.0}}

first ws - (x+2)**3;


                   3                             2
2.70006239589E-12*X  - 0.0000000000166000546642*X

 + 0.0000000000329993810055*X - 0.0000000000205000461051



 
% ODE SOLUTION (Runge-Kutta)
 
depend(y,x);



   % approximate y=y(x) with df(y,x)=2y in interval [0 : 5]
num_odesolve(df(y,x)=y,y=2,x=(0 .. 5),iterations=20);


{{0.0,2.0},

 {0.25,2.56805083336},

 {0.5,3.29744254135},

 {0.75,4.23400003313},

 {1.0,5.43656365675},

 {1.25,6.98068591465},

 {1.5,8.96337814026},

 {1.75,11.5092053514},

 {2.0,14.778112197},

 {2.25,18.9754716714},

 {2.5,24.3649879195},

 {2.75,31.2852637657},

 {3.0,40.1710738427},

 {3.25,51.5806798292},

 {3.5,66.2309039102},

 {3.75,85.0421639903},

 {4.0,109.196300053},

 {4.25,140.210824675},

 {4.5,180.034262576},

 {4.75,231.168569021},

 {5.0,296.826318159}}

 
   % same with negative direction
num_odesolve(df(y,x)=y,y=2,x=(0 .. -5),iterations=20);


{{0.0,2.0},

 {-0.25,1.55760156616},

 {-0.5,1.21306131944},

 {-0.75,0.944733105504},

 {-1.0,0.735758882366},

 {-1.25,0.573009593743},

 {-1.5,0.446260320318},

 {-1.75,0.34754788692},

 {-2.0,0.27067056649},

 {-2.25,0.210798449139},

 {-2.5,0.164169997261},

 {-2.75,0.127855722424},

 {-3.0,0.0995741367451},

 {-3.25,0.0775484156713},

 {-3.5,0.0603947668512},

 {-3.75,0.0470354917175},

 {-4.0,0.036631277782},

 {-4.25,0.0285284678218},

 {-4.5,0.0222179930796},

 {-4.75,0.0173033904088},

 {-5.0,0.0134758940003}}


   % giving a nice picture when plotted
num_odesolve(df(y,x)=1- x*y**2 ,y=0,x=(0 .. 4),iterations=20);


{{0.0,0.0},

 {0.2,0.199600912185},

 {0.4,0.393714914143},

 {0.6,0.569482634317},

 {0.8,0.710657687321},

 {1.0,0.805480021865},

 {1.2,0.852604290316},

 {1.4,0.860563376499},

 {1.6,0.842333333669},

 {1.8,0.809992008198},

 {2.0,0.772211952477},

 {2.2,0.734163639954},

 {2.4,0.69843323517},

 {2.6,0.66601919664},

 {2.8,0.637070047105},

 {3.0,0.611341375875},

 {3.2,0.588447372816},

 {3.4,0.567985133961},

 {3.6,0.549587947477},

 {3.8,0.53294225579},

 {4.0,0.517787833885}}


end;


Time: 48739 ms  plus GC time: 2601 ms

Quitting


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]