Skip to main content

Polynomial

                            
                              
                                class 
                                Polynomial
                              
                              

A polynomial in the form ax^3 + bx^2 + cx + d up to a cubic polynomial.

Source code liberally taken from:

Constructors

constructor

                            
                              
                                public 
                                new
                                Polynomial
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              
                            
                              
                                public 
                                new
                                Polynomial
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                    
                                      c1
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              
                            
                              
                                public 
                                new
                                Polynomial
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                    
                                      c1
                                      : 
                                      number
                                    
                                    
                                      c2
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              
                            
                              
                                public 
                                new
                                Polynomial
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                    
                                      c1
                                      : 
                                      number
                                    
                                    
                                      c2
                                      : 
                                      number
                                    
                                    
                                      c3
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              

Parameters

  • c0 : number

    The constant coefficient

Properties

c0

                            
                              
                                readonly 
                                public 
                                c0
                                : 
                                number
                              
                              

c1

                            
                              
                                readonly 
                                public 
                                c1
                                : 
                                number
                              
                              

c2

                            
                              
                                readonly 
                                public 
                                c2
                                : 
                                number
                              
                              

c3

                            
                              
                                readonly 
                                public 
                                c3
                                : 
                                number
                              
                              

Accessors

degree

                            
                              
                                public 
                                get 
                                degree
                                (): 
                                number
                              
                              

The degree of the polynomial

Methods

differentiate

                            
                              
                                public 
                                differentiate
                                
                                  
                                    
                                      n
                                      : 
                                      number
                                       = 
                                      1
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              

Return the nth derivative of the polynomial.

Parameters

  • n : number = 1

    The number of times to differentiate the polynomial.


eval

                            
                              
                                public 
                                eval
                                
                                  
                                    
                                      t
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                number
                              
                              
                            
                              
                                public 
                                eval
                                
                                  
                                    
                                      t
                                      : 
                                      number
                                    
                                    
                                      derivative
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                number
                              
                              

Evaluate the polynomial at the given value t.

Parameters

  • t : number

    The value to sample at


localExtrema

                            
                              
                                public 
                                localExtrema
                                (): 
                                number
                                []
                              
                              

Calculate the local extrema of the polynomial.


localExtrema01

                            
                              
                                public 
                                localExtrema01
                                (): 
                                number
                                []
                              
                              

Calculate the local extrema of the polynomial in the unit interval.


outputRange01

                            
                              
                                public 
                                outputRange01
                                (): 
                                number
                                []
                              
                              

Return the output value range within the unit interval.


roots

                            
                              
                                public 
                                roots
                                (): 
                                number
                                []
                              
                              

Calculate the roots (values where this polynomial = 0).

Depending on the degree of the polynomial, returns between 0 and 3 results.


split

                            
                              
                                public 
                                split
                                
                                  
                                    
                                      u
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                
                                  
                                    
                                      Polynomial
                                    
                                    
                                      Polynomial
                                    
                                  
                                
                              
                              

Split the polynomial into two polynomials of the same overall shape.

Parameters

  • u : number

    The point at which to split the polynomial.


constant

                            
                              
                                static 
                                public 
                                constant
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              

Constructs a constant polynomial

Parameters

  • c0 : number

    The constant coefficient


cubic

                            
                              
                                static 
                                public 
                                cubic
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                    
                                      c1
                                      : 
                                      number
                                    
                                    
                                      c2
                                      : 
                                      number
                                    
                                    
                                      c3
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              

Constructs a cubic polynomial

Parameters

  • c0 : number

    The constant coefficient

  • c1 : number

    The linear coefficient

  • c2 : number

    The quadratic coefficient

  • c3 : number

    The cubic coefficient


linear

                            
                              
                                static 
                                public 
                                linear
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                    
                                      c1
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              

Constructs a linear polynomial

Parameters

  • c0 : number

    The constant coefficient

  • c1 : number

    The linear coefficient


quadratic

                            
                              
                                static 
                                public 
                                quadratic
                                
                                  
                                    
                                      c0
                                      : 
                                      number
                                    
                                    
                                      c1
                                      : 
                                      number
                                    
                                    
                                      c2
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                Polynomial
                              
                              

Constructs a quadratic polynomial

Parameters

  • c0 : number

    The constant coefficient

  • c1 : number

    The linear coefficient

  • c2 : number

    The quadratic coefficient