Skip to content

Commit

Permalink
Merge pull request #2 from kokter/kokter
Browse files Browse the repository at this point in the history
Kokter
  • Loading branch information
kokter authored Nov 24, 2023
2 parents af30253 + f71dbe3 commit 59427b2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
27 changes: 27 additions & 0 deletions golang/internal/lab4/calculate.go
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 17 additions & 2 deletions golang/main.go
Original file line number Diff line number Diff line change
@@ -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])
}
}

0 comments on commit 59427b2

Please sign in to comment.