Documentation ¶
Overview ¶
Define the polynomial type and functions related to it.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Polynomial ¶
type Polynomial struct { // The coefficients for each term of the polynomial. The coefficients should be provided for each term ascending (e.g. 3x² + 7x + 9 -> 9, 7, 3). Coefficients []float64 }
A type that represents a polynomial function. It contains the information of it's coefficients, and has a method that will return the value of the function with a specific 'x' value (i.e. 'f(x)').
func (Polynomial) Degree ¶
func (p Polynomial) Degree() int
Calculate the degree of the Polynomial.
Example ¶
package main import ( "fmt" "github.com/noah-friedman/factor" ) func main() { p := factor.Polynomial{Coefficients: []float64{1, 2, 3, 4}} degree := p.Degree() fmt.Print(degree) }
Output: 3
func (Polynomial) F ¶
func (p Polynomial) F(x float64) float64
Calculate the value of the Polynomial function at a specific 'x' value. Rounded to 5 decimal places.
Click to show internal directories.
Click to hide internal directories.