Лабы 5 семестра
This commit is contained in:
parent
72cf5b79a1
commit
df99bf9129
62 changed files with 13542 additions and 0 deletions
BIN
5.1.2/algos/Main
Executable file
BIN
5.1.2/algos/Main
Executable file
Binary file not shown.
BIN
5.1.2/algos/Main.hi
Normal file
BIN
5.1.2/algos/Main.hi
Normal file
Binary file not shown.
45
5.1.2/algos/Main.hs
Normal file
45
5.1.2/algos/Main.hs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
module Main where
|
||||
import Text.Printf
|
||||
|
||||
ns = [860, 847, 743, 672, 623, 521, 461, 427, 376, 343, 315, 288]
|
||||
angles = take 12 $ [0, 10..]
|
||||
|
||||
main :: IO()
|
||||
main = do
|
||||
let xs = (map (\x -> 1 - cos (pi * x / 180)) angles)
|
||||
let ys = (map (\x -> 1 / x - 1 / (head ns)) ns)
|
||||
print_data xs ys
|
||||
|
||||
let k' = k xs ys
|
||||
--let b' = b xs ys
|
||||
|
||||
putStr "k="
|
||||
print k'
|
||||
|
||||
let n0 = k' * (1 - cos 0) + 1/ (head ns)
|
||||
print $ 1 / n0
|
||||
let n90 = k' * (1 - cos (pi / 2)) + 1 / (head ns)
|
||||
print $ 1 / n90
|
||||
|
||||
|
||||
print_data :: [Double] -> [Double] -> IO ()
|
||||
print_data (x:xs) (y:ys) = do
|
||||
printf "%f %f\n" x y
|
||||
print_data xs ys
|
||||
print_data _ _ = return ()
|
||||
|
||||
mean :: [Double] -> Double
|
||||
mean lst = sum lst / n where
|
||||
n = fromIntegral $ length lst
|
||||
|
||||
k :: [Double] -> [Double] -> Double
|
||||
k xs ys = xy / x' where
|
||||
xy = mean $ zipWith (*) xs ys
|
||||
x' = mean $ map (^2) xs
|
||||
|
||||
b :: [Double] -> [Double] -> Double
|
||||
b xs ys = (xy - x * y) / (x ^ 2 - x') where
|
||||
xy = mean $ zipWith (*) xs ys
|
||||
x = mean xs
|
||||
y = mean ys
|
||||
x' = mean $ map (^2) xs
|
||||
BIN
5.1.2/algos/Main.o
Normal file
BIN
5.1.2/algos/Main.o
Normal file
Binary file not shown.
12
5.1.2/algos/plot.dat
Normal file
12
5.1.2/algos/plot.dat
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
0.0 0.0
|
||||
0.01519224698779198 0.00001784684659948926
|
||||
0.06030737921409157 0.00018310432251400673
|
||||
0.1339745962155613 0.0003253045404208194
|
||||
0.233955556881022 0.00044234573892269215
|
||||
0.35721239031346064 0.0007565950988706869
|
||||
0.4999999999999999 0.0010064066992887051
|
||||
0.6579798566743311 0.0011791296770328414
|
||||
0.8263518223330696 0.0014967837704106877
|
||||
0.9999999999999999 0.0017526611973693131
|
||||
1.1736481776669303 0.002011812476928756
|
||||
1.3420201433256687 0.0023094315245478034
|
||||
13
5.1.2/algos/plot.plt
Normal file
13
5.1.2/algos/plot.plt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
set xrange[0:1.4]
|
||||
set yrange[0:0.0025]
|
||||
set grid
|
||||
unset key
|
||||
|
||||
set mxtics 5
|
||||
set mytics 5
|
||||
|
||||
set grid mxtics mytics
|
||||
|
||||
set multiplot
|
||||
|
||||
plot 1.7670420408213902e-3 * x
|
||||
BIN
5.1.2/algos/plot.png
Normal file
BIN
5.1.2/algos/plot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8 KiB |
Reference in a new issue