Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TATA54-kurshemsida
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Snellman
TATA54-kurshemsida
Commits
5313d4b0
Commit
5313d4b0
authored
11 months ago
by
Jan Snellman
Browse files
Options
Downloads
Patches
Plain Diff
rosen notebook
parent
8b0daf03
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#126365
passed
11 months ago
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.ipynb_checkpoints/Rosen12-3-checkpoint.ipynb
+165
-18
165 additions, 18 deletions
.ipynb_checkpoints/Rosen12-3-checkpoint.ipynb
Rosen12-3.ipynb
+165
-18
165 additions, 18 deletions
Rosen12-3.ipynb
with
330 additions
and
36 deletions
.ipynb_checkpoints/Rosen12-3-checkpoint.ipynb
+
165
−
18
View file @
5313d4b0
...
...
@@ -294,7 +294,7 @@
},
{
"cell_type": "code",
"execution_count":
36
,
"execution_count":
1
,
"id": "44991d26-ebed-44ad-9883-e49b90842e8e",
"metadata": {},
"outputs": [],
...
...
@@ -304,7 +304,7 @@
},
{
"cell_type": "code",
"execution_count":
41
,
"execution_count":
2
,
"id": "a05c12c9-9df9-464d-b932-62a81a1d4429",
"metadata": {},
"outputs": [],
...
...
@@ -316,7 +316,15 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": null,
"id": "7ffc1d57-0784-4119-825f-32f5459cc945",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1f050106-4454-441f-ab17-869bb1e7deb9",
"metadata": {},
"outputs": [
...
...
@@ -328,7 +336,7 @@
" (-0.6299605249474365? + 1.091123635971722?*I, 1)]"
]
},
"execution_count":
42
,
"execution_count":
5
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -339,7 +347,58 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 7,
"id": "3327b8b5-8e8e-4f34-97d0-8b24e06410e2",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"1.259921049894873?"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa0=f0.roots()[0][0]\n",
"alfa0"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "4ddb6330-657c-4387-b902-6e055b0097b0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"continued_fraction(alfa0)"
]
},
{
"cell_type": "raw",
"id": "d800b558-13db-47be-be2c-a1a878594129",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 9,
"id": "78e5e15c-0cc0-4dff-a8a2-5693f4b4a339",
"metadata": {},
"outputs": [
...
...
@@ -349,7 +408,7 @@
"x^3 - 3*x^2 - 3*x - 1"
]
},
"execution_count":
46
,
"execution_count":
9
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -386,7 +445,29 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 10,
"id": "c54abfa7-4930-4a3f-9c2c-3bf05d5b32a0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[3; 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, ...]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa1=f1.roots()[0][0]\n",
"continued_fraction(alfa1)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "5801d40e-a2a8-46e9-bdd9-39b33d52f83f",
"metadata": {},
"outputs": [
...
...
@@ -396,7 +477,7 @@
"10*x^3 - 6*x^2 - 6*x - 1"
]
},
"execution_count":
48
,
"execution_count":
12
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -410,7 +491,7 @@
},
{
"cell_type": "code",
"execution_count":
49
,
"execution_count":
13
,
"id": "c4c0bc9d-9bbf-4d8d-b063-d1dc78245ff6",
"metadata": {},
"outputs": [
...
...
@@ -422,7 +503,7 @@
" (-0.2900943677742046? + 0.02403056328910778?*I, 1)]"
]
},
"execution_count":
49
,
"execution_count":
13
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -433,7 +514,29 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 14,
"id": "c049c466-ebf9-4853-9ebf-2be2a169b069",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1; 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, ...]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa2=f2.roots()[0][0]\n",
"continued_fraction(alfa2)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "9953eae5-e5d1-48f6-bda3-e464b1a6c6c1",
"metadata": {},
"outputs": [
...
...
@@ -443,7 +546,7 @@
"3*x^3 - 12*x^2 - 24*x - 10"
]
},
"execution_count":
50
,
"execution_count":
16
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -457,7 +560,7 @@
},
{
"cell_type": "code",
"execution_count":
5
1,
"execution_count": 1
7
,
"id": "0a66ff0f-dc17-42ae-b8ee-6535c8541aac",
"metadata": {},
"outputs": [
...
...
@@ -469,7 +572,7 @@
" (-0.7748682428911940? + 0.01443345604526783?*I, 1)]"
]
},
"execution_count":
5
1,
"execution_count": 1
7
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -480,7 +583,29 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 18,
"id": "b4fc68d2-c006-43ce-945d-f809360adb11",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[5; 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, ...]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa3=f3.roots()[0][0]\n",
"continued_fraction(alfa3)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "0c50aa3c-5f4c-4d34-bc2f-a5de911952b9",
"metadata": {},
"outputs": [
...
...
@@ -490,7 +615,7 @@
"55*x^3 - 81*x^2 - 33*x - 3"
]
},
"execution_count":
5
2,
"execution_count": 2
0
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -504,7 +629,7 @@
},
{
"cell_type": "code",
"execution_count":
53
,
"execution_count":
21
,
"id": "d99ecd1d-0a85-4ebb-a69b-546456037c87",
"metadata": {},
"outputs": [
...
...
@@ -516,7 +641,7 @@
" (-0.1731630422019992? + 0.00043279622203746?*I, 1)]"
]
},
"execution_count":
53
,
"execution_count":
21
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -525,6 +650,28 @@
"f4.roots()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "c72bd901-5e62-4abf-ab21-758fc8a6d91d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1; 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, 4, ...]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa4=f4.roots()[0][0]\n",
"continued_fraction(alfa4)"
]
},
{
"cell_type": "code",
"execution_count": 54,
...
...
%% Cell type:code id:a0564571-faf2-47f7-80b8-6b93da370de6 tags:
```
sage
# 12.3.1c
```
%% Cell type:code id:97f1a9eb-89f3-493e-a564-9ceed016b7ba tags:
```
sage
N=6
alpha = vector(QQbar,[0 for _ in range(N)])
a = vector(QQbar,[0 for _ in range(N)])
t = vector(QQbar,[0 for _ in range(N)])
```
%% Cell type:code id:43236aea-32a2-4b2e-ad87-674ea0443341 tags:
```
sage
```
%% Cell type:code id:4c58f2d2-829b-4e8e-8b41-e18241a04c39 tags:
```
sage
alpha[0] = sqrt(5)
```
%% Cell type:code id:d239123d-8f1d-4c2a-8723-e488035f4882 tags:
```
sage
for k in range(N-1):
a[k], t[k] = floor(alpha[k]), alpha[k] - floor(alpha[k])
alpha[k+1] = 1 / t[k]
print(k,alpha[k], a[k], t[k])
```
%% Output
0 2.236067977499790? 2 0.2360679774997897?
1 4.236067977499789? 4 0.2360679774997897?
2 4.236067977499789? 4 0.2360679774997897?
3 4.23606797749979? 4 0.23606797749979?
4 4.2360679774998? 4 0.2360679774998?
%% Cell type:code id:91e64dfc-7d82-41da-97a3-907b70fb04cf tags:
```
sage
continued_fraction(alpha[0])
```
%% Output
[2; 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...]
%% Cell type:code id:4805e461-de3a-4ad1-b68b-0ac1254a9fa2 tags:
```
sage
continued_fraction(alpha[1])
```
%% Output
[4; 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...]
%% Cell type:code id:74e5c6b5-4141-48a2-9ed0-5145ec962206 tags:
```
sage
continued_fraction(t[1])
```
%% Output
[0; 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...]
%% Cell type:code id:ce40fb53-525d-4778-ab65-d3b9de12fd0a tags:
```
sage
```
%% Cell type:code id:5f179ca2-6fe2-4acf-8ee5-efc16c9f92d7 tags:
```
sage
alpha[0] = sqrt(19)-1
for k in range(N-1):
a[k], t[k] = floor(alpha[k]), alpha[k] - floor(alpha[k])
alpha[k+1] = 1 / t[k]
print(k,alpha[k], a[k], t[k])
```
%% Output
0 3.358898943540674? 3 0.3588989435406736?
1 2.786299647846891? 2 0.7862996478468912?
2 1.271779788708135? 1 0.2717797887081347?
3 3.679449471770337? 3 0.679449471770337?
4 1.471779788708135? 1 0.471779788708135?
%% Cell type:code id:befb67c1-8720-4d6f-88da-1920b91edfab tags:
```
sage
continued_fraction(alpha[0])
```
%% Output
[3; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:73ca37dd-732c-4614-87e5-f546b69ff166 tags:
```
sage
continued_fraction(t[0])
```
%% Output
[0; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:3e32ecf1-bb17-4e8c-88cc-ab86cb26c262 tags:
```
sage
continued_fraction(1/t[0])
```
%% Output
[2; 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, ...]
%% Cell type:code id:ad4f7e53-2f82-4592-b1b1-ce52cc96373f tags:
```
sage
continued_fraction(a[0] + t[0])
```
%% Output
[3; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:2a3daa68-23ea-4292-b642-b9b293468494 tags:
```
sage
continued_fraction(a[0] + 1/(a[1] +t[1]))
```
%% Output
[3; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:e33f1445-ebf7-4ad9-8441-093613207188 tags:
```
sage
```
%% Cell type:code id:1c92946d-cb2e-458f-967e-c10cc12be1aa tags:
```
sage
```
%% Cell type:code id:e5b2db5f-d125-43eb-837f-27896ceabd02 tags:
```
sage
```
%% Cell type:code id:44991d26-ebed-44ad-9883-e49b90842e8e tags:
```
sage
#12.3.2.a
```
%% Cell type:code id:a05c12c9-9df9-464d-b932-62a81a1d4429 tags:
```
sage
R.
<x>
= QQbar[]
f0 = x^3-2
d=3
```
%% Cell type:code id:7ffc1d57-0784-4119-825f-32f5459cc945 tags:
```
sage
```
%% Cell type:code id:1f050106-4454-441f-ab17-869bb1e7deb9 tags:
```
sage
f0.roots()
```
%% Output
[(1.259921049894873?, 1),
(-0.6299605249474365? - 1.091123635971722?*I, 1),
(-0.6299605249474365? + 1.091123635971722?*I, 1)]
%% Cell type:code id:3327b8b5-8e8e-4f34-97d0-8b24e06410e2 tags:
```
sage
alfa0=f0.roots()
[
0
][
0
]
alfa0
```
%% Output
1.259921049894873?
%% Cell type:code id:4ddb6330-657c-4387-b902-6e055b0097b0 tags:
```
sage
continued_fraction(alfa0)
```
%% Output
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...]
%% Cell type:raw id:d800b558-13db-47be-be2c-a1a878594129 tags:
%% Cell type:code id:78e5e15c-0cc0-4dff-a8a2-5693f4b4a339 tags:
```
sage
a0 = 1
f1 = (-x)^d
*
f0(a0 + 1/x)
f1 =R(f1)
f1
```
%% Output
x^3 - 3*x^2 - 3*x - 1
%% Cell type:code id:5d9d0f98-5ecc-4e6a-b074-813c329fdbf1 tags:
```
sage
f1.roots()
```
%% Output
[(3.847322101863073?, 1),
(-0.4236610509315363? - 0.2836060010268813?*I, 1),
(-0.4236610509315363? + 0.2836060010268813?*I, 1)]
%% Cell type:code id:c54abfa7-4930-4a3f-9c2c-3bf05d5b32a0 tags:
```
sage
alfa1=f1.roots()
[
0
][
0
]
continued_fraction(alfa1)
```
%% Output
[3; 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, ...]
%% Cell type:code id:5801d40e-a2a8-46e9-bdd9-39b33d52f83f tags:
```
sage
a1 = 3
f2 = (-x)^d
*
f1(a1 + 1/x)
f2 =R(f2)
f2
```
%% Output
10*x^3 - 6*x^2 - 6*x - 1
%% Cell type:code id:c4c0bc9d-9bbf-4d8d-b063-d1dc78245ff6 tags:
```
sage
f2.roots()
```
%% Output
[(1.180188735548410?, 1),
(-0.2900943677742046? - 0.02403056328910778?*I, 1),
(-0.2900943677742046? + 0.02403056328910778?*I, 1)]
%% Cell type:code id:c049c466-ebf9-4853-9ebf-2be2a169b069 tags:
```
sage
alfa2=f2.roots()
[
0
][
0
]
continued_fraction(alfa2)
```
%% Output
[1; 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, ...]
%% Cell type:code id:9953eae5-e5d1-48f6-bda3-e464b1a6c6c1 tags:
```
sage
a2 = 1
f3 = (-x)^d
*
f2(a2 + 1/x)
f3 =R(f3)
f3
```
%% Output
3*x^3 - 12*x^2 - 24*x - 10
%% Cell type:code id:0a66ff0f-dc17-42ae-b8ee-6535c8541aac tags:
```
sage
f3.roots()
```
%% Output
[(5.549736485782388?, 1),
(-0.7748682428911940? - 0.01443345604526783?*I, 1),
(-0.7748682428911940? + 0.01443345604526783?*I, 1)]
%% Cell type:code id:b4fc68d2-c006-43ce-945d-f809360adb11 tags:
```
sage
alfa3=f3.roots()
[
0
][
0
]
continued_fraction(alfa3)
```
%% Output
[5; 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, ...]
%% Cell type:code id:0c50aa3c-5f4c-4d34-bc2f-a5de911952b9 tags:
```
sage
a3 = 5
f4 = (-x)^d
*
f3(a3 + 1/x)
f4 =R(f4)
f4
```
%% Output
55*x^3 - 81*x^2 - 33*x - 3
%% Cell type:code id:d99ecd1d-0a85-4ebb-a69b-546456037c87 tags:
```
sage
f4.roots()
```
%% Output
[(1.819053357131272?, 1),
(-0.1731630422019992? - 0.00043279622203746?*I, 1),
(-0.1731630422019992? + 0.00043279622203746?*I, 1)]
%% Cell type:code id:c72bd901-5e62-4abf-ab21-758fc8a6d91d tags:
```
sage
alfa4=f4.roots()
[
0
][
0
]
continued_fraction(alfa4)
```
%% Output
[1; 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, 4, ...]
%% Cell type:code id:468aa920-5d96-4aba-af0d-906c8823f6c4 tags:
```
sage
continued_fraction(2^(1/3))
```
%% Output
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...]
%% Cell type:code id:73ee5ba0-8a57-4afc-a637-3ef24d89ad58 tags:
```
sage
```
%% Cell type:code id:c9930f4b-758a-4edd-b462-827914d8f867 tags:
```
sage
```
%% Cell type:code id:d742e1d1-7935-46ee-bd91-3037e9791149 tags:
```
sage
#12.3.4
```
%% Cell type:code id:cd9a0eb9-823a-46cf-a3ce-ce344d55ceb4 tags:
```
sage
a=vector([2,1,2,1,1,4])
N=len(a)
v=[]
v.append(vector([1,0]))
v.append(vector([0,1]))
```
%% Cell type:code id:22b9d3bd-d905-4ecc-a841-0469335e7707 tags:
```
sage
v
```
%% Output
[(1, 0), (0, 1)]
%% Cell type:code id:a89b77b0-93bf-4c2a-82db-f1f1a7d99938 tags:
```
sage
for k in range(N):
v.append(a[k]
*
v[-1] + v[-2])
```
%% Cell type:code id:5f5c0c05-47f0-4538-8046-1a75fe629b55 tags:
```
sage
v
```
%% Output
[(1, 0), (0, 1), (1, 2), (1, 3), (3, 8), (4, 11), (7, 19), (32, 87)]
%% Cell type:code id:b8feab8b-f3ed-477c-8ee2-9f88a8728ea2 tags:
```
sage
conve =[c[1]/c[0] for c in v[2:]]
conve
```
%% Output
[2, 3, 8/3, 11/4, 19/7, 87/32]
%% Cell type:code id:a560f987-04f8-40a1-8b1e-366949e8464e tags:
```
sage
conve[5] - conve[4]
```
%% Output
1/224
%% Cell type:code id:dcbebe47-9e94-4540-8f4d-99f1217ca1b0 tags:
```
sage
```
...
...
This diff is collapsed.
Click to expand it.
Rosen12-3.ipynb
+
165
−
18
View file @
5313d4b0
...
...
@@ -294,7 +294,7 @@
},
{
"cell_type": "code",
"execution_count":
36
,
"execution_count":
1
,
"id": "44991d26-ebed-44ad-9883-e49b90842e8e",
"metadata": {},
"outputs": [],
...
...
@@ -304,7 +304,7 @@
},
{
"cell_type": "code",
"execution_count":
41
,
"execution_count":
2
,
"id": "a05c12c9-9df9-464d-b932-62a81a1d4429",
"metadata": {},
"outputs": [],
...
...
@@ -316,7 +316,15 @@
},
{
"cell_type": "code",
"execution_count": 42,
"execution_count": null,
"id": "7ffc1d57-0784-4119-825f-32f5459cc945",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 5,
"id": "1f050106-4454-441f-ab17-869bb1e7deb9",
"metadata": {},
"outputs": [
...
...
@@ -328,7 +336,7 @@
" (-0.6299605249474365? + 1.091123635971722?*I, 1)]"
]
},
"execution_count":
42
,
"execution_count":
5
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -339,7 +347,58 @@
},
{
"cell_type": "code",
"execution_count": 46,
"execution_count": 7,
"id": "3327b8b5-8e8e-4f34-97d0-8b24e06410e2",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"1.259921049894873?"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa0=f0.roots()[0][0]\n",
"alfa0"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "4ddb6330-657c-4387-b902-6e055b0097b0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"continued_fraction(alfa0)"
]
},
{
"cell_type": "raw",
"id": "d800b558-13db-47be-be2c-a1a878594129",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 9,
"id": "78e5e15c-0cc0-4dff-a8a2-5693f4b4a339",
"metadata": {},
"outputs": [
...
...
@@ -349,7 +408,7 @@
"x^3 - 3*x^2 - 3*x - 1"
]
},
"execution_count":
46
,
"execution_count":
9
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -386,7 +445,29 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 10,
"id": "c54abfa7-4930-4a3f-9c2c-3bf05d5b32a0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[3; 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, ...]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa1=f1.roots()[0][0]\n",
"continued_fraction(alfa1)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "5801d40e-a2a8-46e9-bdd9-39b33d52f83f",
"metadata": {},
"outputs": [
...
...
@@ -396,7 +477,7 @@
"10*x^3 - 6*x^2 - 6*x - 1"
]
},
"execution_count":
48
,
"execution_count":
12
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -410,7 +491,7 @@
},
{
"cell_type": "code",
"execution_count":
49
,
"execution_count":
13
,
"id": "c4c0bc9d-9bbf-4d8d-b063-d1dc78245ff6",
"metadata": {},
"outputs": [
...
...
@@ -422,7 +503,7 @@
" (-0.2900943677742046? + 0.02403056328910778?*I, 1)]"
]
},
"execution_count":
49
,
"execution_count":
13
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -433,7 +514,29 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 14,
"id": "c049c466-ebf9-4853-9ebf-2be2a169b069",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1; 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, ...]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa2=f2.roots()[0][0]\n",
"continued_fraction(alfa2)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "9953eae5-e5d1-48f6-bda3-e464b1a6c6c1",
"metadata": {},
"outputs": [
...
...
@@ -443,7 +546,7 @@
"3*x^3 - 12*x^2 - 24*x - 10"
]
},
"execution_count":
50
,
"execution_count":
16
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -457,7 +560,7 @@
},
{
"cell_type": "code",
"execution_count":
5
1,
"execution_count": 1
7
,
"id": "0a66ff0f-dc17-42ae-b8ee-6535c8541aac",
"metadata": {},
"outputs": [
...
...
@@ -469,7 +572,7 @@
" (-0.7748682428911940? + 0.01443345604526783?*I, 1)]"
]
},
"execution_count":
5
1,
"execution_count": 1
7
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -480,7 +583,29 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 18,
"id": "b4fc68d2-c006-43ce-945d-f809360adb11",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[5; 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, ...]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa3=f3.roots()[0][0]\n",
"continued_fraction(alfa3)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "0c50aa3c-5f4c-4d34-bc2f-a5de911952b9",
"metadata": {},
"outputs": [
...
...
@@ -490,7 +615,7 @@
"55*x^3 - 81*x^2 - 33*x - 3"
]
},
"execution_count":
5
2,
"execution_count": 2
0
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -504,7 +629,7 @@
},
{
"cell_type": "code",
"execution_count":
53
,
"execution_count":
21
,
"id": "d99ecd1d-0a85-4ebb-a69b-546456037c87",
"metadata": {},
"outputs": [
...
...
@@ -516,7 +641,7 @@
" (-0.1731630422019992? + 0.00043279622203746?*I, 1)]"
]
},
"execution_count":
53
,
"execution_count":
21
,
"metadata": {},
"output_type": "execute_result"
}
...
...
@@ -525,6 +650,28 @@
"f4.roots()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "c72bd901-5e62-4abf-ab21-758fc8a6d91d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1; 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, 4, ...]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alfa4=f4.roots()[0][0]\n",
"continued_fraction(alfa4)"
]
},
{
"cell_type": "code",
"execution_count": 54,
...
...
%% Cell type:code id:a0564571-faf2-47f7-80b8-6b93da370de6 tags:
```
sage
# 12.3.1c
```
%% Cell type:code id:97f1a9eb-89f3-493e-a564-9ceed016b7ba tags:
```
sage
N=6
alpha = vector(QQbar,[0 for _ in range(N)])
a = vector(QQbar,[0 for _ in range(N)])
t = vector(QQbar,[0 for _ in range(N)])
```
%% Cell type:code id:43236aea-32a2-4b2e-ad87-674ea0443341 tags:
```
sage
```
%% Cell type:code id:4c58f2d2-829b-4e8e-8b41-e18241a04c39 tags:
```
sage
alpha[0] = sqrt(5)
```
%% Cell type:code id:d239123d-8f1d-4c2a-8723-e488035f4882 tags:
```
sage
for k in range(N-1):
a[k], t[k] = floor(alpha[k]), alpha[k] - floor(alpha[k])
alpha[k+1] = 1 / t[k]
print(k,alpha[k], a[k], t[k])
```
%% Output
0 2.236067977499790? 2 0.2360679774997897?
1 4.236067977499789? 4 0.2360679774997897?
2 4.236067977499789? 4 0.2360679774997897?
3 4.23606797749979? 4 0.23606797749979?
4 4.2360679774998? 4 0.2360679774998?
%% Cell type:code id:91e64dfc-7d82-41da-97a3-907b70fb04cf tags:
```
sage
continued_fraction(alpha[0])
```
%% Output
[2; 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...]
%% Cell type:code id:4805e461-de3a-4ad1-b68b-0ac1254a9fa2 tags:
```
sage
continued_fraction(alpha[1])
```
%% Output
[4; 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...]
%% Cell type:code id:74e5c6b5-4141-48a2-9ed0-5145ec962206 tags:
```
sage
continued_fraction(t[1])
```
%% Output
[0; 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, ...]
%% Cell type:code id:ce40fb53-525d-4778-ab65-d3b9de12fd0a tags:
```
sage
```
%% Cell type:code id:5f179ca2-6fe2-4acf-8ee5-efc16c9f92d7 tags:
```
sage
alpha[0] = sqrt(19)-1
for k in range(N-1):
a[k], t[k] = floor(alpha[k]), alpha[k] - floor(alpha[k])
alpha[k+1] = 1 / t[k]
print(k,alpha[k], a[k], t[k])
```
%% Output
0 3.358898943540674? 3 0.3588989435406736?
1 2.786299647846891? 2 0.7862996478468912?
2 1.271779788708135? 1 0.2717797887081347?
3 3.679449471770337? 3 0.679449471770337?
4 1.471779788708135? 1 0.471779788708135?
%% Cell type:code id:befb67c1-8720-4d6f-88da-1920b91edfab tags:
```
sage
continued_fraction(alpha[0])
```
%% Output
[3; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:73ca37dd-732c-4614-87e5-f546b69ff166 tags:
```
sage
continued_fraction(t[0])
```
%% Output
[0; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:3e32ecf1-bb17-4e8c-88cc-ab86cb26c262 tags:
```
sage
continued_fraction(1/t[0])
```
%% Output
[2; 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, ...]
%% Cell type:code id:ad4f7e53-2f82-4592-b1b1-ce52cc96373f tags:
```
sage
continued_fraction(a[0] + t[0])
```
%% Output
[3; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:2a3daa68-23ea-4292-b642-b9b293468494 tags:
```
sage
continued_fraction(a[0] + 1/(a[1] +t[1]))
```
%% Output
[3; 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, 1, 3, 1, 2, 8, 2, ...]
%% Cell type:code id:e33f1445-ebf7-4ad9-8441-093613207188 tags:
```
sage
```
%% Cell type:code id:1c92946d-cb2e-458f-967e-c10cc12be1aa tags:
```
sage
```
%% Cell type:code id:e5b2db5f-d125-43eb-837f-27896ceabd02 tags:
```
sage
```
%% Cell type:code id:44991d26-ebed-44ad-9883-e49b90842e8e tags:
```
sage
#12.3.2.a
```
%% Cell type:code id:a05c12c9-9df9-464d-b932-62a81a1d4429 tags:
```
sage
R.
<x>
= QQbar[]
f0 = x^3-2
d=3
```
%% Cell type:code id:7ffc1d57-0784-4119-825f-32f5459cc945 tags:
```
sage
```
%% Cell type:code id:1f050106-4454-441f-ab17-869bb1e7deb9 tags:
```
sage
f0.roots()
```
%% Output
[(1.259921049894873?, 1),
(-0.6299605249474365? - 1.091123635971722?*I, 1),
(-0.6299605249474365? + 1.091123635971722?*I, 1)]
%% Cell type:code id:3327b8b5-8e8e-4f34-97d0-8b24e06410e2 tags:
```
sage
alfa0=f0.roots()
[
0
][
0
]
alfa0
```
%% Output
1.259921049894873?
%% Cell type:code id:4ddb6330-657c-4387-b902-6e055b0097b0 tags:
```
sage
continued_fraction(alfa0)
```
%% Output
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...]
%% Cell type:raw id:d800b558-13db-47be-be2c-a1a878594129 tags:
%% Cell type:code id:78e5e15c-0cc0-4dff-a8a2-5693f4b4a339 tags:
```
sage
a0 = 1
f1 = (-x)^d
*
f0(a0 + 1/x)
f1 =R(f1)
f1
```
%% Output
x^3 - 3*x^2 - 3*x - 1
%% Cell type:code id:5d9d0f98-5ecc-4e6a-b074-813c329fdbf1 tags:
```
sage
f1.roots()
```
%% Output
[(3.847322101863073?, 1),
(-0.4236610509315363? - 0.2836060010268813?*I, 1),
(-0.4236610509315363? + 0.2836060010268813?*I, 1)]
%% Cell type:code id:c54abfa7-4930-4a3f-9c2c-3bf05d5b32a0 tags:
```
sage
alfa1=f1.roots()
[
0
][
0
]
continued_fraction(alfa1)
```
%% Output
[3; 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, ...]
%% Cell type:code id:5801d40e-a2a8-46e9-bdd9-39b33d52f83f tags:
```
sage
a1 = 3
f2 = (-x)^d
*
f1(a1 + 1/x)
f2 =R(f2)
f2
```
%% Output
10*x^3 - 6*x^2 - 6*x - 1
%% Cell type:code id:c4c0bc9d-9bbf-4d8d-b063-d1dc78245ff6 tags:
```
sage
f2.roots()
```
%% Output
[(1.180188735548410?, 1),
(-0.2900943677742046? - 0.02403056328910778?*I, 1),
(-0.2900943677742046? + 0.02403056328910778?*I, 1)]
%% Cell type:code id:c049c466-ebf9-4853-9ebf-2be2a169b069 tags:
```
sage
alfa2=f2.roots()
[
0
][
0
]
continued_fraction(alfa2)
```
%% Output
[1; 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, ...]
%% Cell type:code id:9953eae5-e5d1-48f6-bda3-e464b1a6c6c1 tags:
```
sage
a2 = 1
f3 = (-x)^d
*
f2(a2 + 1/x)
f3 =R(f3)
f3
```
%% Output
3*x^3 - 12*x^2 - 24*x - 10
%% Cell type:code id:0a66ff0f-dc17-42ae-b8ee-6535c8541aac tags:
```
sage
f3.roots()
```
%% Output
[(5.549736485782388?, 1),
(-0.7748682428911940? - 0.01443345604526783?*I, 1),
(-0.7748682428911940? + 0.01443345604526783?*I, 1)]
%% Cell type:code id:b4fc68d2-c006-43ce-945d-f809360adb11 tags:
```
sage
alfa3=f3.roots()
[
0
][
0
]
continued_fraction(alfa3)
```
%% Output
[5; 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, ...]
%% Cell type:code id:0c50aa3c-5f4c-4d34-bc2f-a5de911952b9 tags:
```
sage
a3 = 5
f4 = (-x)^d
*
f3(a3 + 1/x)
f4 =R(f4)
f4
```
%% Output
55*x^3 - 81*x^2 - 33*x - 3
%% Cell type:code id:d99ecd1d-0a85-4ebb-a69b-546456037c87 tags:
```
sage
f4.roots()
```
%% Output
[(1.819053357131272?, 1),
(-0.1731630422019992? - 0.00043279622203746?*I, 1),
(-0.1731630422019992? + 0.00043279622203746?*I, 1)]
%% Cell type:code id:c72bd901-5e62-4abf-ab21-758fc8a6d91d tags:
```
sage
alfa4=f4.roots()
[
0
][
0
]
continued_fraction(alfa4)
```
%% Output
[1; 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, 2, 1, 3, 4, ...]
%% Cell type:code id:468aa920-5d96-4aba-af0d-906c8823f6c4 tags:
```
sage
continued_fraction(2^(1/3))
```
%% Output
[1; 3, 1, 5, 1, 1, 4, 1, 1, 8, 1, 14, 1, 10, 2, 1, 4, 12, 2, 3, ...]
%% Cell type:code id:73ee5ba0-8a57-4afc-a637-3ef24d89ad58 tags:
```
sage
```
%% Cell type:code id:c9930f4b-758a-4edd-b462-827914d8f867 tags:
```
sage
```
%% Cell type:code id:d742e1d1-7935-46ee-bd91-3037e9791149 tags:
```
sage
#12.3.4
```
%% Cell type:code id:cd9a0eb9-823a-46cf-a3ce-ce344d55ceb4 tags:
```
sage
a=vector([2,1,2,1,1,4])
N=len(a)
v=[]
v.append(vector([1,0]))
v.append(vector([0,1]))
```
%% Cell type:code id:22b9d3bd-d905-4ecc-a841-0469335e7707 tags:
```
sage
v
```
%% Output
[(1, 0), (0, 1)]
%% Cell type:code id:a89b77b0-93bf-4c2a-82db-f1f1a7d99938 tags:
```
sage
for k in range(N):
v.append(a[k]
*
v[-1] + v[-2])
```
%% Cell type:code id:5f5c0c05-47f0-4538-8046-1a75fe629b55 tags:
```
sage
v
```
%% Output
[(1, 0), (0, 1), (1, 2), (1, 3), (3, 8), (4, 11), (7, 19), (32, 87)]
%% Cell type:code id:b8feab8b-f3ed-477c-8ee2-9f88a8728ea2 tags:
```
sage
conve =[c[1]/c[0] for c in v[2:]]
conve
```
%% Output
[2, 3, 8/3, 11/4, 19/7, 87/32]
%% Cell type:code id:a560f987-04f8-40a1-8b1e-366949e8464e tags:
```
sage
conve[5] - conve[4]
```
%% Output
1/224
%% Cell type:code id:dcbebe47-9e94-4540-8f4d-99f1217ca1b0 tags:
```
sage
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment