473,405 Members | 2,287 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,405 software developers and data experts.

Tips For Find Cube Root Program Using C++

Hi,
i found the new method of find cube root of the given value.i want to implement in the c++ program.ex: if you give the answer the certain value i find the cube value.(i.e)if you give the ans 1331.i find the cube root is 11.i want to implement in the program please give some tips...
Jan 2 '08 #1
4 14645
Savage
1,764 Expert 1GB
Hi,
i found the new method of find cube root of the given value.i want to implement in the c++ program.ex: if you give the answer the certain value i find the cube value.(i.e)if you give the ans 1331.i find the cube root is 11.i want to implement in the program please give some tips...
Cube root is nothing but a double sqrt.
You sqrt once,and then sqrt result again.
If you want to find perfect cube root check whether int result on cube is same as start value,and if it is..........

Savage
Jan 2 '08 #2
oler1s
671 Expert 512MB
So what you're saying is... ((x)^.5)^.5 = x^(1/3)?

Are you absolutely certain ;)
Jan 2 '08 #3
Savage
1,764 Expert 1GB
So what you're saying is... ((x)^.5)^.5 = x^(1/3)?

Are you absolutely certain ;)
Oops,i got it wrong,i was thinking on quad root algorithm. :(

Let's see,if it is cube root then he could use pow with 1/3 as second argument..

result=pow(number,(double)1/3);

Savage
Jan 2 '08 #4
google wikipedia, there's Halley's algorithm which seems to have the nice property that it's integer implementation won't oscillate between r and r+1
(as does Newton's method for some values)
where r³ <= n <= (r+1)³ :

int icbrt(int n){ int t=0, x=(n+2)/3; /* works for n=0 and n>=1 */
for(; t!=x;){ int x3=x*x*x;
t=x; x*=(2*n + x3); x/=(2*x3 + n);
}
return(x); /* always(?) equal to floor(n^(1/3)) */
}
Oct 23 '10 #5

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

Similar topics

0
by: mrwoopey | last post by:
Hi, My OLAP data cube is giving me the following error when I am manipulating OLAP data cube views: "the data being processed is over the allowed limit" I know that this message is caused by...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
0
by: mrwoopey | last post by:
Hi, I am using the OLAP data cube in a web browser (using the code from the SQL 2000 toolkit). The OLAP services is on database server and the web interface is on the web server. If we do simple...
2
by: johnywalkyra | last post by:
Hello, first of all sorry for crossposting, but I could not decide which group is more appropriate. To my question: Recently I've came across the code in GCC standard library, which computes the...
10
by: Nkhosinathie | last post by:
hello everyone may someone please help me with this c++ program. i'm developing a program that will print numbers from 0 to 10 which must appear like a table but i;m only allowed to use if...
9
by: kj7ny | last post by:
Is there a way that I can programmatically find the name of a method I have created from within that method? I would like to be able to log a message from within that method (def) and I would like...
2
by: chitrapandy | last post by:
how to write a c program for this question. what is the concept behind this question. Assuming that a function f() and its derivative fprime() are provided, design a function to compute the roots...
5
by: Brock | last post by:
I routinely use sqrt(x) for getting a cube root in vb.net. does anyone know of a way of getting the cube root? I tried cbrt(x) and that didn't work. thanks!
8
Frinavale
by: Frinavale | last post by:
Edit Many times we spend hours and hours trying to solve a problem. When we finally figure it out, we want to share it to keep others from suffering the same way! That's why we have this "Tips...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.