factor

package module
Version: v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2020 License: MPL-2.0 Imports: 1 Imported by: 0

README

factor CI PkgGoDev

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.

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.

Source Files

Directories

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL