Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanzh committed Nov 6, 2023
1 parent 6f97547 commit ee9b9f4
Show file tree
Hide file tree
Showing 97 changed files with 1,891 additions and 656 deletions.
71 changes: 71 additions & 0 deletions _sources/appendix/solvecubic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(appendix_solvecubic)=
# Решение кубического уравнения

```{proof:function} solve_cubic
**Решение кубического уравнения**
:::julia
"""
solve_cubic(a, b, c, d) -> Tuple{T,T,T}
Решает в действительных числах кубическое уравнение вида
a x³ + b x² + c x + d = 0
Вовзвращает кортеж из трёх корней, где первые корни действительные,
а комплексные корни представлены как not a number.
"""
function solve_cubic(a, b, c, d)
A, B, C, D = promote(float(a), float(b), float(c), float(d)) ./ (1, 3, 3, 1)
δ₁ = A * C - B * B
δ₂ = A * D - B * C
δ₃ = B * D - C * C
d13 = δ₁ * δ₃
d22 = δ₂ * δ₂
Δ = 4 * d13 - d22
nanvalue = zero(A) / zero(A)
if Δ < 0
At = Cb = Db = zero(A) # A-tilde, C-bar, D-bar
if B^3 * D ≥ A * C^3
At, Cb, Db = A, δ₁, -2 * B * δ₁ + A * δ₂
else
At, Cb, Db = D, δ₃, -D * δ₂ + 2 * C * δ₃
end
T₀ = -copysign(At, Db) * sqrt(-Δ)
T₁ = -Db + T₀
p = cbrt(T₁ / 2)
q = T₁ == T₀ ? -p : -Cb / p
x₁ = Cb ≤ 0 ? p + q : -Db / (p^2 + q^2 + Cb)
x, w = B^3 * D ≥ A * C^3 ? (x₁ - B, A) : (-D, x₁ + C)
return (x/w, nanvalue, nanvalue)
else
δ₁ == δ₂ == δ₃ == 0 && return (-B/A, -B/A, -B/A)
sΔ = sqrt(Δ)
θA, θD = abs.(atan.((A*sΔ, 2*B*δ₁ - A*δ₂, D*sΔ, D*δ₂ - 2*C*δ₃)) ./ 3)
sCA, sCD = sqrt.(.-min.((δ₁, δ₃), 0))
x₁A, x₁D = 2 .* (sCA, sCD) .* cos.((θA, θD))
x₃A, x₃D = .-((sCA, sCD)) .* (cos.((θA, θD)) .+ sqrt(3) .* sin.((θA, θD)))
xlt = (x₁A + x₃A > 2 * B) ? x₁A : x₃A
xst = (x₁D + x₃D < 2 * C) ? x₁D : x₃D
xl, wl = xlt - B, A
xs, ws = -D, xst + C
E = wl * ws
F = -xl * ws - wl * xs
G = xl * xs
xm, wm = C * F - B * G, C * E - B * F
return (xs/ws, xm/wm, xl/wl)
end
end
:::
>Оригинальный алгоритм изложен в работе:
>
>J. F. Blinn.
>How to Solve a Cubic Equation, Part 5: Back to Numerics.
>IEEE Computer Graphics and Applications, V. 27, no. 3, pp. 78-89, 2007.
>https://doi.org/10.1109/MCG.2007.60
>
>Имплементация взята из пакета [CubicEoS.jl](https://github.com/vvpisarev/CubicEoS.jl).
```
16 changes: 8 additions & 8 deletions _sources/integration/adaptive.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "38f79f96",
"id": "fa1d2fb2",
"metadata": {
"tags": [
"remove-cell"
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "markdown",
"id": "c6345ec5",
"id": "3a0c1ffa",
"metadata": {},
"source": [
"(chapter_integration_adaptive)=\n",
Expand All @@ -48,7 +48,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "df476824",
"id": "4438d3fa",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -187,7 +187,7 @@
},
{
"cell_type": "markdown",
"id": "118e80f1",
"id": "937be30f",
"metadata": {},
"source": [
"Видно, что данная функция по-разному \"изменчива\" на разных участках:\n",
Expand All @@ -202,7 +202,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "7480e6cd",
"id": "b1a1c73e",
"metadata": {},
"outputs": [
{
Expand All @@ -226,7 +226,7 @@
},
{
"cell_type": "markdown",
"id": "dec9412d",
"id": "a4b8fbff",
"metadata": {},
"source": [
"`rombergwstep` отличается от {numref}`Функции {number} (romberg) <function:romberg>` только тем, что возвращает кортеж `(I[1, i], i)`. То есть, вычисления слева можно было бы закончить уже после 7 разбиений, однако при вычислении на всём участке потребовалось уже 13 разбиений.\n",
Expand Down Expand Up @@ -344,7 +344,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "58cfdd84",
"id": "ed83e729",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -883,7 +883,7 @@
},
{
"cell_type": "markdown",
"id": "3ed75cda",
"id": "b5935262",
"metadata": {},
"source": [
"```{raw} html\n",
Expand Down
16 changes: 8 additions & 8 deletions _sources/integration/newton_cotes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "207409ec",
"id": "c6ed8448",
"metadata": {
"tags": [
"remove-cell"
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "markdown",
"id": "b6ae22ad",
"id": "1427e931",
"metadata": {},
"source": [
"(chapters:integration:newton-cotes)=\n",
Expand Down Expand Up @@ -156,7 +156,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "53deabec",
"id": "1a7ff24e",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -551,7 +551,7 @@
},
{
"cell_type": "markdown",
"id": "941f424e",
"id": "235d4eed",
"metadata": {},
"source": [
"```{raw} html\n",
Expand Down Expand Up @@ -662,7 +662,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "75a8f84a",
"id": "2ad71d4b",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -996,7 +996,7 @@
},
{
"cell_type": "markdown",
"id": "f2f716f6",
"id": "4da725ca",
"metadata": {},
"source": [
"```{raw} html\n",
Expand Down Expand Up @@ -1124,7 +1124,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "e7b6c0ad",
"id": "84ab382e",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1317,7 +1317,7 @@
},
{
"cell_type": "markdown",
"id": "75e4ac39",
"id": "6de1f942",
"metadata": {},
"source": [
"```{raw} html\n",
Expand Down
16 changes: 8 additions & 8 deletions _sources/interpolation/cubic_spline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "87c8a498",
"id": "22d846ad",
"metadata": {
"tags": [
"remove-cell"
Expand Down Expand Up @@ -43,7 +43,7 @@
},
{
"cell_type": "markdown",
"id": "5521f190",
"id": "f2b0ee83",
"metadata": {},
"source": [
"# Кубические сплайны\n",
Expand Down Expand Up @@ -354,7 +354,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "06f511ab",
"id": "ffdfd301",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -549,7 +549,7 @@
},
{
"cell_type": "markdown",
"id": "d7504e92",
"id": "33c9fbfe",
"metadata": {},
"source": [
"**Случай равноотстоящих точек**"
Expand All @@ -558,7 +558,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "8ac2ae63",
"id": "76cbb8c4",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -760,7 +760,7 @@
},
{
"cell_type": "markdown",
"id": "7a70272e",
"id": "81a0e352",
"metadata": {},
"source": [
"**Оценка порядка сходимости**\n",
Expand All @@ -771,7 +771,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "265bf1e2",
"id": "4145db93",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -928,7 +928,7 @@
},
{
"cell_type": "markdown",
"id": "a3cfb703",
"id": "2a5bdc15",
"metadata": {},
"source": [
"```{raw} html\n",
Expand Down
8 changes: 4 additions & 4 deletions _sources/interpolation/ex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "b4da4fcb",
"id": "6be74e20",
"metadata": {
"tags": [
"remove-cell"
Expand All @@ -27,7 +27,7 @@
},
{
"cell_type": "markdown",
"id": "ba0cd4d0",
"id": "4916b002",
"metadata": {},
"source": [
"# Задания\n",
Expand Down Expand Up @@ -98,7 +98,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "9984687f",
"id": "725b0472",
"metadata": {
"tags": [
"remove-input"
Expand Down Expand Up @@ -219,7 +219,7 @@
},
{
"cell_type": "markdown",
"id": "630d3d35",
"id": "c8ecb9cc",
"metadata": {},
"source": [
"В качестве ответа вам необходимо предоставить следующее.\n",
Expand Down
Loading

0 comments on commit ee9b9f4

Please sign in to comment.