
-----------------------------------
chromium
Sat Mar 01, 2014 7:51 pm

Can someone explain this question
-----------------------------------
Im not understanding what this questions is asking:
http://i.stack.imgur.com/HmSxx.png

Please can someone explain it to me. Thanks.

-----------------------------------
Panphobia
Sat Mar 01, 2014 8:13 pm

RE:Can someone explain this question
-----------------------------------
It seems pretty simple, I just solved it. You just need to implement a recursive function that uses that approximation expression. So basically if you know what recursion is, you know you want the function to stop calling itself at some time, so this is your base case, in the question it says exactly when to stop. So 
[code]
if(TARGET HAS BEEN MET)
     return answer
else 
     RECURSIVE CALL[/code]

-----------------------------------
chromium
Sat Mar 01, 2014 8:34 pm

Re: RE:Can someone explain this question
-----------------------------------
It seems pretty simple, I just solved it. You just need to implement a recursive function that uses that approximation expression. So basically if you know what recursion is, you know you want the function to stop calling itself at some time, so this is your base case, in the question it says exactly when to stop. So 


But what am i supposed to be returning? The cube root of 'a'?

-----------------------------------
Panphobia
Sat Mar 01, 2014 8:39 pm

RE:Can someone explain this question
-----------------------------------
which is t, so yes!

-----------------------------------
chromium
Sat Mar 01, 2014 8:48 pm

Re: RE:Can someone explain this question
-----------------------------------
which is t, so yes!
K Ive done this so far:

[code]    public static double betterCubeRoot (double a, double t)
    {
        double tCubed = Math.pow (t, 3);
        double dif = Math.abs (tCubed - a);

        double eq = ((a / (t * t)) + 2 * t) / 3;
        
        if (dif < 0.001)
        {
            return eq;
        }
        else
        {
            
            return betterCubeRoot (eq, t) ;

        }
    }[/code]
Im still kind of unsure of what the values of a and t are.

-----------------------------------
Panphobia
Sat Mar 01, 2014 8:50 pm

RE:Can someone explain this question
-----------------------------------
a is the number you're trying to get the cube of
t is the cube root approximation

so with that out there, looking at your recursive call, is it right?

-----------------------------------
chromium
Sat Mar 01, 2014 8:52 pm

Re: RE:Can someone explain this question
-----------------------------------
a is the number you're trying to get the cube of
t is the cube root approximation

so with that out there, looking at your recursive call, is it right?

I dont think so. It isnt correctly returning the cube root of a. What initial value should t have?

-----------------------------------
Panphobia
Sat Mar 01, 2014 8:58 pm

Re: Can someone explain this question
-----------------------------------
For this to work t can start out as any positive number, but anyway. Look at your logic right now, go through your code and figure out where the problem is. You are passing it a value t in your main function/method, but is t ever changed? Also a is supposed to stay constant since it is the number you are comparing to t^3. Look at your base case too, you are checking if Math.abs(t*t*t-a) < 0.001, so why are you returning eq? the difference was calculating with t, not eq.

-----------------------------------
Insectoid
Sat Mar 01, 2014 9:06 pm

RE:Can someone explain this question
-----------------------------------
Read through the question again, it tells you.
