Страница: 1 |
|
Вопрос: Функции бесселя
|
Добавлено: 06.06.10 22:58
|
|
Автор вопроса: kurganov4
|
Ребят! Помогите!!!
Как в VB2008 задать функцию Бесселя?
То есть например есть число x, надо найти J1(x).
Прошу подскажите кто нибудь как это сделать.
Ответить
|
Номер ответа: 4 Автор ответа: kurganov4
Вопросов: 1 Ответов: 1
|
Профиль | | #4
|
Добавлено: 07.06.10 23:24
|
Всем спасибо за помощь!
Решение нашел отсюда - http://alglib.sources.ru/specialfunctions/bessel.php
Довольно высокая точность.
Кому интересно в VB2008 я использовал такой код:
-
- Public Function BesselJ1(ByVal X As Double) As Double
- Dim Result As Double
- Dim s As Double
- Dim XSq As Double
- Dim nn As Double
- Dim PZero As Double
- Dim QZero As Double
- Dim P1 As Double
- Dim Q1 As Double
-
- s = Math.Sign(X)
- If X < 0.0# Then
- X = -X
- End If
- If X > 8.0# Then
- Call BesselAsympt1(X, PZero, QZero)
- nn = X - 3.0# * Math.PI / 4.0#
- Result = Math.Sqrt(2.0# / Math.PI / X) * (PZero * Math.Cos(nn) - QZero * Math.Sin(nn))
- If s < 0.0# Then
- Result = -Result
- End If
- BesselJ1 = Result
- Exit Function
- End If
- XSq = X ^ 2
- P1 = 2701.12271089232
- P1 = -4695753.530643 + XSq * P1
- P1 = 3413234182.3017 + XSq * P1
- P1 = -1322983480332.13 + XSq * P1
- P1 = 290879526383478.0# + XSq * P1
- P1 = -3.58881756991011E+16 + XSq * P1
- P1 = 2.316433580634E+18 + XSq * P1
- P1 = -6.67210656892492E+19 + XSq * P1
- P1 = 5.81199354001606E+20 + XSq * P1
- Q1 = 1.0#
- Q1 = 1606.93157348149 + XSq * Q1
- Q1 = 1501793.59499859 + XSq * Q1
- Q1 = 1013863514.35867 + XSq * Q1
- Q1 = 524371026216.765 + XSq * Q1
- Q1 = 208166122130761.0# + XSq * Q1
- Q1 = 6.09206139891752E+16 + XSq * Q1
- Q1 = 1.18577071219032E+19 + XSq * Q1
- Q1 = 1.16239870800321E+21 + XSq * Q1
- Result = s * X * P1 / Q1
- BesselJ1 = Result
- End Function
- Private Sub BesselAsympt1(ByVal X As Double, _
- ByRef PZero As Double, _
- ByRef QZero As Double)
- Dim XSq As Double
- Dim P2 As Double
- Dim Q2 As Double
- Dim P3 As Double
- Dim Q3 As Double
-
- XSq = 64.0# / (X * X)
- P2 = -1611.61664432461
- P2 = -109824.055434593 + XSq * P2
- P2 = -1523529.35118114 + XSq * P2
- P2 = -6603373.24836494 + XSq * P2
- P2 = -9942246.50507764 + XSq * P2
- P2 = -4435757.81679413 + XSq * P2
- Q2 = 1.0#
- Q2 = -1455.0094401905 + XSq * Q2
- Q2 = -107263.859911038 + XSq * Q2
- Q2 = -1511809.50663416 + XSq * Q2
- Q2 = -6585339.47972309 + XSq * Q2
- Q2 = -9934124.38993459 + XSq * Q2
- Q2 = -4435757.81679413 + XSq * Q2
- P3 = 35.265133846636
- P3 = 1706.37542902077 + XSq * P3
- P3 = 18494.2628732239 + XSq * P3
- P3 = 66178.8365812708 + XSq * P3
- P3 = 85145.1606753357 + XSq * P3
- P3 = 33220.9134098572 + XSq * P3
- Q3 = 1.0#
- Q3 = 863.836776960499 + XSq * Q3
- Q3 = 37890.2297457722 + XSq * Q3
- Q3 = 400294.43582267 + XSq * Q3
- Q3 = 1419460.66960372 + XSq * Q3
- Q3 = 1819458.042244 + XSq * Q3
- Q3 = 708712.819410287 + XSq * Q3
- PZero = P2 / Q2
- QZero = 8.0# * P3 / Q3 / X
- End Sub
Ответить
|
Страница: 1 |
Поиск по форуму