# factor

package module
Version: v0.0.1 Latest Latest

Go to latest
Published: Dec 8, 2020 License: MPL-2.0

### factor

A library for manipulating polynomials. Includes a command-line tool for factoring as well.

##### Installation:
Library:
``````go get github.com/noah-friedman/factor
``````
Command-Line Tool:
``````go get github.com/noah-friedman/factor/cmd/factor
``````

NOTE: Make sure `\$GOPATH/bin` is in the system path.

## Documentation ¶

### Overview ¶

Define the polynomial type and functions related to it.

### 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.

## Directories ¶

Path Synopsis
cmd
Command line tool for factoring polynomials.
Command line tool for factoring polynomials.