https://github.com/gabri432/equation-solver
A program that will be able to solve any linear, quadratic or cubic equation
https://github.com/gabri432/equation-solver
cubic equation-solver go golang linear math quadratic
Last synced: about 1 month ago
JSON representation
A program that will be able to solve any linear, quadratic or cubic equation
- Host: GitHub
- URL: https://github.com/gabri432/equation-solver
- Owner: Gabri432
- License: mit
- Created: 2022-09-25T18:49:34.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-05T20:07:52.000Z (over 3 years ago)
- Last Synced: 2024-06-21T11:10:09.434Z (about 2 years ago)
- Topics: cubic, equation-solver, go, golang, linear, math, quadratic
- Language: Go
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.it.md
- Changelog: CHANGELOG.txt
- Contributing: .github/CONTRIBUTING.it.md
- License: license
Awesome Lists containing this project
README
# equation-solver



[](https://goreportcard.com/report/github.com/Gabri432/equation-solver)
[](https://pkg.go.dev/github.com/Gabri432/equation-solver)
Un programma che risolverà una qualunque equazione lineare, quadratica e cubica.
## Come usare la libreria
- Scarica il package 'equationsolver':
```
go get -u github.com/Gabri432/equation-solver
```
- Esempio di utilizzo
```go
package main
import (
"fmt"
eq "github.com/Gabri432/equation-solver"
)
func main() {
solution := eq.EvaluateEquation("x^3-4x=5x^2-1")
fmt.Println("real solutions: ", solution.RealSolutions, "\ncomplex solutions:", solution.ComplexSolutions)
myPolynom := eq.Polynom{A: 1, B: 5, C: -4, D: 1}
fmt.Println(myPolynom.SolveEquation())
}
```
=== Output ===
real solutions: [-0.8752..., 0.2013..., 5.6739...]
complex solutions: []
{[0.38196... 2.61803...] [] }
## Funzioni
```go
EvaluateEquations(equation string) EquationSolution
```
- Prende l'equazione in forma di stringa e ritorna il risultato di tipo EquationSolution
```go
ValidateEquation(equation string) string
```
- Controlla se l'equazione inserita dall'utente è valida.
## Tipi
### Polynom
```go
// Crea un polinomio nella forma: ax^3+bx^2+cx+d
type Polynom struct {
a float64
b float64
c float64
d float64
}
```
### EquationSolution
```go
type EquationSolution struct {
realSolutions []float64 // insieme di soluzioni reali
complexSolutions []complex128 // insieme di soluzioni complesse
errorDescription string // messaggio d'errore
```
## Struttura del progetto
- (main)
- equation.go
- equation_test.go
- internal_functions.go
- internal_functions_test.go
- license
- README.md
- README.it.md
- .github
- CONTRIBUTING.it.md
- CONTRIBUTING.md
## Contribuire al progetto
- Se vuoi aggiungere una feature o fare un aggiustamento fai un giro in questa pagina su come fare: [Contribuire a equation-solver](https://github.com/Gabri432/equation-solver/blob/master/.github/CONTRIBUTING.it.md)
## Note aggiuntive
- Se vuoi verificare l'accuratezza del programma usa i seguenti link:
- [Cubic Equations Solver](https://www.calculatorsoup.com/calculators/algebra/cubicequation.php)
- [Quadratic Equations Solver](https://www.calculatorsoup.com/calculators/algebra/quadratic-formula-calculator.php)