Math Functions

# Math Module

## Directory List

### AStar

 AStarSearch Finds the optimal path using A*. DeltaAngleForNewRADec Compute the angle change needed to change a trajectory so that it GenerateGrid Generate a grid on a sphere. GlobeGrid Generate right ascensions and declinations for a global grid. GridPathCost Finds the cost for going from startNode to nextNode. GridSuccessorNodes Finds successor nodes in a square grid. GridTraverseCost Finds the cost of going from one node to another in a square grid. ManeuverCost Finds the cost for going from startNode to nextNode. ManeuverCost3D Finds the cost for going from startNode to nextNode in 3D. ManeuverSuccessorNodes Finds successor nodes. ManeuverSuccessorNodes3D Finds successor nodes in 3D. SphericalGrid Generate a grid on a sphere that is evenly spaced in right ascension TransformGridCoordinates Transforms between 2D and 1D coordinates.

### Analysis

 Armijo Use the Armijo rule to compute a stepsize, alpha: AutoCorr Generates the autocorrelation function for the input sequence. Binomial The binomial expansion of (x + y)^n CFract Computes the value of a continued fraction of the form CHarm Generate a series of cosine harmonics of the arguments CHarmD Generate a series of cosine harmonics of the arguments DLyapG Find the solution for the Lyapunov equation apa' - p + q = 0, which is FitPair Given xF, find yF that best fits xF given the pair (x,y) FourierSeries Generates the Fourier Series sine and cosine coefficients of a signal using Heavisde Heavside function. H = 1 x „ 0, otherwise = 0 HypgF1 Computes the value of the hypergeometric function HypgFr Computes the value of the ratio of hypergeometric functions HypgMr Computes the value of the confluent hypergeometric ratio IntExpR One dimensional interpolation and extrapolation on the rows of a. IntExt One or two dimensional interpolation and extrapolation. If no outputs Interp1D Performs a linear interpolation: InterpolateCircle Interpolates between x1 and x2 when x1 and x2 lie in a circle. When JCart2Sp Converts cartesian to spherical coordinates. Spherical coordinates are JSp2Cart Computes the Jacobian for converting from spherical to Jacobian This function computes the Jacobian matrix for a right hand-side. JacobianODE This function computes the Jacobian matrix for a right hand-side. LogBaseN log of base n. Logistic Logistic function. LyapG Solve the general Lyapunov equation ap + pa' + q = 0 NewStats Calculates the new standard deviation and average. NewtonsMethod Solve an optimization problem with Newton's method. OptimalTrajectory Computes the control for an optimal trajectory using simplex for a fixed PAL Generates the Associated Legendre Functions of the first kind PDAL Generates Associated Legendre Functions of the first kind and derivatives PGauss Computes the Gaussian form of the Legendre functions. Pade Create a Padé approximant of exp(sT) SCHarm Generate a series of sine and cosine harmonics of the arguments SCHarmD Generate a series of sine and cosine harmonics of the arguments SCSeries Compute a series a + sum(bn sin(n wo t)) + sum(cn cos(n wo t)) SHarm Generate a series of sine harmonics of the arguments SHarmD Generate a series of sine harmonics of the arguments Simplex Uses the simplex method to minimize the cost when solving the problem Simplex2 Computes the solution to the simplex problem with an optional SimplexOld Uses the simplex method to minimize the cost when solving the problem SimplexScaling Scales the multipliers of the slack variables in the 'a' matrix SphJacobian This function is the application to the chain rule to a function U SubPoly Subtract two polynomials so that c = a - b. WorstFirstAssignment Reorder columns to minimize the diagonal sum with a worst-first policy

### Demos/AStar

 AStarSearch3DManeuverDemo Demonstrate A* for a close orbital maneuver. AStarSearchGrid1Demo Test AStarSearch using a grid with obstacles. AStarSearchGrid2Demo Test AStarSearch using a grid with obstacles. AStarSearchManeuverDemo Demonstrate A* for a close orbital maneuver. AStarSearchOrderGridDemo Test AStarSearch using a grid with randomly placed obstacles. AStarSearchRandomGridDemo Test AStarSearch using a grid with randomly placed obstacles.

### Demos/FDIR

 DCMotorSim Simulates 2 DC Motors with failure detection logic. DetectionFilterBuilderDemo Simulate a detection filter using the DetectionFilterBuilder GUI. FDIROLASim Test Fault Diagnosis using online approximators. OrbitFDIRDemo Demonstrate an orbit detection filter for a spacecraft with one thruster. OrbitFDIRPulseDemo Demonstrate an orbit detection filter for a spacecraft with one thruster. SpinnerFDIRDemo Demonstrate a detection filter for a spinning spacecraft.

### Demos/Math

 SimplexConstraintRelaxationDemo Solve an infeasible LP with simplex through constraint relaxation SimplexScalingDemo Solve a linear program with Simplex. Illustrate the need for scaling. THyperG Demonstrate hypergeometric functions.

### Demos/Probability

 DoggyProblem Demonstrate the BinomialTheorem for the doggy problem. GunProblem Demonstrate the BinomialTheorem for the gun problem.

### FDIR

 BuildLinearDF Create a detection filter for a fully measured system. DCMotorDetectionFilter Implements a DC motor detection filter. Uses Euler integration. DCMotorFailures Triggers a failure at time tFail. Sets the failed parameter to pFail. DCMotorParitySpace Computes the residuals for two DC motors. DetectionFilter Implement a detection filter for a fully measured system. DetectionFilterBuild Algorithm to compute detection filter gains. DetectionFilterBuilder GUI to build detection filters. DetectionFilterSimulation Simulate a detection filter using a state space model. DetectionFilterUnnormalized Create a unnormalized detection filter for a fully measured system. DualDCMotors Simulates two DC motors. NonlinearEstimator Implements an online approximator for a spring mass damper system. NonlinearSpring Right-hand-side of a nonlinear spring dynamics model. NonlinearSpringFault Nonlinear spring fault. NormalizeMatrix Normalizes a state space system for use with a detection filter. OnlineApproximator Implements an online approximator, f( y, theta ). ProbabilityOfFailure Computes the probability of failure. Failure rate is in failures/unit RadialBasisFunction Implements a radial basis function for online estimators. TMatrix Compute a transformation matrix for the following operation

### Geometry

 AngleSepFromRotation Compute angular separation between 2 vectors by rotating about an axis BilinearInterpolation Apply bilinear interpolation on 4 data points. FindValidAngleRange Find valid range of rotation angles that satisfy separation constraints FitEllipse Fit an ellipse. InsideAngleRange Determine whether an angle is inside an angular range. IntersectLineAndCone Compute the intersection of a line and a cone. The line is defined by a IntersectLineAndEllipsoid Compute the intersection of a line and ellipsoid. Always returns MergeAngleRange Merge two angular ranges. Returns the intersection Perpendicular Finds perpendicular vectors to a such that Dot(b,a) = 0. PointInGridInTriangle Determine whether points p are in triangle v. PointInPolygon Determine whether points p are in polygon v. PointInTriangle Determine whether points p are in triangle v. SegmentIntersection Compute whether and where two 2D line segments intersect UnitVectorAverage Average unit vector. Volume Volume of a solid.

### Integration

 Euler Euler's method for numerical integration. RK2 Second order Runge-Kutta. Called function is of the form: RK4 Fourth order Runge-Kutta. Called function is of the form: RK45 Fourth/fifth order Runge-Kutta. RK4TI Fourth order Runge-Kutta integration. RHS is time-independent (TI).

### Linear

 ColCompR Computes the right column compression of a matrix. Compresses the ComplexToReal Convert a matrix from complex to real. c is assumed to have columns of Cross Vector cross product. The number of columns of w and y can be: DUnit Derivative of the unit vector for r. DelLZ Deletes leading zeros from a vector. Dot Dot product with support for arrays. DupVect Create a matrix with n rows or columns each of which equals the Factorl Computes the factorial matrix for a matrix. GJInv Matrix inverse using Gauss-Jordan elimination with partial pivoting. GenSub Subtract two matrices where NaN - NaN or inf - inf == 0 Inv3x3 Inverse of a 3x3 matrix. InvP The product form of the inverse: IsZero Set = 0 if the matrix is all zeros. LSSVD Solves ax = b using the singular value decomposition LeastSq Find a weighted least squares curve fit to the overdetermined Mag Given a 3-by-n matrix where each column represents a vector, return a Orthogonalize Orthogonalize a matrix Product Computes product of the terms in a vector RowCompU Computes the upper row compression of a matrix. Compresses the SXV Multiplies a scalar times a vector. Each column in the vector is Sep Separate a matrix or vector based on the criteria entered in s. Skew Converts a vector into a skew symmetric matrix. SkewSq Computes the product of two skew symmetric matrices derive from vectors. SkewSymm Converts a vector into a skew symmetric matrix SumC Always sums by column even if x is a single row. SumV Sum a set of vectors in a 3-by-n matrix Unit Unitize vectors by column.

### MathUtils

 DeltaEig Computes the delta eigenvalues for a given a small perturbation of a, e FTrunc Simulates floating point truncation to -ƒ. FloatToTwosComplement Converts a float to two's complement array. For example: Odd 1 if the value is odd R2P5 Rounds towards zero to the nearest 1/2. Ramp Generate a ramp signal at t0 from value v0 to vF in time interval t Ramps Generates ramps for any number of inputs. Since version 10. RoundN Round to n decimal places TriangleWave Generates a triangle wave. 0 is the beginning and 2*pi is the end. TwosComplementToFloat Converts a two's complement array to float.

### Probability

 BinomialTheorem Computes the binomial theorem. CRand Given a covariance matrix, c, finds a transformation matrix CableTensionExample Cable tension example. Combinations The number of combinations of r articles in n samples. ConfidenceInterval Computes the confidence interval. CovarianceRHS Generates the covariance derivative. The covariance matrix is entered as EMarkov Find the correlation time and the mean squared value for a Markov sequence. ErrorCombination Combine errors given a function. GaussianCPDF Compute the cumulative probability density function for GaussianPDF Compute the probability density function for a Gaussian distribution. GaussianRSG Gaussian Random Sequence Generator Using the Box-Mueller Transform Markov Generate random output from a Gauss-Markov process. The NormalDistribution Matrix normal or Gaussian distribution. RMarkov Generates the autocorrelation function for a Markov Process. RandP Generate a Poission random matrix. RandPM Generates uniform random matrices between -1 and +1 RandPN Generate a Poission random matrix using a normal approximation. Random Compute a random nxm matrix SMarkov Generates the spectral function for a Markov Process. SignTest Compare the relative accuracy of two signals.

### Solvers

 BisectionZero Use bisection method to find the zero crossing of a function. LEPDS Solves the problem ax = b when a is positive definite symmetric ModNewt Finds the solution to f(x) = 0 given derivative information. NLEqSolver Solves a set of equations for zero using Newton's method. NLEqSolverWrapper Wraps the Newton's method solver by trying several values. NewtRaph Finds the solution to f(x) = 0 given df(x)/dx when only one