Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Taddeüs Kroes
uva
Commits
55549caa
Commit
55549caa
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Fixed Newton-Raphson header file.
parent
f5e46532
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modsim/ass2/newton_raphson.h
+1
-1
1 addition, 1 deletion
modsim/ass2/newton_raphson.h
modsim/ass2/q3.c
+9
-2
9 additions, 2 deletions
modsim/ass2/q3.c
modsim/ass2/q4.c
+1
-1
1 addition, 1 deletion
modsim/ass2/q4.c
with
11 additions
and
4 deletions
modsim/ass2/newton_raphson.h
+
1
−
1
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
)
++
)
{
...
...
This diff is collapsed.
Click to expand it.
modsim/ass2/q3.c
+
9
−
2
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
;
}
This diff is collapsed.
Click to expand it.
modsim/ass2/q4.c
+
1
−
1
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
))
)
...
...
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