Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-24fa
minimathematica
Commits
373c84a8
Commit
373c84a8
authored
6 months ago
by
Adam Blank
Browse files
Options
Download
Email Patches
Plain Diff
Re-write arctan(x)
parent
a0b3acfd
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/taylor.py
+5
-10
src/taylor.py
with
5 additions
and
10 deletions
+5
-10
src/taylor.py
View file @
373c84a8
...
...
@@ -61,21 +61,16 @@ def estimate(func_name, x, a, func_at_a, N):
PI
=
3.14159265358979323846264338327950288419716939937510582097494
@
cache
def
arctan
(
x
):
N
=
10
if
x
==
0
:
return
0
,
0
elif
x
==
1
:
return
pi
/
4
,
Decimal
(
10
**-
16
)
a
=
0
total_error
=
Decimal
(
0
)
prev_value
=
0
while
a
+
1
<=
x
:
prev_value
=
estimate
(
'arctan'
,
a
+
1
,
a
,
prev_value
,
N
)
total_error
+=
max_error
(
'arctan'
,
a
,
a
+
1
,
N
)
a
+=
1
return
estimate
(
'arctan'
,
x
,
floor
(
x
),
prev_value
,
N
),
total_error
+
max_error
(
'arctan'
,
floor
(
x
),
x
,
N
)
return
PI
/
4
,
10
**
(
-
1
)
total_error
=
max_error
(
'arctan'
,
floor
(
x
),
x
,
N
)
prev_value
,
total_error
=
arctan
(
floor
(
float
(
x
)
-
0.0001
))
return
float
(
estimate
(
'arctan'
,
x
,
floor
(
x
),
prev_value
,
N
)),
total_error
+
float
(
max_error
(
'arctan'
,
floor
(
x
),
x
,
N
))
if
__name__
==
"__main__"
:
for
i
in
range
(
0
,
4
):
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help