mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 11:24:16 +01:00 
			
		
		
		
	+ Added examples 25-34
This commit is contained in:
		
							parent
							
								
									aa3e0fbe87
								
							
						
					
					
						commit
						03cae6836f
					
				@ -34,8 +34,9 @@ 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 
 | 
			
		||||
# 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 \
 | 
			
		||||
 | 
			
		||||
TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -26,3 +26,13 @@ ex21.pp contains an example of the log10 function.
 | 
			
		||||
ex22.pp contains an example of the log2 function.
 | 
			
		||||
ex23.pp contains an example of the logn function.
 | 
			
		||||
ex24.pp contains an example of the max function.
 | 
			
		||||
ex25.pp contains an example of the MaxIntValue function.
 | 
			
		||||
ex26.pp contains an example of the MaxValue function.
 | 
			
		||||
ex27.pp contains an example of the Mean function.
 | 
			
		||||
ex28.pp contains an example of the MeanAndStdDevfunction.
 | 
			
		||||
ex29.pp contains an example of the min function.
 | 
			
		||||
ex30.pp contains an example of the MinIntValue function.
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								docs/mathex/ex25.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								docs/mathex/ex25.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
Program Example25;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the MaxIntValue function. }
 | 
			
		||||
 | 
			
		||||
{ Make sore integer is 32 bit}
 | 
			
		||||
{$mode objfpc}
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
  TExArray = Array[1..100] of Integer;
 | 
			
		||||
  
 | 
			
		||||
Var
 | 
			
		||||
  I : Integer;
 | 
			
		||||
  ExArray : TExArray; 
 | 
			
		||||
    
 | 
			
		||||
begin
 | 
			
		||||
  Randomize;
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExArray[i]:=Random(I)-Random(100);
 | 
			
		||||
  Writeln(MaxIntValue(ExArray));  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										32
									
								
								docs/mathex/ex26.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								docs/mathex/ex26.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
			
		||||
Program Example26;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the MaxValue function. }
 | 
			
		||||
 | 
			
		||||
{ Make sore integer is 32 bit}
 | 
			
		||||
{$mode objfpc}
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
  TExFloatArray = Array[1..100] of Float;
 | 
			
		||||
  TExIntArray = Array[1..100] of Integer;
 | 
			
		||||
    
 | 
			
		||||
Var
 | 
			
		||||
  I : Integer;
 | 
			
		||||
  ExFloatArray : TExFloatArray; 
 | 
			
		||||
  ExIntArray : TExIntArray; 
 | 
			
		||||
  AFLoatArray : PFLoat;
 | 
			
		||||
  AIntArray : PInteger;    
 | 
			
		||||
begin
 | 
			
		||||
  Randomize;
 | 
			
		||||
  AFloatArray:=@ExFloatArray[1];
 | 
			
		||||
  AIntArray:=@ExIntArray[1];
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExFloatArray[i]:=(Random-Random)*100;
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExIntArray[i]:=Random(I)-Random(100);
 | 
			
		||||
  Writeln('Max Float       : ',MaxValue(ExFloatArray):8:4);  
 | 
			
		||||
  Writeln('Max Float   (b) : ',MaxValue(AFloatArray,100):8:4);
 | 
			
		||||
  Writeln('Max Integer     : ',MaxValue(ExIntArray):8);  
 | 
			
		||||
  Writeln('Max Integer (b) : ',MaxValue(AIntArray,100):8);  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										22
									
								
								docs/mathex/ex27.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								docs/mathex/ex27.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
Program Example27;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the Mean 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('Mean     : ',Mean(ExArray):8:4);  
 | 
			
		||||
  Writeln('Mean (b) : ',Mean(@ExArray[1],100):8:4);  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										25
									
								
								docs/mathex/ex28.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								docs/mathex/ex28.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
Program Example28;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the Meanandstddev function. }
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
  TExArray = Array[1..100] of Extended;
 | 
			
		||||
    
 | 
			
		||||
Var
 | 
			
		||||
  I : Integer;
 | 
			
		||||
  ExArray : TExArray; 
 | 
			
		||||
  Mean,stddev : Extended;
 | 
			
		||||
    
 | 
			
		||||
begin
 | 
			
		||||
  Randomize;
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExArray[i]:=(Random-Random)*100;
 | 
			
		||||
  MeanAndStdDev(ExArray,Mean,StdDev);
 | 
			
		||||
  Writeln('Mean       : ',Mean:8:4);  
 | 
			
		||||
  Writeln('StdDev     : ',StdDev:8:4);  
 | 
			
		||||
  MeanAndStdDev(@ExArray[1],100,Mean,StdDev);
 | 
			
		||||
  Writeln('Mean   (b) : ',Mean:8:4);  
 | 
			
		||||
  Writeln('StdDev (b) : ',StdDev:8:4);  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										13
									
								
								docs/mathex/ex29.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								docs/mathex/ex29.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
			
		||||
Program Example29;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the min function. }
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Var 
 | 
			
		||||
  A,B : Cardinal;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  A:=1;b:=2;
 | 
			
		||||
  writeln(min(a,b));
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										22
									
								
								docs/mathex/ex30.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								docs/mathex/ex30.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
Program Example30;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the MinIntValue function. }
 | 
			
		||||
 | 
			
		||||
{ Make sore integer is 32 bit}
 | 
			
		||||
{$mode objfpc}
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
  TExArray = Array[1..100] of Integer;
 | 
			
		||||
  
 | 
			
		||||
Var
 | 
			
		||||
  I : Integer;
 | 
			
		||||
  ExArray : TExArray; 
 | 
			
		||||
    
 | 
			
		||||
begin
 | 
			
		||||
  Randomize;
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExArray[i]:=Random(I)-Random(100);
 | 
			
		||||
  Writeln(MinIntValue(ExArray));  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										33
									
								
								docs/mathex/ex31.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								docs/mathex/ex31.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
Program Example26;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the MinValue function. }
 | 
			
		||||
 | 
			
		||||
{ Make sore integer is 32 bit}
 | 
			
		||||
{$mode objfpc}
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
  TExFloatArray = Array[1..100] of Float;
 | 
			
		||||
  TExIntArray = Array[1..100] of Integer;
 | 
			
		||||
    
 | 
			
		||||
Var
 | 
			
		||||
  I : Integer;
 | 
			
		||||
  ExFloatArray : TExFloatArray; 
 | 
			
		||||
  AFloatArray : PFloat;
 | 
			
		||||
  ExIntArray : TExIntArray; 
 | 
			
		||||
  AintArray : PInteger;
 | 
			
		||||
    
 | 
			
		||||
begin
 | 
			
		||||
  Randomize;
 | 
			
		||||
  AFloatArray:=@ExFloatArray[0];
 | 
			
		||||
  AIntArray:=@ExIntArray[0];
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExFloatArray[i]:=(Random-Random)*100;
 | 
			
		||||
  for I:=1 to 100 do 
 | 
			
		||||
    ExIntArray[i]:=Random(I)-Random(100);
 | 
			
		||||
  Writeln('Min Float       : ',MinValue(ExFloatArray):8:4);  
 | 
			
		||||
  Writeln('Min Float   (b) : ',MinValue(AFloatArray,100):8:4);
 | 
			
		||||
  Writeln('Min Integer     : ',MinValue(ExIntArray):8);  
 | 
			
		||||
  Writeln('Min Integer (b) : ',MinValue(AintArray,100):8);  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										24
									
								
								docs/mathex/ex32.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								docs/mathex/ex32.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
Program Example32;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the momentskewkurtosis function. }
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Var 
 | 
			
		||||
  DistArray : Array[1..1000] of float;
 | 
			
		||||
  I : longint;
 | 
			
		||||
  m1,m2,m3,m4,skew,kurtosis : float;
 | 
			
		||||
  
 | 
			
		||||
begin
 | 
			
		||||
  randomize;
 | 
			
		||||
  for I:=1 to 1000 do
 | 
			
		||||
    distarray[i]:=random;
 | 
			
		||||
  momentskewkurtosis(DistArray,m1,m2,m3,m4,skew,kurtosis);
 | 
			
		||||
  
 | 
			
		||||
  Writeln ('1st moment : ',m1:8:6);  
 | 
			
		||||
  Writeln ('2nd moment : ',m2:8:6);  
 | 
			
		||||
  Writeln ('3rd moment : ',m3:8:6);  
 | 
			
		||||
  Writeln ('4th moment : ',m4:8:6);  
 | 
			
		||||
  Writeln ('Skew       : ',skew:8:6);  
 | 
			
		||||
  Writeln ('kurtosis   : ',kurtosis:8:6);  
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										18
									
								
								docs/mathex/ex33.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								docs/mathex/ex33.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
Program Example33;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the norm function. }
 | 
			
		||||
 | 
			
		||||
Uses math;
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
  TVector = Array[1..10] of Float;
 | 
			
		||||
 | 
			
		||||
Var 
 | 
			
		||||
  AVector : Tvector;
 | 
			
		||||
  I : longint;
 | 
			
		||||
   
 | 
			
		||||
begin
 | 
			
		||||
 for I:=1 to 10 do
 | 
			
		||||
   Avector[i]:=Random;
 | 
			
		||||
 Writeln(Norm(AVector));
 | 
			
		||||
end.
 | 
			
		||||
							
								
								
									
										17
									
								
								docs/mathex/ex34.pp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								docs/mathex/ex34.pp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
Program Example34;
 | 
			
		||||
 | 
			
		||||
{ Program to demonstrate the power function. }
 | 
			
		||||
 | 
			
		||||
Uses Math;
 | 
			
		||||
 | 
			
		||||
procedure dopower(x,y : float);
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  writeln(x:8:6,'^',y:8:6,' = ',power(x,y):8:6)
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  dopower(2,2);
 | 
			
		||||
  dopower(2,-2);
 | 
			
		||||
  dopower(2,0.0);
 | 
			
		||||
end.
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user