Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- R^1 -> R^1 Function Definition Condition Number (26, 27, 28)
	- R^1 -> R^1 Addition Operator Function #1 (29, 30, 31)
	- R^1 -> R^1 Addition Operator Function #2 (32, 33, 34)
	- R^1 -> R^1 Addition Operator Function Evaluate (35, 36)
	- R^1 -> R^1 Addition Operator Function a (37, 38)
	- R^1 -> R^1 Addition Operator Function Constructor (39, 40, 41)
	- R^1 -> R^1 Addition Operator Function Condition Number (42, 43, 44)
	- R^1 -> R^1 Addition Operator Function Derivative (45, 46)
	- Built-in R^1 -> R^1 Operator Functions (47)
	- R^1 -> R^1 Scale Operator Function Shell (59, 60)
	- R^1 -> R^1 Scale Operator Function "a" (61, 62)
	- R^1 -> R^1 Scale Operator Function Constructor (63, 64)
	- R^1 -> R^1 Scale Operator Function Evaluate (65, 66)
	- R^1 -> R^1 Scale Operator Function Derivative (67, 68)
	- R^1 -> R^1 Scale Operator Function Condition Number (69, 70)
	- R^1 -> R^1 Reciprocal Operator Function Condition Number (71, 72)
	- R^1 -> R^1 Exponential Operator Function Shell (73, 74)
	- R^1 -> R^1 Exponential Operator Function Constructor (75, 76)
	- R^1 -> R^1 Exponential Operator Function Evaluate (77, 78)
	- R^1 -> R^1 Exponential Operator Function Derivative (79, 80)
	- R^1 -> R^1 Exponential Operator Function Condition Number (81, 82)
	- R^1 -> R^1 Natural Logarithm Operator Function Shell (83, 84)
	- R^1 -> R^1 Natural Logarithm Operator Function Constructor (85, 86)
	- R^1 -> R^1 Natural Logarithm Operator Function Evaluate (87, 88)
	- R^1 -> R^1 Natural Logarithm Operator Function Condition Number (89, 90)
	- Built-in R^1 -> R^1 Trigonometric Functions (91, 92)
	- R^1 -> R^1 Sine Trigonometric Function Shell (93, 94)
	- R^1 -> R^1 Sine Trigonometric Function Constructor (95, 96)
	- R^1 -> R^1 Sine Trigonometric Function Evaluate (97, 98)
	- R^1 -> R^1 Sine Trigonometric Function Condition Number (99, 100)
	- R^1 -> R^1 Cosine Trigonometric Function Shell (101, 102)
	- R^1 -> R^1 Cosine Trigonometric Function Constructor (103, 104)
	- R^1 -> R^1 Cosine Trigonometric Function Evaluate (105, 106)
	- R^1 -> R^1 Cosine Trigonometric Function Condition Number (107, 108)
	- R^1 -> R^1 Tangent Trigonometric Function Shell (109, 110)
	- R^1 -> R^1 Tangent Trigonometric Function Constructor (111, 112)
	- R^1 -> R^1 Tangent Trigonometric Function Evaluate (113, 114)
	- R^1 -> R^1 Tangent Trigonometric Function Condition Number (115, 116)
	- R^1 -> R^1 Inverse Sine Trigonometric Function Shell (117, 118)
	- R^1 -> R^1 Inverse Sine Trigonometric Function Constructor (119, 120)


Bug Fixes/Re-organization:

	- R^1 -> R^1 Addition Operator Function Migration (48, 49)
	- R^1 -> R^1 Flat Operator Function Migration (50, 51)
	- R^1 -> R^1 Offset Idempotent Operator Migration (52)
	- R^1 -> R^1 Convolution Operator Function Migration (53, 54)
	- R^1 -> R^1 Reciprocal Operator Function Migration (55, 56)
	- R^1 -> R^1 Reflection Operator Function Migration (57, 58)


Samples:

IdeaDRIP:

	- Condition Number Matrices (1-5)
	- Condition Number Non-linear (6-7)
	- Condition Number Non-linear - One Variable (8-17)
	- Condition Number Non-linear - Several Variables (18-25)
  • Loading branch information
Lakshmik committed Aug 4, 2024
1 parent 27096fc commit 915c6a3
Show file tree
Hide file tree
Showing 108 changed files with 1,852 additions and 282 deletions.
Binary file not shown.
Binary file not shown.
192 changes: 192 additions & 0 deletions IdeaDRIP/NumericalAnalysis/NA_v0.07
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@

--------------------------
#1 - Successive Over-Relaxation
--------------------------
--------------------------
1.1) Successive Over-Relaxation Method for A.x = b; A - n x n square matrix, x - unknown vector, b - RHS vector
1.2) Decompose A into Diagonal, Lower, and upper Triangular Matrices; A = D + L + U
1.3) SOR Scheme uses omega input
1.4) Forward subsitution scheme to iteratively determine the x_i's
1.5) SOR Scheme Linear System Convergence: Inputs A and D, Jacobi Iteration Matrix Spectral Radius, omega
- Construct Jacobi Iteration Matrix: C_Jacobian = I - (Inverse D) A
- Convergence Verification #1: Ensure that Jacobi Iteration Matrix Spectral Radius is < 1
- Convergence Verification #2: Ensure omega between 0 and 2
- Optimal Relaxation Parameter Expression in terms of Jacobi Iteration Matrix Spectral Radius
- Omega Based Convergence Rate Expression
- Gauss-Seidel omega = 1; corresponding Convergence Rate
- Optimal Omega Convergence Rate
1.6) Generic Iterative Solver Method:
- Inputs: Iterator Function(x) and omega
- Unrelaxed Iterated variable: x_n+1 = f(x_n)
- SOR Based Iterated variable: x_n+1 = (1-omega).x_n + omega.f(x_n)
- SOR Based Iterated variable for Unknown Vector x: x_n+1 = (1-omega).x_n + omega.(L_star inverse)(b - U.x_n)
--------------------------

--------------------------
#2 - Successive Over-Relaxation
--------------------------
--------------------------
2.1) SSOR Algorithm - Inputs; A, omega, and gamma
- Decompose into D and L
- Pre-conditioner Matrix: Expression from SSOR
- Finally SSOR Iteration Formula
--------------------------

----------------------------
#7 - Tridiagonal matrix algorithm
----------------------------
----------------------------
7.1) Is Tridiagonal Check
7.2) Core Algorithm:
- C Prime's and D Prime's Calculation
- Back Substitution for the Result
- Modified better Book-keeping algorithm
7.3) Sherman-Morrison Algorithm:
- Choice of gamma
- Construct Tridiagonal B from A and gamma
- u Column from gamma and c_n
- v Column from a_1 and gamma
- Solve for y from By=d
- Solve for q from Bq=u
- Use Sherman Morrison Formula to extract x
7.4) Alternate Boundary Condition Algorithm:
- Solve Au=d for u
- Solve Av={-a_2, 0, ..., -c_n} for v
- Full solution is x_i = u_i + x_1 * v_i
- x_1 if computed using formula
----------------------------

----------------------------
#8 - Triangular Matrix
----------------------------
----------------------------
8.1) Description:
- Lower/Left Triangular Verification
- Upper/Right Triangular Verification
- Diagonal Matrix Verification
- Upper/Lower Trapezoidal Verification
8.2) Forward/Back Substitution:
- Inputs => L and b
- Forward Substitution
- Inputs => U and b
- Back Substitution
8.3) Properties:
- Is Matrix Normal, i.e., A times A transpose = A transpose times A
- Characteristic Polynomial
- Determinant/Permanent
8.4) Special Forms:
- Upper/Lower Unitriangular Matrix Verification
- Upper/Lower Strictly Matrix Verification
- Upper/Lower Atomic Matrix Verification
----------------------------

----------------------------
#9 - Sylvester Equation
----------------------------
----------------------------
9.1) Matrix Form:
- Inputs: A, B, and C
- Size Constraints Verification
9.2) Solution Criteria:
- Co-joint EigenSpectrum between A and B
9.3) Numerical Solution:
- Decomposition of A/B using Schur Decomposition into Triangular Form
- Forward/Back Substitution
----------------------------

----------------------------
#10 - Bartels-Stewart Algorithm
----------------------------
----------------------------
10.1) Matrix Form:
- Inputs: A, B, and C
- Size Constraints Verification
10.2) Schur Decompositions:
- R = U^T A U - emits U and R
- S = V^T B^T V - emits V and S
- F = U^T C V
- Y = U^T X V
- Solution to R.Y - Y.S^T = F
- Finally X = U.Y.V^T
10.3) Computational Costs:
- Flops cost for Schur decomposition
- Flops cost overall
10.4) Hessenberg-Schur Decompositions:
- R = U^T A U becomes H = Q^T A Q - thus emits Q and H (Upper Hessenberg)
- Computational Costs
----------------------------

----------------------------
#11 - Gershgorin Circle Theorem
----------------------------
----------------------------
11.1) Gershgorin Disc:
- Diagonal Entry
- Radius
- One disc per Row/Column in Square Matrix
- Optimal Disc based on Row/Column
11.2) Tolerance based Gershgorin Convergence Criterion
11.3) Joint and Disjoint Discs
11.4) Gershgorin Strengthener
11.5) Row/Column Diagonal Dominance
----------------------------

----------------------------
#12 - Condition Number
----------------------------
----------------------------
12.1) Condition Number Calculation:
- Absolute Error
- Relative Error
- Absolute Condition Number
- Relative Condition Number
12.2) Matrix Condition Number Calculation:
- Condition Number as a Product of Regular and Inverse Norms
- L2 Norm
- L2 Norm for Normal Matrix
- L2 Norm for Unitary Matrix
- Default Condition Number
- L Infinity Norm
- L Infinity Norm Triangular Matrix
12.3) Non-linear
- One Variable
- Basic Formula
- Condition Numbers for Common Functions
- Multi Variables
----------------------------

--------------------------
#13 - Crank–Nicolson method
--------------------------
--------------------------
13.1) von Neumann Stability Validator - Inputs; time-step, diffusivity, space step
- 1D => time step * diffusivity / space step ^2 < 0.5
- nD => time step * diffusivity / (space step hypotenuse) ^ 2 < 0.5
13.2) Set up:
- Input: Spatial variable x
- Input: Time variable t
- Inputs: State variable u, du/dx, d2u/dx2 - all at time t
- Second Order, 1D => du/dt = F (u, x, t, du/dx, d2u/dx2)
13.3) Finite Difference Evolution Scheme:
- Time Step delta_t, space step delta_x
- Forward Difference: F calculated at x
- Backward Difference: F calculated at x + delta_x
- Crank Nicolson: Average of Forward/Backward
13.4) 1D Diffusion:
- Inputs: 1D von Neumann Stability Validator, Number of time/space steps
- Time Index n, Space Index i
- Explicit Tridiagonal form for the discretization - State concentration at n+1 given state concentration at n
- Non-linear diffusion coefficient:
- Linearization across x_i and x_i+1
- Quasi-explicit forms accommodation
13.5) 2D Diffusion:
- Inputs: 2D von Neumann Stability Validator, Number of time/space steps
- Time Index n, Space Index i, j
- Explicit Tridiagonal form for the discretization - State concentration at n+1 given state concentration at n
- Explicit Solution using the Alternative Difference Implicit Scheme
13.6) Extension to Iterative Solver Schemes above:
- Input: State Space "velocity" dF/du
- Input: State "Step Size" delta_u
- Fixed Point Iterative Location Scheme
- Relaxation Scheme based Robustness => Input: Relaxation Parameter
--------------------------
10 changes: 9 additions & 1 deletion NumericalAnalysisLibrary.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Numerical Analysis Library contains the supporting Functionality for Numerical M

| Document | Link |
|-------------------------|------|
| Technical Specification | [*Latest*](https://github.com/lakshmiDRIP/DROP/blob/master/Docs/Internal/NumericalAnalysis/NumericalAnalysis_v6.44.pdf) [*Previous*](https://github.com/lakshmiDRIP/DROP/blob/master/Docs/Internal/NumericalAnalysis) |
| Technical Specification | [*Latest*](https://github.com/lakshmiDRIP/DROP/blob/master/Docs/Internal/NumericalAnalysis/NumericalAnalysis_v6.45.pdf) [*Previous*](https://github.com/lakshmiDRIP/DROP/blob/master/Docs/Internal/NumericalAnalysis) |
| User Guide | |
| API | [*Javadoc*](https://lakshmidrip.github.io/DROP/Javadoc/index.html)|

Expand Down Expand Up @@ -408,6 +408,14 @@ Numerical Analysis Library contains the supporting Functionality for Numerical M
* Application
* Example
* References
* Condition Number
* Introduction
* General Definition in the Context of Error Analysis
* Matrices
* Non-linear
* One variable
* Several variables
* References


## DROP Specifications
Expand Down
16 changes: 16 additions & 0 deletions ReleaseNotes/03_04_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Features:

Bug Fixes/Re-organization:

Samples:

IdeaDRIP:

- Condition Number Matrices #1 (1-33)
- Condition Number Non-linear (34-35)
- Condition Number Non-linear - One Variable (36-45)
- Condition Number Non-linear - Several Variables (46-53)
- Condition Number Matrices - Introduction (54-77)
- Condition Number General Definition in the Context of Error Analysis (78-81)
- Condition Number Matrices #2 (82-120)
63 changes: 63 additions & 0 deletions ReleaseNotes/03_05_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

Features:

- R^1 -> R^1 Function Definition Condition Number (26, 27, 28)
- R^1 -> R^1 Addition Operator Function #1 (29, 30, 31)
- R^1 -> R^1 Addition Operator Function #2 (32, 33, 34)
- R^1 -> R^1 Addition Operator Function Evaluate (35, 36)
- R^1 -> R^1 Addition Operator Function a (37, 38)
- R^1 -> R^1 Addition Operator Function Constructor (39, 40, 41)
- R^1 -> R^1 Addition Operator Function Condition Number (42, 43, 44)
- R^1 -> R^1 Addition Operator Function Derivative (45, 46)
- Built-in R^1 -> R^1 Operator Functions (47)
- R^1 -> R^1 Scale Operator Function Shell (59, 60)
- R^1 -> R^1 Scale Operator Function "a" (61, 62)
- R^1 -> R^1 Scale Operator Function Constructor (63, 64)
- R^1 -> R^1 Scale Operator Function Evaluate (65, 66)
- R^1 -> R^1 Scale Operator Function Derivative (67, 68)
- R^1 -> R^1 Scale Operator Function Condition Number (69, 70)
- R^1 -> R^1 Reciprocal Operator Function Condition Number (71, 72)
- R^1 -> R^1 Exponential Operator Function Shell (73, 74)
- R^1 -> R^1 Exponential Operator Function Constructor (75, 76)
- R^1 -> R^1 Exponential Operator Function Evaluate (77, 78)
- R^1 -> R^1 Exponential Operator Function Derivative (79, 80)
- R^1 -> R^1 Exponential Operator Function Condition Number (81, 82)
- R^1 -> R^1 Natural Logarithm Operator Function Shell (83, 84)
- R^1 -> R^1 Natural Logarithm Operator Function Constructor (85, 86)
- R^1 -> R^1 Natural Logarithm Operator Function Evaluate (87, 88)
- R^1 -> R^1 Natural Logarithm Operator Function Condition Number (89, 90)
- Built-in R^1 -> R^1 Trigonometric Functions (91, 92)
- R^1 -> R^1 Sine Trigonometric Function Shell (93, 94)
- R^1 -> R^1 Sine Trigonometric Function Constructor (95, 96)
- R^1 -> R^1 Sine Trigonometric Function Evaluate (97, 98)
- R^1 -> R^1 Sine Trigonometric Function Condition Number (99, 100)
- R^1 -> R^1 Cosine Trigonometric Function Shell (101, 102)
- R^1 -> R^1 Cosine Trigonometric Function Constructor (103, 104)
- R^1 -> R^1 Cosine Trigonometric Function Evaluate (105, 106)
- R^1 -> R^1 Cosine Trigonometric Function Condition Number (107, 108)
- R^1 -> R^1 Tangent Trigonometric Function Shell (109, 110)
- R^1 -> R^1 Tangent Trigonometric Function Constructor (111, 112)
- R^1 -> R^1 Tangent Trigonometric Function Evaluate (113, 114)
- R^1 -> R^1 Tangent Trigonometric Function Condition Number (115, 116)
- R^1 -> R^1 Inverse Sine Trigonometric Function Shell (117, 118)
- R^1 -> R^1 Inverse Sine Trigonometric Function Constructor (119, 120)


Bug Fixes/Re-organization:

- R^1 -> R^1 Addition Operator Function Migration (48, 49)
- R^1 -> R^1 Flat Operator Function Migration (50, 51)
- R^1 -> R^1 Offset Idempotent Operator Migration (52)
- R^1 -> R^1 Convolution Operator Function Migration (53, 54)
- R^1 -> R^1 Reciprocal Operator Function Migration (55, 56)
- R^1 -> R^1 Reflection Operator Function Migration (57, 58)


Samples:

IdeaDRIP:

- Condition Number Matrices (1-5)
- Condition Number Non-linear (6-7)
- Condition Number Non-linear - One Variable (8-17)
- Condition Number Non-linear - Several Variables (18-25)
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private org.drip.execution.dynamics.LinearPermanentExpectationParameters realize
try {
return new org.drip.execution.dynamics.LinearPermanentExpectationParameters (new
org.drip.execution.parameters.ArithmeticPriceDynamicsSettings (0., new
org.drip.function.r1tor1.FlatUnivariate (_cv.referenceVolatility() * java.lang.Math.exp
org.drip.function.r1tor1operator.Flat (_cv.referenceVolatility() * java.lang.Math.exp
(-0.5 * dblMarketState)), 0.), new
org.drip.execution.profiletime.UniformParticipationRateLinear
(org.drip.execution.impact.ParticipationRateLinear.NoImpact()), new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public org.drip.execution.dynamics.LinearPermanentExpectationParameters almgren2
try {
return org.drip.execution.dynamics.ArithmeticPriceEvolutionParametersBuilder.Almgren2003 (new
org.drip.execution.parameters.ArithmeticPriceDynamicsSettings (0., new
org.drip.function.r1tor1.FlatUnivariate (_afp.dailyVolatility()), 0.), new
org.drip.function.r1tor1operator.Flat (_afp.dailyVolatility()), 0.), new
org.drip.execution.profiletime.UniformParticipationRateLinear (new
org.drip.execution.athl.PermanentImpactNoArbitrage (_afp)), new
org.drip.execution.profiletime.UniformParticipationRate (new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static final org.drip.execution.dynamics.LinearPermanentExpectationParame
try {
return new org.drip.execution.dynamics.ArithmeticPriceEvolutionParameters (new
org.drip.execution.parameters.ArithmeticPriceDynamicsSettings (0., new
org.drip.function.r1tor1.FlatUnivariate (dblPriceVolatility), 0.), new
org.drip.function.r1tor1operator.Flat (dblPriceVolatility), 0.), new
org.drip.execution.profiletime.UniformParticipationRate
(org.drip.execution.impact.ParticipationRateLinear.NoImpact()),
bprlTemporaryExpectation, new
Expand Down Expand Up @@ -255,7 +255,7 @@ public static final org.drip.execution.dynamics.ArithmeticPriceEvolutionParamete
final org.drip.execution.tradingtime.CoordinatedVariation cv)
{
try {
return CoordinatedVariation (new org.drip.function.r1tor1.FlatUnivariate (dblPriceVolatility),
return CoordinatedVariation (new org.drip.function.r1tor1operator.Flat (dblPriceVolatility),
cv);
} catch (java.lang.Exception e) {
e.printStackTrace();
Expand All @@ -281,7 +281,7 @@ public static final org.drip.execution.dynamics.ArithmeticPriceEvolutionParamete
try {
return new org.drip.execution.dynamics.LinearPermanentExpectationParameters (new
org.drip.execution.parameters.ArithmeticPriceDynamicsSettings (0., new
org.drip.function.r1tor1.FlatUnivariate (cv.referenceVolatility()), 0.), new
org.drip.function.r1tor1operator.Flat (cv.referenceVolatility()), 0.), new
org.drip.execution.profiletime.UniformParticipationRateLinear
(org.drip.execution.impact.ParticipationRateLinear.NoImpact()), new
org.drip.execution.profiletime.UniformParticipationRateLinear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static final ArithmeticPriceDynamicsSettings FromAnnualReturnsSettings (

try {
return new ArithmeticPriceDynamicsSettings (dblPrice * dblAnnualReturnsExpectation / 250., new
org.drip.function.r1tor1.FlatUnivariate (dblPrice * dblAnnualReturnsVolatility /
org.drip.function.r1tor1operator.Flat (dblPrice * dblAnnualReturnsVolatility /
java.lang.Math.sqrt (250.)), dblSerialCorrelation);
} catch (java.lang.Exception e) {
e.printStackTrace();
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/drip/function/definition/R1ToR1.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,21 @@ public org.drip.function.definition.PoleResidue poleResidue (
{
return null;
}

/**
* Compute the Condition Number at the specified Variate
*
* @param x Variate
*
* @return The Condition Number
*
* @throws Exception Thrown if the Condition Number cannor be computed
*/

public double conditionNumber (
final double x)
throws Exception
{
return x * derivative (x, 1) / evaluate (x);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
* @author Lakshmi Krishnamurthy
*/

public class BernsteinPolynomial extends org.drip.function.r1tor1.UnivariateConvolution {
public class BernsteinPolynomial extends org.drip.function.r1tor1operator.Convolution {

/**
* Construct a BernsteinPolynomial instance
Expand All @@ -114,7 +114,7 @@ public BernsteinPolynomial (
throws java.lang.Exception
{
super (new org.drip.function.r1tor1.NaturalLogSeriesElement (iBaseExponent), new
org.drip.function.r1tor1.UnivariateReflection (new org.drip.function.r1tor1.NaturalLogSeriesElement
org.drip.function.r1tor1operator.Reflection (new org.drip.function.r1tor1.NaturalLogSeriesElement
(iComplementExponent)));
}

Expand Down
Loading

0 comments on commit 915c6a3

Please sign in to comment.