473,382 Members | 1,775 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,382 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 14643
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.