diff --git a/golang/internal/lab4/calculate.go b/golang/internal/lab4/calculate.go new file mode 100644 index 00000000..2b3f2440 --- /dev/null +++ b/golang/internal/lab4/calculate.go @@ -0,0 +1,27 @@ +package lab4 + +import "math" + +func Form(x, a float64) float64 { + return (math.Pow(a, (math.Pow(x, 2)-1)) - math.Log10(math.Pow(x, 2)-1) + math.Cbrt((math.Pow(x, 2) - 1))) +} + +func TaskA(Xs, Xe, step, a float64) ([]float64, []float64) { + y := []float64{} + x := []float64{} + for i := Xs; i <= Xe; i += step { + y = append(y, Form(i, a)) + x = append(x, i) + } + return x, y +} + +func TaskB(a float64, xArr []float64) ([]float64, []float64) { + x := []float64{} + y := []float64{} + for _, i := range xArr { + y = append(y, Form(i, a)) + x = append(x, i) + } + return x, y +} diff --git a/golang/main.go b/golang/main.go index 886e9971..b25b43cc 100644 --- a/golang/main.go +++ b/golang/main.go @@ -1,7 +1,22 @@ package main -import "fmt" +import ( + "fmt" + + "isuct.ru/informatics2022/internal/lab4" +) func main() { - fmt.Println("Целиков Алексей Александрович") + a := 2.25 + fmt.Println("Задача A") + x, y := lab4.TaskA(1.2, 2.7, 0.3, a) + for i := range y { + fmt.Println("При x=", x[i], "y=", y[i]) + } + fmt.Println("Задача B") + var list_of_x []float64 = []float64{1.31, 1.39, 1.44, 1.56, 1.92} + x, y = lab4.TaskB(a, list_of_x) + for i := range y { + fmt.Println("При x=", x[i], "y=", y[i]) + } }