PDA

View Full Version : Sqrt()

krappykoder
03-08-2003, 06:12 PM
i know its a bit of a wierd question but you people are very knowledgable, does any1 know how to figure out the squre root of a number?

frenchfry164
03-08-2003, 06:21 PM
include cmath
use sqrt()

krappykoder
03-08-2003, 06:25 PM
remind me agen, how can i extract sums from libs?

krappykoder
03-08-2003, 06:47 PM
Scratch that: sqrt=pow(number,0.5)
i need to write a power function now :confused:

Hammer
03-08-2003, 07:38 PM
>>i need to write a power function now
Then search the boards, there's sample code out there. Or simply write your own.

TechWins
03-08-2003, 08:30 PM
Does anyone here actually know the precise formula to find the square root of a number? I'm not neccessarily looking to find out how to do it (I could easily find the answer myself), but to see if someone knows the formula for it. My math teahcer said she used to know, but she hasn't used it in so long that she forgot what it is.

Davros
03-08-2003, 08:38 PM
http://surfboard.surfside.net/prussell/approximations/RootAlgorithms.htm

TechWins
03-08-2003, 09:30 PM
Davros, I don't particularly care to know the formula myself, yet to see if someone had the formula memorized themself.

LouDu
03-08-2003, 09:41 PM
Originally posted by krappykoder
i know its a bit of a wierd question but you people are very knowledgable, does any1 know how to figure out the squre root of a number?

you find the square root of a number by mulptliging a number by it self, the perfect quares in math are as fallows

0=0
1=1
2=4
3=9
4=16
5=25
6=36
7=49
8=64
9=81
10=100
11=121
12=144

i know up to 15 but i jsut forgot them :)

XSquared
03-08-2003, 10:35 PM
Originally posted by LouDu
you find the square root of a number by mulptliging a number by it self
No, that's the square of the number.

abrege
03-08-2003, 11:25 PM
Originally posted by LouDu
you find the square root of a number by mulptliging a number by it self, the perfect quares in math are as fallows
Wow, and to think we were baffled all this time!

XSquared
03-09-2003, 12:00 AM
Originally posted by abrege
Wow, and to think we were baffled all this time!
LOL

Do I detect a bit of sarcasm?

frenchfry164
03-09-2003, 12:06 AM
you find the square root of a number by mulptliging a number by it self, the perfect quares in math are as fallows
Wowzers! I gotta tell my math teachers about this! I gotta find all of them since my 4th grade class! I must tell them that they taught me the square root wrongly! Haha! I can't wait to see the looks on their faces!

Bajanine
03-09-2003, 01:56 AM
This is taught to first year plumber and pipefitter appretices which is also how I was taught in school. It is rather convoluted though:
http://mathforum.org/library/drmath/view/52610.html

typo's again
[\edit]

krappykoder
03-09-2003, 02:31 AM
I dont know what convoluded means but it sure it complicated

03-09-2003, 03:15 AM
It's convoluTed, look here (http://dictionary.reference.com/search?q=convoluted) for a definition.

Shiro
03-09-2003, 04:03 AM
Mathworld is a good reference for mathematical topics. Here is another definition of convolution.

http://mathworld.wolfram.com/Convolution.html

krappykoder
03-09-2003, 04:08 AM
The reason i want to know this is to find the length of a line, unless some1 knows a way to not use sqrt

03-09-2003, 04:10 AM
Why do you want to use sqrt() to find the length of a line? What line?

krappykoder
03-09-2003, 04:16 AM
ill post my basic code

FOR a = 1 TO SQRT((x1 - x) + (y1 - y))
x = x + .5
y = (y + ((y1 - y) / (x1 - x) / 2))
DOT x, y
NEXT

Not using the sqr route the line would be to long or too short

Shiro
03-09-2003, 04:44 AM
Calculating the length of a line. You mean the theorem of Pythagoras?
http://mathworld.wolfram.com/PythagoreanTheorem.html

Back to the original question:

>I'm not neccessarily looking to find out how to do it (I could
>easily find the answer myself), but to see if someone knows the
>formula for it. My math teahcer said she used to know, but she
>hasn't used it in so long that she forgot what it is.

The same with me. I learned it in the math lessons at university, but it is a long time ago that I did that, like some other math I currently don't use much anymore. If I would see the algorithm I will probably understand it again, but I currently don't remember how to do it.

Bajanine
03-09-2003, 05:14 AM
Use sin cos or tan if you don't wish to use the square root function.

krappykoder
03-09-2003, 05:16 AM
How do i use cos() to do it??

Bajanine
03-09-2003, 05:20 AM
Do you know any of the other lengths and or angles?

krappykoder
03-09-2003, 05:21 AM
The above code will plot a line from x,y to x1,y1

Bajanine
03-09-2003, 05:23 AM
Then all you need to do is take the arctan of opposite side/ adjacent side to get an angle then use cos or sin with the appropiate length of one of the sides.

why in the world do you want to do this without using a sqrt function?

krappykoder
03-09-2003, 05:25 AM
You confuse me, i never use geometry exept for my circle() function

Bajanine
03-09-2003, 05:27 AM
Do you know any trig.?

krappykoder
03-09-2003, 05:32 AM
i cant use -metery :D

Bajanine
03-09-2003, 05:40 AM
That sucks, why not?

krappykoder
03-09-2003, 05:42 AM
Never been taught it yet :-p

Bajanine
03-09-2003, 05:58 AM
http://mathforum.org/dr.math/faq/formulas/faq.trig.html

frenchfry164
03-09-2003, 11:28 AM
it's easier to learn trig from a teacher than from the internet. Most internet sites make you jump into it really quickly, where a teacher will make sure you learn the basics b4 going into the hard stuff. At least, if they are any good :p.