473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Numerical methods

11
Hello im only new here. i just wanna ask if you could solve this problem in newton-rhapson's method although the prescribe one is secant method.
the problem is, f(x)= sinx + cos(1+x^2)-1
where x is in radians and make four iterations w/ initial values of
a)Xi-1 = 1 and Xi=3

and graph the results.
Jul 30 '07 #1
11 3599
JosAH
11,448 Expert 8TB
Hello im only new here. i just wanna ask if you could solve this problem in newton-rhapson's method although the prescribe one is secant method.
the problem is, f(x)= sinx + cos(1+x^2)-1
where x is in radians and make four iterations w/ initial values of
a)Xi-1 = 1 and Xi=3

and graph the results.
If I recall correctly, the secant method is for root finding; the Newton/Raphson
method approximates an integral. The Newton root finding method is easy:

first find the first derivative f'(x) of f w.r.t. x and apply the following repeatedly:

x(n+1) = x(n)-delta
delta= f(x(n))/f'(x(n))

until |delta| < epsilon, where epsilon is a small posititve value and x(0) is your
first estimation.

kind regards,

Jos
Jul 30 '07 #2
jendrin
11
If I recall correctly, the secant method is for root finding; the Newton/Raphson
method approximates an integral. The Newton root finding method is easy:

first find the first derivative f'(x) of f w.r.t. x and apply the following repeatedly:

x(n+1) = x(n)-delta
delta= f(x(n))/f'(x(n))

until |delta| < epsilon, where epsilon is a small posititve value and x(0) is your
first estimation.

kind regards,

Jos
i forgot we are ask to find the 1st positive root. what is delta? and can you pls somehow tell me how to find the derivative?
Jul 30 '07 #3
i forgot we are ask to find the 1st positive root. what is delta? and can you pls somehow tell me how to find the derivative?
To find a positive make sure that you input a positive number as an approximation to the root.

The derivative of the function is found by basic calculus, not sure if this falls under the domain of the scripts. You must know differentiation to use the Newton-Rhapson method.

delta as defined is the ratio of f(x) and its derivative, f ' (x), evaluated at the ith approximation to the root.

If you can't differentiate a function I suggest you use the secant method or the bisection method.

Code for these algorithms can be found at www.nr.com
Jul 30 '07 #4
JosAH
11,448 Expert 8TB
To find a positive make sure that you input a positive number as an approximation to the root.
That is not true; example f(x) = (x+2)*(x-10); for all x(0) < 4 and > 0 the negative
root will be found by the iteration.

kind regards,

Jos
Jul 30 '07 #5
That is not true; example f(x) = (x+2)*(x-10); for all x(0) < 4 and > 0 the negative
root will be found by the iteration.

kind regards,

Jos
My apologies, you are quite right. Entering a positive approximation will not always return a positive root.
Jul 30 '07 #6
JosAH
11,448 Expert 8TB
My apologies, you are quite right. Entering a positive approximation will not always return a positive root.
No need to apologize; I was just nitpicking, that's the way I am ;-)

kind regards,

Jos
Jul 30 '07 #7
jendrin
11
To find a positive make sure that you input a positive number as an approximation to the root.

The derivative of the function is found by basic calculus, not sure if this falls under the domain of the scripts. You must know differentiation to use the Newton-Rhapson method.

delta as defined is the ratio of f(x) and its derivative, f ' (x), evaluated at the ith approximation to the root.

If you can't differentiate a function I suggest you use the secant method or the bisection method.

Code for these algorithms can be found at www.nr.com
thanks for the help guys. my prof wants us to do this using newton rhapsons method. can i just use the given Xi and disregard the Xi-1?
Jul 31 '07 #8
JosAH
11,448 Expert 8TB
thanks for the help guys. my prof wants us to do this using newton rhapsons method. can i just use the given Xi and disregard the Xi-1?
I was wrong about my assumption that the Newton-Raphson method deals with
approximation of closed integrals. And yes, if Xi-1 represents the previous
estimation you can forget about it after you've calculated Xi (read my previous
reply again).

kind regards,

Jos
Jul 31 '07 #9
jendrin
11
I was wrong about my assumption that the Newton-Raphson method deals with
approximation of closed integrals. And yes, if Xi-1 represents the previous
estimation you can forget about it after you've calculated Xi (read my previous
reply again).

kind regards,

Jos
xi-1 is meant to be for the secant method, but in newton's method only xi is needed. can i just discard it and get the same root?and btw can i graph using c++?
Aug 1 '07 #10
JosAH
11,448 Expert 8TB
xi-1 is meant to be for the secant method, but in newton's method only xi is needed. can i just discard it and get the same root?and btw can i graph using c++?
Hold on for a second; first you have to implement that Newton (+ Raphson)
iteration. Perform the following steps:

1) let h be a very small positive number
2) let i = 0
2) let x(i) be an estimation of the root you want to find
3) let f'(x) be the first derivative of f(x)
4) let delta = f(x(i)/f'(x(i))
5) let x(i+1)= x(i)-delta
6) let i = i+1
7) if |delta| > h goto step 4

if you can't find f'(x) analytically you can use an approximation:
((f(x+h)-f(x-h))/2h for it.

Graphing something is an entirely different subject; first you have to understand
how that NR method works.

kind regards,

Jos
Aug 1 '07 #11
xi-1 is meant to be for the secant method, but in newton's method only xi is needed. can i just discard it and get the same root?and btw can i graph using c++?
Graphics in C++ is an entirely different matter.

If you want to graph your function to determine an initial approximation to the root then use a graphing package such as Excel, Mathematica, Maple, MatLab, Gnuplot. If you cannot graph the function then you should start your iterations at something like x = 0.

If you want to use Newton-Rhapson it's best if you know the derivative of the function before hand. If you try numerically differentiating your function you are just introducing errors into the calculation. There are plenty of resources on the web that will teach you how to differentiate, if you don't already know. Either google differentiation or go to mathworld.wolfram.com

What code have you done so far?
Aug 1 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rob Miller | last post by:
A new book with a numerical library in Java was published in August 2003. Title: "A Numerical Library in Java for Scientists and Engineers" Author: Hang T. Lau ISBN: 1584884304 Published date:...
5
by: Jorn Attermann | last post by:
I perform numerical simulation which requires linear algebra programming that is optimized for speed. However, to my surprise, there seems to be no "standard" linear algebra library in C++ which is...
81
by: Jonas Smithson | last post by:
I recently read the claim somewhere that numerical entities (such as —) have a speed advantage over the equivalent named entities (such as &mdash;) because the numerical entity requires just a...
14
by: Steven T. Hatton | last post by:
Can anyone recommend a good book on numerical methods that presents the subject using C++ in an ideal manner? -- "If our hypothesis is about anything and not about some one or more particular...
31
by: JS | last post by:
We have the same floating point intensive C++ program that runs on Windows on Intel chip and on Sun Solaris on SPARC chips. The program reads the exactly the same input files on the two platforms....
23
by: Abhi | last post by:
Hi.. I wanted the C source code in machine readable format for the book "Numerical Recipes in C". I got hold of the pdf version of the book somehow. Does anyone have the complete C code of the...
1
by: j.f.c.neves | last post by:
Hello, I need some help in using the rlft3 (Numerical Recipes in c++ book, Chapter 12) to apply a Gaussian smoothing to a 2D image. How do I create a suitable filter function (page 535)? ...
17
by: Albert Hopkins | last post by:
This issue may have been referred to in news:<mailman.1864.1196703799.13605.python-list@python.orgbut I didn't entirely understand the explanation. Basically I have this: 6.0 nan 6.0 nan ...
0
by: Johannes Nix | last post by:
Hi, this might be of interest for people who are look for practical information on doing real-time signal processing, possibly using multiple CPUs, and wonder whether it's possible to use...
10
by: Babak | last post by:
Hi, I've developed a C program which contains a large number of vectors and matrices operations. Throughout my code, I used the template from the Numerical Recipes book to define vectors and...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.