Browse Source

+ Finished chapter on math

michael 25 years ago
parent
commit
9aa513e58c

+ 2 - 2
docs/mathex/Makefile

@@ -35,8 +35,8 @@ endif
 OBJECTS=ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 \
         ex11 ex12 ex13 ex14 ex15 ex16 ex17 ex18 ex19 ex20 \
         ex21 ex22 ex23 ex24 ex25 ex26 ex27 ex28 ex29 ex30 \
-        ex31 ex32 ex33 ex34 
-# ex25 ex26 ex27 ex28 ex29 ex30 \
+        ex31 ex32 ex33 ex34 ex35 ex36 ex37 ex38 ex39 ex40 \
+        ex41 ex42 ex43 ex44 ex45 ex46 ex47 ex48 ex49 ex50
 
 TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
 

+ 16 - 0
docs/mathex/README

@@ -36,3 +36,19 @@ ex31.pp contains an example of the MinValue function.
 ex32.pp contains an example of the momentskewkurtosis function.
 ex33.pp contains an example of the norm function.
 ex34.pp contains an example of the power function.
+ex35.pp contains an example of the popnstddev function.
+ex36.pp contains an example of the popnvariance function.
+ex37.pp contains an example of the radtocycle function.
+ex38.pp contains an example of the radtodeg function.
+ex39.pp contains an example of the radtograd function.
+ex40.pp contains an example of the randg function.
+ex41.pp contains an example of the sincos function.
+ex42.pp contains an example of the sinh function.
+ex43.pp contains an example of the stddev function.
+ex44.pp contains an example of the sum function.
+ex45.pp contains an example of the sumofsquares function.
+ex46.pp contains an example of the sumsandsquares function.
+ex47.pp contains an example of the Tan function.
+ex48.pp contains an example of the Tanh function.
+ex48.pp contains an example of the TotalVariance function.
+ex50.pp contains an example of the Variance function.

+ 22 - 0
docs/mathex/ex35.pp

@@ -0,0 +1,22 @@
+Program Example35;
+
+{ Program to demonstrate the PopnStdDev function. }
+
+Uses Math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  Writeln('Max              : ',MaxValue(ExArray):8:4);  
+  Writeln('Min              : ',MinValue(ExArray):8:4);  
+  Writeln('Pop. stddev.     : ',PopnStdDev(ExArray):8:4);  
+  Writeln('Pop. stddev. (b) : ',PopnStdDev(@ExArray[1],100):8:4);  
+end.

+ 22 - 0
docs/mathex/ex36.pp

@@ -0,0 +1,22 @@
+Program Example36;
+
+{ Program to demonstrate the PopnVariance function. }
+
+Uses math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  Writeln('Max           : ',MaxValue(ExArray):8:4);  
+  Writeln('Min           : ',MinValue(ExArray):8:4);  
+  Writeln('Pop. var.     : ',PopnVariance(ExArray):8:4);  
+  Writeln('Pop. var. (b) : ',PopnVariance(@ExArray[1],100):8:4);  
+end.

+ 11 - 0
docs/mathex/ex37.pp

@@ -0,0 +1,11 @@
+Program Example37;
+
+{ Program to demonstrate the radtocycle function. }
+
+Uses math;
+
+begin
+  writeln(radtocycle(2*pi):8:6);
+  writeln(radtocycle(pi):8:6);
+  writeln(radtocycle(pi/2):8:6);
+end.

+ 11 - 0
docs/mathex/ex38.pp

@@ -0,0 +1,11 @@
+Program Example38;
+
+{ Program to demonstrate the radtodeg function. }
+
+Uses math;
+
+begin
+  writeln(radtodeg(2*pi):8:6);
+  writeln(radtodeg(pi):8:6);
+  writeln(radtodeg(pi/2):8:6);
+end.

+ 11 - 0
docs/mathex/ex39.pp

@@ -0,0 +1,11 @@
+Program Example39;
+
+{ Program to demonstrate the radtograd function. }
+
+Uses math;
+
+begin
+  writeln(radtograd(2*pi):8:6);
+  writeln(radtograd(pi):8:6);
+  writeln(radtograd(pi/2):8:6);
+end.

+ 22 - 0
docs/mathex/ex40.pp

@@ -0,0 +1,22 @@
+Program Example40;
+
+{ Program to demonstrate the randg function. }
+
+Uses Math;
+
+Type
+  TExArray = Array[1..10000] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+  Mean,stddev : Float;
+    
+begin
+  Randomize;
+  for I:=1 to 10000 do 
+    ExArray[i]:=Randg(1,0.2);
+  MeanAndStdDev(ExArray,Mean,StdDev);
+  Writeln('Mean       : ',Mean:8:4);  
+  Writeln('StdDev     : ',StdDev:8:4);  
+end.

+ 25 - 0
docs/mathex/ex41.pp

@@ -0,0 +1,25 @@
+Program Example41;
+
+{ Program to demonstrate the sincos function. }
+
+Uses math;
+
+Procedure dosincos(Angle : Float);
+
+Var 
+  Sine,Cosine : Float;
+
+begin
+  sincos(angle,sine,cosine);
+  Write('Angle : ',Angle:8:6);
+  Write(' Sine :',sine:8:6);
+  Write(' Cosine :',cosine:8:6);
+end;
+
+begin
+  dosincos(pi);
+  dosincos(pi/2);
+  dosincos(pi/3);
+  dosincos(pi/4);
+  dosincos(pi/6);
+end.

+ 11 - 0
docs/mathex/ex42.pp

@@ -0,0 +1,11 @@
+Program Example42;
+
+{ Program to demonstrate the sinh function. }
+
+Uses math;
+
+begin
+  writeln(sinh(0));
+  writeln(sinh(1));
+  writeln(sinh(-1));
+end.

+ 20 - 0
docs/mathex/ex43.pp

@@ -0,0 +1,20 @@
+Program Example40;
+
+{ Program to demonstrate the stddev function. }
+
+Uses Math;
+
+Type
+  TExArray = Array[1..10000] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+    
+begin
+  Randomize;
+  for I:=1 to 10000 do 
+    ExArray[i]:=Randg(1,0.2);
+  Writeln('StdDev     : ',StdDev(ExArray):8:4);  
+  Writeln('StdDev (b) : ',StdDev(@ExArray[0],10000):8:4);  
+end.

+ 22 - 0
docs/mathex/ex44.pp

@@ -0,0 +1,22 @@
+Program Example44;
+
+{ Program to demonstrate the Sum function. }
+
+Uses math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  Writeln('Max     : ',MaxValue(ExArray):8:4);  
+  Writeln('Min     : ',MinValue(ExArray):8:4);  
+  Writeln('Sum     : ',Sum(ExArray):8:4);  
+  Writeln('Sum (b) : ',Sum(@ExArray[1],100):8:4);  
+end.

+ 22 - 0
docs/mathex/ex45.pp

@@ -0,0 +1,22 @@
+Program Example45;
+
+{ Program to demonstrate the SumOfSquares function. }
+
+Uses math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  Writeln('Max             : ',MaxValue(ExArray):8:4);  
+  Writeln('Min             : ',MinValue(ExArray):8:4);  
+  Writeln('Sum squares     : ',SumOfSquares(ExArray):8:4);  
+  Writeln('Sum squares (b) : ',SumOfSquares(@ExArray[1],100):8:4);  
+end.

+ 27 - 0
docs/mathex/ex46.pp

@@ -0,0 +1,27 @@
+Program Example45;
+
+{ Program to demonstrate the SumOfSquares function. }
+
+Uses math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+  s,ss : float;
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  Writeln('Max             : ',MaxValue(ExArray):8:4);  
+  Writeln('Min             : ',MinValue(ExArray):8:4);  
+  SumsAndSquares(ExArray,S,SS);
+  Writeln('Sum             : ',S:8:4);  
+  Writeln('Sum squares     : ',SS:8:4);  
+  SumsAndSquares(@ExArray[1],100,S,SS);
+  Writeln('Sum (b)         : ',S:8:4);  
+  Writeln('Sum squares (b) : ',SS:8:4);  
+end.

+ 20 - 0
docs/mathex/ex47.pp

@@ -0,0 +1,20 @@
+Program Example47;
+
+{ Program to demonstrate the Tan function. }
+
+Uses math;
+
+Procedure DoTan(Angle : Float);
+
+begin
+  Write('Angle : ',RadToDeg(Angle):8:6);
+  Writeln(' Tangent : ',Tan(Angle):8:6);
+end;
+
+begin
+  DoTan(0);
+  DoTan(Pi);
+  DoTan(Pi/3);
+  DoTAn(Pi/4);
+  DoTan(Pi/6);
+end.

+ 11 - 0
docs/mathex/ex48.pp

@@ -0,0 +1,11 @@
+Program Example48;
+
+{ Program to demonstrate the Tanh function. }
+
+Uses math;
+
+begin
+  writeln(tanh(0));
+  writeln(tanh(1));
+  writeln(tanh(-1));
+end.

+ 23 - 0
docs/mathex/ex49.pp

@@ -0,0 +1,23 @@
+Program Example49;
+
+{ Program to demonstrate the TotalVariance function. }
+
+Uses math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+  TV : float;
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  TV:=TotalVariance(ExArray);
+  Writeln('Total variance     : ',TV:8:4);  
+  TV:=TotalVariance(@ExArray[1],100);
+  Writeln('Total Variance (b) : ',TV:8:4);  
+end.

+ 23 - 0
docs/mathex/ex50.pp

@@ -0,0 +1,23 @@
+Program Example50;
+
+{ Program to demonstrate the Variance function. }
+
+Uses math;
+
+Type
+  TExArray = Array[1..100] of Float;
+    
+Var
+  I : Integer;
+  ExArray : TExArray; 
+  V : float;
+    
+begin
+  Randomize;
+  for I:=1 to 100 do 
+    ExArray[i]:=(Random-Random)*100;
+  V:=Variance(ExArray);
+  Writeln('Variance     : ',V:8:4);  
+  V:=Variance(@ExArray[1],100);
+  Writeln('Variance (b) : ',V:8:4);  
+end.