× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



There is no "easy and good approximation" technique for cube roots.  Here are three methods to do what you want. 
 
Using system APIs, convert input argument to log(10), divide by 3, convert back. 
 
Use the power API function to raise the input argument to the 0.333... power. 
 
Write an RPG program:
 
Assign some value to a variable called tolerance. 
Using some technique that you invent, compute a seed value from input argument and assign it to a variable named work. 
TAG: Cube variable work into a variable named cube. 
Subtract the input value from cube and assign to a variable named difference. 
If the absolute value of difference is greater than tolerance,
    if difference is positive, adjust work down
    if difference is negative, adjust work up
    Go to tag
else
    the current value of work is the cube root of input argument
end
 
You should be able to make this into a nice tight little loop, I wrote it in this style because we don't have to have any arguments about syntax or language.  The RPG program is, in fact, the missing approximation technique noted in the first sentence.  You will note that it uses a technique called successive approximation.  It is good but not easy - it may require a lot of CPU cycles in the cubing function to discover the answer. 
 
Richard Jackson
(speaking only for myself)
 
 -----Original Message-----
From: owner-rpg400-l@midrange.com [mailto:owner-rpg400-l@midrange.com]On Behalf Of Walter Hesius
Sent: Wednesday, February 14, 2001 3:06 PM
To: RPG400-L@midrange.com
Subject: Cube root

Hi all,
 
I would like to know a way to calculate the cube root of a number. We are on V4R4.
 
Thanx.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.