473,473 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need with with some errors

Hi, I am trying to write a program to solve roots using the Newtonian
method of roots, and I am recieving several errors which I cannot
figure out... if anyone could give me a point in the right direction
it wuld be appreciaed.

Here is what I have so far:

#include <iostream>
#include <math.h>
using namespace std;

double getF(double x); //The orgional function
double getdF(double x); //The derivative of orgional function

//int getRoot(double &rootEst, double tolerance, int maxIterations);

const double e = 2.718281828459;

double getRoot(double &rootEst, double tolerance, int maxIterations)
{
int n = 1;

while( ( fabs(getF(rootEst)) tolerance ) && ( n <=
maxIterations ) )
{
rootEst = rootEst - ( getF(rootEst) / getFd(rootEst) );

n++;
}
return n;
}

double getF( x )
{
return ( pow(x, 2) * pow(e, -1 * x) - 2 );
}

double getdF( x )
{
return ( 2 * pow(e, -1 * x) * x - pow(x, 2) * pow(e, -x) );
}

int main () {

double rootEst, //The initial estimate of the root
tolerance; //The stopping tolerance
int maxIterations,
curNumIterations;

cout << "Please enter the initial estimate of the root: ";
cin >rootEst;

cout << "Please enter the tolerance: ";
cin >tolerance;

cout << "Please enter the maximum allowed iterations: ";
cin >maxIterations;

cout << endl << "Using the following data" << endl
<< "Initial guess: " << rootEst << endl
<< "Tolerance: " << tolerance << ", and" << endl
<< "Maximum iterations: " << maxIterations << "." << endl;

curNumIterations = getRoot(rootEst, tolerance, maxIterations);

if(curNumIterations maxIterations) {
cout << "After " << maxIterations << " iterations no solution was
found!" << endl;
}
else {
cout << "The solution is: " << rootEst << " and it was found in "
<< curNumIterations << " iterations" << endl;
}

return 0;

}

And here are my compile errors:

------ Build started: Project: test, Configuration: Debug Win32 ------
Compiling...
assign8.cpp
..\assign8.cpp(18) : error C3861: 'getFd': identifier not found
..\assign8.cpp(27) : error C2065: 'x' : undeclared identifier
..\assign8.cpp(28) : error C2448: 'getF' : function-style initializer
appears to be a function definition
..\assign8.cpp(33) : error C2448: 'getdF' : function-style initializer
appears to be a function definition
Build log was saved at "file://c:\Documents and Settings\Janet Lannon
\My Documents\Visual Studio 2005\Projects\test\test\Debug
\BuildLog.htm"
test - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
I am a student and new to this, im not looking for someone to give me
the complete solution, but hopefully help me realise whats wong with
my own. thanks.

Mar 21 '07 #1
2 1741
On 21 Mar 2007 16:54:04 -0700 in comp.lang.c++, "Andrew"
<an*********@gmail.comwrote,
>And here are my compile errors:

------ Build started: Project: test, Configuration: Debug Win32 ------
Compiling...
assign8.cpp
.\assign8.cpp(18) : error C3861: 'getFd': identifier not found
What could be more clear?

You try to call getFd().
You never defined anything with that (exact) name.
Mar 22 '07 #2
On Mar 21, 4:54 pm, "Andrew" <andrew.b...@gmail.comwrote:
<snip>
rootEst = rootEst - ( getF(rootEst) / getFd(rootEst) );
This is line 18 in your program. Look at the first error
message, now look at the actual function name... do you
see the discrepancy?

<snip>
double getF( x )
This is line 27 of your program. I think you're missing
a type specifier... The error on line 28 is just
collateral damage from this error

<snip>
double getdF( x )
This is line 33: do you see the problem here?

Mar 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Active8 | last post by:
I did this once and can't remember how <blush> so I read the reportlab user guid. It says to unzip the reportlab archive - this is on w2k, BTW, with Python23 - to a directory and make a file...
3
by: D | last post by:
Database 1 is corrupted. Database 2 was created by dba but none of the primary or foreign key constraints were ported over. TOAD won't let me export. I will try ErWin next. What is the best way...
11
by: Laiverd.COM | last post by:
Hi, In the following function I keep getting a 'Object expected at line 75 char 5' but for the life of me I cannot find the error. Maybe someone would be so kin to have a look? I indicated the...
5
by: J. J. Cale | last post by:
Little astrology program has 2 text input boxes for birth dates. There are 3 selects for day month year that will supply output to whichever text input had the focus last. If the user picks from...
8
by: frank | last post by:
Below is some code for doing and insert into one of my tables. The inserts do not work because a duplicate key exists, which I want to happen. The problem is, I cannot get access to return an error...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
1
by: Jonathan Turkanis | last post by:
Dear All, My latest library leads to a lot of internal errors and compiler limit errors (C1001, C1055, C1067) when compiled on VC7.1 with /Zi or /ZI. The library compiles on GCC 3.4.1, Comeau...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
3
by: Milagro | last post by:
Hello Everyone, I'm trying to debug someone elses php code. I'm actually a Perl programmer, with OO experience, but not in php. The code is supposed to upload a photo from a form and save it...
3
by: Learner | last post by:
Hello, I recently converted a VS 2003 application to VS 2005. When I compile it in VS 2005 every thing gets compiled with no errors. But when I try publishing the website I get all different...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.