Ask your own question, for FREE!
Mathematics 10 Online
OpenStudy (anonymous):

Define a function f(x) such that f(f(x)) = -x

OpenStudy (anonymous):

\[f(x)=-|x|\]

OpenStudy (anonymous):

\[f(f(x)) = -|-|x||\]\[f(f(-1)) \neq 1 \]

OpenStudy (anonymous):

@Anwar f(f(x)) = -(-x) = x :-P

OpenStudy (anonymous):

:/

OpenStudy (anonymous):

This can be done in a few lines in Python. Python 1, Math 0 :-D

OpenStudy (anonymous):

why not C?

OpenStudy (anonymous):

It might be possible in C..... let me think

OpenStudy (anonymous):

maybe easier in C++

OpenStudy (anonymous):

because Python (at least the default one) is C's baby, and if Python can do it, then C can :-D

OpenStudy (anonymous):

in python you can't even i++ :D

OpenStudy (jamesj):

What's the definition of the function? Don't give us Python code; the code is just the encapsulation of that definition. What is the definition itself in ordinary mathematical notation?

OpenStudy (anonymous):

I was hoping someone could figure it out for me :( I think it has to do with complex numbers. f(x) = x*i

OpenStudy (jamesj):

oh, so it's not a real valued function? Then it's trivial.

OpenStudy (anonymous):

right

OpenStudy (anonymous):

but the question said we can't use complex numbers :(

OpenStudy (jamesj):

In which case, it's not trivial. Do you know the answer? I don't. I'd like you to tell me.

OpenStudy (anonymous):

I don't know either, but it's one line in Python

OpenStudy (anonymous):

f = lambda x: (lambda: -x) if (not hasattr(x, '__call__')) else x()

OpenStudy (jamesj):

decode the line for us and tell us then. You're the Python expert.

OpenStudy (jamesj):

I can't read that.

OpenStudy (anonymous):

it just says f is a function that returns a function that returns the additive inverse of a number if the argument is not a function and calls its input otherwise.

OpenStudy (jamesj):

Oh, so it's not a regular mathematical function at all.

OpenStudy (anonymous):

is it possible to make it a regular math function?

OpenStudy (jamesj):

i don't think so, but i'll think about it a little.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!