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(rootE st)) 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,
curNumIteration s;
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 >maxIteration s;
cout << endl << "Using the following data" << endl
<< "Initial guess: " << rootEst << endl
<< "Tolerance: " << tolerance << ", and" << endl
<< "Maximum iterations: " << maxIterations << "." << endl;
curNumIteration s = getRoot(rootEst , tolerance, maxIterations);
if(curNumIterat ions maxIterations) {
cout << "After " << maxIterations << " iterations no solution was
found!" << endl;
}
else {
cout << "The solution is: " << rootEst << " and it was found in "
<< curNumIteration s << " 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\Visua l Studio 2005\Projects\t est\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. 2 1759
On 21 Mar 2007 16:54:04 -0700 in comp.lang.c++, "Andrew"
<an*********@gm ail.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.
On Mar 21, 4:54 pm, "Andrew" <andrew.b...@gm ail.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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
called reportlab.pth in the pythod dir. The only line in this file
is supposed to be the path to the reportlib dir.
Then I'm instructed to open the ... ok I'll close and reopen ... the
python cmd line interpreter and type
import reportlab
|
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 to
recover this information if the views are corrupted and through
errors?
thanks,
Lowly developer
|
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 'problem' line below in the
function.
function checkEmail(f){
// check for a valid emailadress
var field = f;
// alert(field.value);
var str = field.value;
|
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 the list boxes the relative text
input field is formatted d/m/y, the format that the cgi is expecting. The
user can also input directly to the text inputs and I would like to route
whatever the user inputs through a filter using regexes wherever...
|
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 for this
condition.
What can I do to get access to return an error on my query?
Thanks
| |
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 WinForms interface and then
need to port that to a web app. I am kinda stuck on a design issue and need
some suggestions / direction.
Basically I have a business layer that I want to use to process any
dataentry logic (row focus changes, data...
|
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 4.3.3 and Intel 8.0, and with fewer errors on
VC8.0 beta, so I don't think the errors reflect non-conformance with the C++
standard.
I've found I can eliminate most of the errors by surrounding the declarations
with
|
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 the
sequence nos and it should be such that i can access it through the
structure .plz help me .
|
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 both on
the file system and in a mySql database. 90% of the time it works just
fine. But for some reason, with some photos, it doesn't work. The
image never shows up on the filesystem and there is no entry in the
database. I feel it's a problem...
|
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 kinds of
errors... just to give you a number of errors it is 888 :) All these
errors aren't syntax errors in code behind files. I see all these
in .aspx pages for instanse...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |