Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
55549caa
Commit
55549caa
authored
Feb 28, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Newton-Raphson header file.
parent
f5e46532
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
modsim/ass2/newton_raphson.h
modsim/ass2/newton_raphson.h
+1
-1
modsim/ass2/q3.c
modsim/ass2/q3.c
+9
-2
modsim/ass2/q4.c
modsim/ass2/q4.c
+1
-1
No files found.
modsim/ass2/newton_raphson.h
View file @
55549caa
...
...
@@ -2,7 +2,7 @@
#define MAX_STEPS 1000
double
newton_raphson
(
func_ptr
f
,
func_ptr
df
,
double
x_start
,
int
*
steps
)
{
double
newton_raphson
(
func_ptr
f
,
func_ptr
df
,
double
x_start
,
unsigned
int
*
steps
)
{
double
x
=
x_start
,
last_x
=
x
-
1
;
for
(
*
steps
=
0
;
x
!=
last_x
;
(
*
steps
)
++
)
{
...
...
modsim/ass2/q3.c
View file @
55549caa
...
...
@@ -6,15 +6,22 @@
#define EPSILON 1e-11
double
quad
(
double
x
)
{
double
f
(
double
x
)
{
return
x
*
x
-
2
;
}
double
df
(
double
x
)
{
return
2
*
x
;
}
int
main
(
void
)
{
unsigned
int
steps
;
printf
(
"Square root of 2 using bisection method: %.11f (%d steps)
\n
"
,
bisec
(
&
quad
,
1
.
4
,
1
.
5
,
EPSILON
,
&
steps
),
steps
);
bisec
(
&
f
,
1
.
4
,
1
.
5
,
EPSILON
,
&
steps
),
steps
);
printf
(
"Square root of 2 using newton_raphson method: %.11f (%d steps)
\n
"
,
newton_raphson
(
&
f
,
&
df
,
1
.
4
,
&
steps
),
steps
);
return
0
;
}
modsim/ass2/q4.c
View file @
55549caa
...
...
@@ -35,7 +35,7 @@ double df3(double x) {
}
int
main
(
void
)
{
int
steps
;
unsigned
int
steps
;
double
root
;
if
(
!
isnan
(
root
=
newton_raphson
(
&
f2
,
&
df2
,
1000000
,
&
steps
))
)
...
...
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