Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs417-lecture-examples
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Kennedy
cs417-lecture-examples
Commits
c4d8a5b5
Commit
c4d8a5b5
authored
4 years ago
by
Thomas Kennedy
Browse files
Options
Downloads
Patches
Plain Diff
Add README.md to sqrt example
parent
2dcc9b5d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SqrtExample/README.md
+44
-0
44 additions, 0 deletions
SqrtExample/README.md
SqrtExample/sqrt_demo.py
+9
-0
9 additions, 0 deletions
SqrtExample/sqrt_demo.py
with
53 additions
and
0 deletions
SqrtExample/README.md
0 → 100644
+
44
−
0
View file @
c4d8a5b5
# Requirements
*
Python 3.7
> This code makes use of the `f"..."` or [f-string
> syntax](https://www.python.org/dev/peps/pep-0498/). This syntax was
> introduced in Python 3.6.
# Sample Execution & Output
If run using
```
./sqrt_demo.py
```
output
*simliar*
to
```
sqrt(1 + 10^-0 ) = 1.41421356237309514547462185873882845044136047363281
sqrt(1 + 10^-1 ) = 1.04880884817015163079645390098448842763900756835938
sqrt(1 + 10^-2 ) = 1.00498756211208895017250597447855398058891296386719
sqrt(1 + 10^-3 ) = 1.00049987506246096380380095069995149970054626464844
sqrt(1 + 10^-4 ) = 1.00004999875006239662411644530948251485824584960938
sqrt(1 + 10^-5 ) = 1.00000499998750003172176548105198889970779418945312
sqrt(1 + 10^-6 ) = 1.00000049999987505877641069673700258135795593261719
sqrt(1 + 10^-7 ) = 1.00000004999999880794803175376728177070617675781250
sqrt(1 + 10^-8 ) = 1.00000000499999996961264514538925141096115112304688
sqrt(1 + 10^-9 ) = 1.00000000050000004137018549954518675804138183593750
sqrt(1 + 10^-10) = 1.00000000005000000413701854995451867580413818359375
sqrt(1 + 10^-11) = 1.00000000000500000041370185499545186758041381835938
sqrt(1 + 10^-12) = 1.00000000000050004445029117050580680370330810546875
sqrt(1 + 10^-13) = 1.00000000000004996003610813204431906342506408691406
sqrt(1 + 10^-14) = 1.00000000000000488498130835068877786397933959960938
sqrt(1 + 10^-15) = 1.00000000000000044408920985006261616945266723632812
sqrt(1 + 10^-16) = 1.00000000000000000000000000000000000000000000000000
sqrt(1 + 10^-17) = 1.00000000000000000000000000000000000000000000000000
sqrt(1 + 10^-18) = 1.00000000000000000000000000000000000000000000000000
sqrt(1 + 10^-19) = 1.00000000000000000000000000000000000000000000000000
```
will be generated. Note that the output may vary.
This diff is collapsed.
Click to expand it.
SqrtExample/sqrt
D
emo.py
→
SqrtExample/sqrt
_d
emo.py
+
9
−
0
View file @
c4d8a5b5
...
...
@@ -4,5 +4,6 @@ import math
if
__name__
==
"
__main__
"
:
for
d
in
range
(
0
,
20
):
print
(
"
{:>50.20f}
"
.
format
(
math
.
sqrt
(
1
+
10
**
-
d
)))
for
power
in
range
(
0
,
20
):
result
=
math
.
sqrt
(
1
+
10
**
-
power
)
print
(
f
"
sqrt(1 + 10^-
{
power
:
<
2
d
}
) =
{
result
:
>
50.50
f
}
"
)
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