SQRT delivers only one result

Pages: 123
closed account (48T7M4Gy)
http://math.stackexchange.com/questions/44406/how-do-i-get-the-square-root-of-a-complex-number
Out of interest.
It is the positive root given the definition in that it is one of the two roots of the defining quadratic.
Therefore it is a function.

seasoned latino
"Seasoned latino"... Is that anything like an "experienced eskimo", or an "accomplished scandinavian"?

But all ethnicity to a side
Why would you even bring it up, you Aussie prick?

I would argue the root does depend on something else but not a function. Mathematically the root is built in to the originating quadratic and is only 'revealed' by the square root function, along with its partner. Ergo, the root is not 'ipso facto' a function
Very good. You've proven (using a generous interpretation of the word) that the roots of a polynomial are not functions. That has nothing to do with whether the principal square root, which gives the positive root for any polynomial of the form x^2-k, is a function.

I did right at the start along with a few other posts IIRC from other ppl.
You did not.

I am just saying if a complete outsider who had never seen our alphabet, saw the symbol and no help 'squiggle' might be the response
And if I put my computer displaying this thread next to a tree, it will continue to photosynthesize. Your point?

number theory says exactly what an irrational number is
The branch of mathematics that studies the integers sure has a lot to say on the subject of irrational numbers. Incidentally, I once read a small pamphlet titled "Applied Knot Theory in the Context of Spacecraft Design".
Last edited on
closed account (48T7M4Gy)
Therefore it is a function.
I think we have flogged the 'principal square root is a function' myth to a standstill. It's an outcome of applying the square root function. not the function itself. You don't think it is. I do and I am supported by the various reputable definitions. We'll both have to be comfortable with that I suspect.

Why would you even bring it up, you Aussie prick?
ROFL, that's the way. You must be a fully assimilated New Australian to have learned such an eloquent comeback.

Very good.
And not before time.

That has nothing to do with whether the principal square root, which gives the positive root for any polynomial of the form x^2-k, is a function.
well that well-deserved compliment was short-lived. Technically all that effort was wasted as it contradicts what you have just conceded in your belated praise. Saying it isn't so doesn't change the fact that the solution to a quadratic is not a function in the type of quadratic we are talking about unless we need to scrape the bottom of the barrel with what a function at a point is.

And if I put my computer displaying this thread next to a tree, it will continue to photosynthesize.
Is that what gauchos do in their spare time when the beef cattle are in bed and their bolas are rolled up for the evening, as they do? https://en.wikipedia.org/wiki/Gaucho - where do they hide their PC's (Pampas Computero)

Your point?
What, you've lost the plot and forgotten already? I'll give you time to revise earlier posts and catch up if you like.

I once read a small pamphlet titled "Applied Knot Theory in the Context of Spacecraft Design"
I read one of those two, it had a free 2 year subscription to "How To Change The Subject" magazine included with it. I see you must have sent your money away for that too!
Last edited on
I do and I am supported by the various reputable definitions.
You haven't provided a single source that defines the principal square root as a number. You've provided one that defines it as a number of a number, which is exactly what a function is.

Saying it isn't so doesn't change the fact that the solution to a quadratic is not a function in the type of quadratic we are talking about unless we need to scrape the bottom of the barrel with what a function at a point is.
It's really not complicated to get a proper definition of a function from what I said above:
Let f(k) be the non-negative value of x such that x^2 - k = 0, where k >= 0.
Therefore f is the principal square root function, that is, the function that gives the principal square root of a number. f(k) is a root, which is what you've "proven" not to be a function, but f is a function.

What, you've lost the plot and forgotten already?
There is no plot. You're just stringing together nonsense in the hopes that a cogent argument will form by accident.
I might have got lost in the masses of nit picking and semantic arguments going on here. However, sqrt is a mathematical function (I believe everyone agreed to that). The definition of a mathematical function is :"In mathematics, a function is a relation between a set of inputs and a set of permissible outputs with the property that each input is related to exactly one output. An example is the function that relates each real number x to its square x2." Therefore sqrt can only return one value for each input (it returns to principal square root of that input), and any other 'square root' n of x is something that satisfies n^2 = x, not something that satisfies sqrt(x) = n. Hence sqrt should only return 1 value in C++ and if you want other solutions to n^2 = x, negating it is not difficult, and is also not the purpose of a sqrt function. Making a plus-minus function to return the positive and negative versions of a number makes moee sense than cramming that in the sqrt function where it doesn't belong.
closed account (48T7M4Gy)
You haven't provided a single source
The source has been mentioned twice by me, namely Wolfram. And that's in addition to a searchable quote from their website. Or do you want to adopt Harvard referencing as a new unilateral rule change?

Therefore f is the principal square root function, that is, the function that gives the principal square root of a number
No that is no proof. It is an assertion by you but fails a simple test. All you have done is sidestepped the point of concern we have been discussing by introducing a new function which is in fact the same as the square root function which, as we all know, is different to one of the numbers it produces namely a PSR.

There is no plot.
You poor thing. I hadn't realised until now your loss of memory was so advanced. Do you want more time to revise? Perhaps a lie down? I understand fully your predicament and I hope it's not an indicator of anything more serious.

You're just stringing together nonsense in the hopes that a cogent argument will form by accident.
You've taught me well helios. Olé!
Last edited on
closed account (48T7M4Gy)
I might have got lost in the masses of nit picking and semantic arguments going on here.
You certainly are lost because semantics was unilaterally banned by helios some considerable time ago.

each input is related to exactly one output
That's as may be as narrow a definition as it is. The fact is the the mythical single output could have many 'outputs', tuple, struct members, vectors, array elements and so the list goes on.

A simple x^2 + y^2 function plot can identify two points as an output or a single circle so the idea of a single output is very vague indeed.

The value of 'cramming it into the function' as you suggest is not so bad as it might sound especially where peoples memories are so short-lived that they forgot the other solution. gentleguy was on to something earlier in suggest change to the function wouldn't be a waste. And it is not as though it would be hard to implement.
Last edited on
The source has been mentioned twice by me, namely Wolfram.
The unique nonnegative square root of a nonnegative real number. For example, the principal square root of 9 is 3, although both -3 and 3 are square roots of 9.
The "of" makes it a function.

No that is no proof.
You can't prove a definition. f is, by the definition I gave above, the function that returns the principal square root of its input. I never claimed this to be proof that the principal square root is a function (that is also by definition).

It is an assertion by you but fails a simple test.
What simple test is that?

All you have done is sidestepped the point of concern we have been discussing by introducing a new function which is in fact the same as the square root function which, as we all know, is different to one of the numbers it produces namely a PSR.
Read the definition again. f is actually not equivalent to the proper square root, as it only ever returns positive roots. At all points in its domain it is exactly equal to the principal square root of its input, and to nothing else.
gentleguy was on to something earlier in suggest change to the function wouldn't be a waste. And it is not as though it would be hard to implement.
Okay, I'm calling it. This guy's trolling. I'm not wasting my time with this, anymore.
closed account (48T7M4Gy)
The "of" makes it a function.
shadowmouse reminded me of you semantic decree so that statement is invalid.

You can't prove a definition.
You're going around in circles. I have already conceded that we don't agree on this even though my argument is supported by facts. Not only is it flogged to a standstill, the horse is dead. Feel free to proceed to the disposal of the body but I won't be budging.

What simple test is that?
Please read the sentences that follow. Perhaps write down that bit so you don't forget.

At all points in its domain it is exactly equal to the principal square root of its input, and to nothing else.
Yeah i know all that and I read what you wrote before I replied. The point is your claimed and alleged gotcha function is still a sausage factory the same as the basic squiggle function. All it does is churn out smaller sausages. the sausages produced aren't capable of producing more sausages whatever size they are.
Last edited on
Therefore sqrt can only return one value for each input (it returns to principal square root of that input), and any other 'square root' n of x is something that satisfies n^2 = x, not something that satisfies sqrt(x) = n.

A function can returns pairs, sets or sequences or bags of trash, or anything else, so long as it always returns the same one given the same input. For example, there is nothing wrong with, define sqroots : R -> R X R, as sqroots( x ) = ( -sqrt(x), +sqrt(x) ).

Hence sqrt should only return 1 value in C++ and if you want other solutions to n^2 = x, negating it is not difficult, and is also not the purpose of a sqrt function.

It would be fine for C++ to provide a function sqroots(x) which returns a pair, but it's not exactly useful in C++, although it may be in a more declarative language like prolog for example.

@Everyone:
https://xkcd.com/386/
Last edited on
htirwin wrote:
A function can returns pairs, sets or sequences or bags of trash, or anything else, so long as it always returns the same one given the same input.


Your definition of a function, like kemort's is not the mathematical definition (despite kemort's specious claim to the contrary.)

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

As for why the sqrt function in C and C++ returns the principal square root rather than the set of square roots that are valid, I would imagine it has more to do with not paying for work you didn't need done/storage you didn't need to use in deference to the usual C/C++ philosophy than any actual mathematical arguments or definitions.
Last edited on
closed account (48T7M4Gy)
xkcd is always a good place to be. ;)
kemort wrote:
xkcd is always a good place to be. ;)

+1
This got interesting.

That being said. Mathematically speaking, a function can only map one element in the domain to one element in the codomain. One could say that the sqrt function is obtained from inverting f(x) = x^2 and mapping the codomain to the domain, but f(x) : R -> R, x -> x^2 isn't invertible, since it isn't one-to-one. You are forced to restrict the domain of x^2 in order to invert it. Restricting the domain to {x | x >= 0} gives the principle square root, restricting it to {x | x < 0} gives the other root.
But finding roots isn't the same thing as taking the square root. You take the square root in the process of finding roots of x^2. 3 and -3 are roots of the equation x^2 = 9, but we'll specify which root we want if we strictly just take the square root of 9.

The principle square root is a function, since it maps every element of the domain to a single element in the codomain. The negative square root is also a function, as it does the same for its domain and codomain. You can hate that or love it, but mathematically speaking both of those satisfy the definition of a function.

But we're in C++, return whatever you want.
I'd agree with cire, but also add that those who use the language and are used to the convention in math would probably expect a sqrt method to return the principle root, and just accommodate for that, since, at least in R in [0, inf), the principle root and negative root and just opposites.
closed account (48T7M4Gy)
The first sentence of the Wolfram reference is definitive, as can be expected. That's all that needs to be, and was, said.
Your definition of a function, like kemort's is not the mathematical definition (despite kemort's specious claim to the contrary.)

It isn't my definition, it is the formal definition of a function. Again read the wolfram link you posted. And on this time at least Kemort is correct, the first sentence is all that needs to be read.

A function is a relation that uniquely associates members of one set with members of another set.


If the codomain is RXR ( R cross R, i.e. the set of all two element tuples of real numbers), then (-a, a), a an element of R, is a single element in that set. Sets are not restricted to scalars, they can be sets of sets, sets of sets of sequences of sets of sequences of graphs, or dogs or really anything.

but f(x) : R -> R, x -> x^2 isn't invertible,

Again,
there is nothing wrong with, define sqroots : R -> R X R, as sqroots( x ) = ( -sqrt(x), +sqrt(x) )

Last edited on
htirwin wrote:
but f(x) : R -> R, x -> x^2 isn't invertible,

Again,
there is nothing wrong with, define sqroots : R -> R X R, as sqroots( x ) = ( -sqrt(x), +sqrt(x) )

Yes, it is fine, I never said it wasn't. My assertion was with f : R -> R, not with R -> R X R. These map different sets, so they're not exactly comparable like that. That definition of sqrts still isn't the inverse of f : R -> R. f(x) -> x^2, though. It isn't invertable without restricting its domain.

I'm more saying that the principle root is, in fact, a function, not that returning a pair of values is invalid. By definition, both are perfectly valid.
The problem with sqroots is not that the domain is restricted. This would be fine, as in for example the case of exp and log. The problem is that the codomain of sqroots is not the domain of x^2. Furthermore, the codomain of sqroots and the domain of x^2 have a null intersection: for all x in R, sqroots(x^2) != x.

You can invert non-injective functions, but the result is not a function, but a multivalued function. A function that merely maps to a cartesian product or to a powerset is not a multivalued function.
Last edited on
http://www.cplusplus.com/reference/cmath/sqrt/

If x is negative, a domain error occurs:
If a domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.
You may as well ask why MATH_PI does not have the exact value of pi, or why sqrt(2) is not exactly equal to the positive square root of 2.
Last edited on
Pages: 123