Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Word / вычмат

.doc
Скачиваний:
23
Добавлен:
07.01.2014
Размер:
35.33 Кб
Скачать

Sub Statistica()

Dim n%, p!, X!(), i%, dx!, s!, Sx!, dmax!, k%, Ut!, Uras!, epsilon!, m%

n = Cells(1, 2)

p = Cells(2, 2)

m = 0

ReDim X(n)

For i = 1 To n

X(i) = Cells(2 + i, 2)

Next i

Do

m = m + 1

s = 0

For i = 1 To n

s = s + X(i)

Next i

dx = s / n

dmax = Abs(X(1) - dx)

k = 1

s = 0

For i = 1 To n

s = s + (X(i) - dx) ^ 2

Next i

Sx = s / (n - 1)

For i = 2 To n Step 1

s = Abs(X(i) - dx)

If s > dmax Then dmax = s: k = i

Next i

Uras = dmax / Sqr(Sx * (n - 1) / n)

Ut = U(p, n - 2)

If m >= 1 Then

Cells(1 + m, 10) = Ut

Cells(1 + m, 11) = Uras

End If

If Uras > Ut Then X(k) = X(n): n = n - 1

Loop Until Uras < Ut

epsilon = t(p, n - 1) * Sqr(Sx / n)

Cells(1, 4) = dx

Cells(2, 4) = Sx

Cells(3, 4) = epsilon

Cells(3, 6) = dx - epsilon

Cells(3, 8) = dx + epsilon

End Sub

Function t!(p!, f%)

t = WorksheetFunction.TInv(p, f)

End Function

Function U!(p!, f%)

Dim tr!

tr = t(2 * p / (f + 2), f)

U = tr * Sqr((f + 1) / (f + tr ^ 2))

End Function

Sub matrix()

Dim A!(), B!(), AT!(), BT!(), c!(), d!(), E!(), G!(), U!(), q!(), F!()

Dim n%, m%, norma!

n = Cells(1, 2)

m = Cells(2, 2)

ReDim A(n, m), AT(m, n), B(m, n), BT(n, m), E(n, n), G(n, n), U(n, n), c(m), d(m), q(m), F(m)

Call input_m(4, 2, n, m, A)

Call transp(n, m, A, AT)

Call print_m(10, 2, m, n, AT)

Call input_m(4, 5, m, n, B)

Call transp(m, n, B, BT)

Call print_m(14, 2, n, m, BT)

Call mumnoj(n, m, n, AT, A, E)

Call print_m(10, 6, m, m, E)

Call mumnoj(m, m, n, B, BT, G)

Call print_m(14, 6, m, m, G)

Call minus(n, n, E, G, U)

Call print_m(10, 9, m, m, U)

Call input_v(4, 9, m, c)

Call input_v(4, 11, m, d)

Call plus(m, c, d, q)

Call print_v(14, 9, m, q)

Call umnoj_v(m, m, U, q, F)

Call print_v(19, 2, m, F)

Call norma_v(m, F, norma)

Cells(19, 6) = norma

End Sub

Sub umnoj_v(n%, m%, A!(), B!(), F!())

Dim i%, j%, s!

For i = 1 To n

s = 0

For j = 1 To m

s = s + A(i, j) * B(j)

Next j

F(i) = s

Next i

End Sub

Sub input_v(str%, col%, n%, A!())

Dim i%

For i = 1 To n

A(i) = Cells(str% - 1 + i, col%)

Next i

End Sub

Sub print_v(str%, col%, n%, Ma!())

Dim i%

For i = 1 To n

Cells(str - 1 + i, col) = Ma(i)

Next i

End Sub

Sub plus(n%, c!(), d!(), q!())

Dim i%

For i = 1 To n

q(i) = c(i) + d(i)

Next i

End Sub

Sub minus(n%, m%, A!(), B!(), c!())

Dim i%, j%

For i = 1 To n

For j = 1 To m

c(i, j) = A(i, j) - B(i, j)

Next j

Next i

End Sub

Sub mumnoj(n%, m%, k%, A!(), B!(), E!())

Dim i%, j%, l%, s!

For i = 1 To m

For j = 1 To m

s = 0

For l = 1 To k

s = s + A(i, l) * B(l, j)

Next l

E(i, j) = s

Next j

Next i

End Sub

Sub transp(n%, m%, A!(), AT!())

Dim i%, j%

For i = 1 To m

For j = 1 To n

AT(i, j) = A(j, i)

Next j

Next i

End Sub

Sub print_m(str%, col%, n%, m%, Ma!())

Dim i%, j%

For i = 1 To n

For j = 1 To m

Cells(str - 1 + i, col - 1 + j) = Ma(i, j)

Next j

Next i

End Sub

Sub input_m(str%, col%, n%, m%, A!())

Dim i%, j%

For i = 1 To n

For j = 1 To m

A(i, j) = Cells(str% - 1 + i, col% - 1 + j)

Next j

Next i

End Sub

Sub norma_v(n%, A!(), normav!)

Dim j%, s!

s = 0

For j = 1 To n

s = s + A(j) ^ 2

Next j

normav = Sqr(s)

End Sub

Sub oi()

Dim x1!, x2!, x3!, y!, dx!

x1 = Cells(1, 1)

x2 = Cells(1, 2)

x3 = Cells(1, 3)

dx = Cells(1, 4)

y = (3 * x1 ^ 2 + x2 ^ 2) / (x1 ^ 2 - 2 * x3 ^ 2)

dy1 = (-12 * x1 * x3 ^ 2 - 2 * x1 * x2 ^ 2) / (x1 ^ 2 - 2 * x3 ^ 2) ^ 2

dy2 = 2 * x2 / (x1 ^ 2 - 2 * x3 ^ 2)

dy3 = 4 * x3 * (3 * x1 ^ 2 + x2 ^ 2) / (x1 ^ 2 - 2 * x3 ^ 2) ^ 2

dy = (Abs(dy1) + Abs(dy2) + Abs(dy3)) * dx

otny = dy * 100 / Abs(y)

MsgBox y

MsgBox dy

MsgBox otny

Cells(4, 3) = dy

Cells(4, 4) = otny

Cells(4, 2) = y

End Sub

Соседние файлы в папке Word