java help plz =\

Discussion in 'OT Technology' started by philvia, Mar 29, 2009.

1. philviaSUCKIN ON MY TITTIES LIKE YOU WANTIN ME CALLIN ME

Joined:
May 3, 2007
Messages:
11,618
12
Location:
NYC
I have to make 2 programs... for now i'll just give you one...

we have to program a way to find the square root without using math.sqrt(0);
i've found out ways to do it manually with pen and paper... but the way i see it, programming it that way is impossible. anyone know of a way? or a program already?

my lecture teacher hasn't showed up in 2 weeks... so my lab teacher just keeps giving us all the hw and expects us to teach ourselves, but the book is pfft

Joined:
Jan 2, 2006
Messages:
48,376
0
Location:
Utah
4. KrakerjakActive Member

Joined:
Jul 7, 2003
Messages:
8,288
1
Location:
Edmonton eh
That's a pretty cool problem

What the fuck is up with that magic number in the quake3 algorithm?

5. DeathClockGuest

I would suggest NOT copying the Q3 algorithm for this project, because I doubt you will be able to explain it if your professor asks.

6. DeathClockGuest

Has to do with the way floating point numbers are represented as sign bit, a mantissa, and a significand. That is why it appears to be such a large number anyway.

7. ge0New Member

Joined:
Oct 31, 2005
Messages:
8,398
0
Location:
JERSEY
isn't it Math.pow(i,2)
and the 2 means what power the i is raised to?

its bee awhile since i squared something

8. DeathClockGuest

lol

square root... would be sqrt()

9. Limp_BrisketNew Member

Joined:
Jan 2, 2006
Messages:
48,376
0
Location:
Utah
but if he could explain it his teacher would shower him with praises and gifts

10. philviaSUCKIN ON MY TITTIES LIKE YOU WANTIN ME CALLIN ME

Joined:
May 3, 2007
Messages:
11,618
12
Location:
NYC
thats the one i found earlier.. and i have no idea where to even begin. i do need practice but like i said our teacher hasn't even been there to teach. pffft
this is a class for CONSTRUCTION MANAGEMENT and is 6 hours but only counts as 2 credits. its a BS class and this is a BS assignment

i thought about just submitting math.pow(i,1/2) lol

11. DeathClockGuest

You would get no points, because calling pow with a float as the second parameter would fail.

*edit* nvm, that would work, I keep thinking this is C. You would still fail the assignment though lol.

12. KrakerjakActive Member

Joined:
Jul 7, 2003
Messages:
8,288
1
Location:
Edmonton eh
Can you just not use the sqrt() function?
but others are ok?

you could do exp( log(i) / 2 )
but im guessing the assignment want you to do it without using the math library

13. philviaSUCKIN ON MY TITTIES LIKE YOU WANTIN ME CALLIN ME

Joined:
May 3, 2007
Messages:
11,618
12
Location:
NYC
yea we're supposed to be following an algorithm like in the first post.

14. DeathClockGuest

Ill walk you through it later, don't have time now but tomorrow afternoon probably.

Basically, the first thing I look for is a potential loop, you should be able to find it in the algorithm described in the link I gave.

15. philviaSUCKIN ON MY TITTIES LIKE YOU WANTIN ME CALLIN ME

Joined:
May 3, 2007
Messages:
11,618
12
Location:
NYC
no one submitted the homework lol. our teacher gave us this algorithm and we did it in class...

If A > 0 is a guess of the square root of the positive number Q, then a better approximation to √Q is given by
B = (A + Q/A)/2.
Now you use B as an approximation and compute C = (B + Q/B)/2, and so on to get as close as you want to the value of √Q.

which is MUCH easier than the long division one

16. DeathClockGuest

Now, see if you can relate that to the D3 algorithm... because it is exactly the same using a clever initial guess.

Joined:
Jan 2, 2006
Messages:
48,376