r/MathHelp • • Jul 25 '21

Looking for a function that satisfies that f(0)=0 and f(positive integer)=1

Looking for a non-piecewise function that satisfies the cases stated on the title. The other inputs and outputs don't need to follow any pattern. Thank you so much. The closest I've gotten to it is f(x)=1-e-43x^2, but the outputs on the integers are just approximations and not exactly 1. I've tried things with sines and cosines but haven't obtained anything useful.

Update: I've been experimenting with tan(x) and I think it has some potential. For instance having f(x)=tg([5pix]/4), f(0)=0 and f(4n+1)=1. Would there be any way to modify f(x) so that it fits the criteria? Thinking about what to do with sine and cosine as well.

11 Upvotes

31 comments sorted by

6

u/edderiofer Jul 25 '21

This looks like 1 subtract the Kronecker delta function, which has a non-piecewise representation.

It's unclear why you want a non-piecewise representation of your function, though; a piecewise representation is just as valid and often simpler than trying to find a non-piecewise representation.

4

u/FoxTroop_ Jul 25 '21

It is true that piecewise representations are valid, I just wanted to challenge myself but I was not capable of finding that non-piecewise function.

4

u/355over113 Jul 25 '21

Take inspiration from the Fourier transform. Recall that integrating cos(nt) from 0 to 2pi, where n is an integer, is "usually" 0, which happens due to the oscillations cancelling out over a whole number of periods. The one exception is when n=0 and we're integrating the constant function, yielding 2pi.

So the sequence f(n) = 1/(2pi) * int_0^2pi ( cos(nt) ) dt is 1 for n=0 and 0 for any other integer.

This takes you most of the way there, since we have the same value for all positive integers and the value at 0 is the exception. Some guiding questions:

  1. How we can we transform f so it satisfies the properties you want?

  2. Is f defined when n is not just an integer but any real number?

  3. Is f once differentiable? Twice?

See this Desmos link if stuck.

2

u/FoxTroop_ Jul 25 '21

I have not studied Fourier transforms, but seeing the Desmos, I see that the only thing I need to do to tranaform f(n) so it satisfies the properties I want is to add 1 to the entire function. Also, f(n) is defined for any real number, since cos(x) is defined for all reals and its integral is cos(x) which is also defined for any real number. I don't know if f(n) is differenciable or not, but, there is a constant that will always be multiplying no matter how many times I differentiate and, since you can differentiate cos(x) indefinitely, I think you can differentiate f(n) infinitely mani times.

1

u/FoxTroop_ Jul 26 '21

Thank you very much for your suggestion and your help.

3

u/miloss88 Jul 26 '21

What an interesting problem. Here is my solutions:

sin( pi/2 * (4x - 1)/3 )

I was looking at the functions in a form of sin (pi/2 * f(x)), where f(0)=1 and f(n)=1(mod 4)

From there, I tried this:

f(0)=0

f(1)-f(0)=1

f(2)-f(1)=4

f(n)-f(n-1)=4n-1

And that gives nice formula f(n)=(4n - 1)/3

3

u/miloss88 Jul 26 '21

Playing a bit more with the same idea, I found this one as well (which I like a bit more):

1 - cos(pi/2 * (2x - 1))

1

u/FoxTroop_ Jul 26 '21

Thank you very much for your two suggestions and your explanations as well.

2

u/SOwED Jul 26 '21

I'm on the same track as you. I tried the following:

cos(exp(-Ax+ln(п/2))) where A is a sufficiently large number for what you're looking for.

I used 10100 for A and got pretty good results.

It satisfies f(0)=0 and f(x)=1 for x>10-12

https://www.desmos.com/calculator/dz5gcxafgj

Zoomed in version: https://www.desmos.com/calculator/jswxemm7dl

2

u/miloss88 Jul 26 '21

I think yours is very close to, buy not exactly, 1.

That could also be achieved with something like:

1-e -x*10100

Same as you, 10100 can be replaced with anything large enough, but that will just give value close to 1, not exactly one.

1

u/SOwED Jul 26 '21

True, it only works in the limit as A tends to infinity.

I'm not sure I understand yours with cosine though. I graphed it and it didn't look right at all but maybe I reproduced it wrong. Can you show me on desmos?

3

u/miloss88 Jul 26 '21

Here is the link, but it's hard to see it past x=5: https://www.desmos.com/calculator/by0eobc2va

I will explain: f(x)=1 - cos(pi/2 * (2^x - 1))

It's clear that f(0)=0. Let's examine f(x), where x i positive integer.

  1. 2^x - 1 is odd

  2. cos ( (2k+1) * pi/2 ) = cos (k*pi + pi/2) = 0 ; k is integer

From 1 and 2 we can conclude: cos(pi/2 * (2^x - 1) )=0. Therefore f(x)=1

1

u/FoxTroop_ Jul 26 '21

I have a question. I can't figure out why 2x - 1 is an odd function. If I plug -x in the exponent, that just gives me 1/2x - 1, which is not -f(x)

2

u/miloss88 Jul 26 '21

The 2^x - 1 is not odd function. Value is odd number, when x is positive integer. Being odd number is important so it can be used with 2.

Hope that clarifies it.

1

u/FoxTroop_ Jul 26 '21

Oh okay, thanks for clarifying. Now everything makes much more sense hahaha

1

u/SOwED Jul 26 '21

Ah I missed the stipulation that it only needs to work for integers.

2

u/velcro44 Jul 26 '21

I feel that you can only find a sequence of functions that converge to your piecewise function

2

u/FoxTroop_ Jul 26 '21

That's qhat I thought, but someone in the comments pointed out Fourier transforms and that kind of functions actually work.

1

u/Cowz-hell Jul 25 '21

so a signum function in terms of a non piecewise function?

2

u/FoxTroop_ Jul 25 '21

Yep, just that the negatives and the non-integer positive numbers can follow any pattern, I only care about 0 and positive integers.

1

u/SOwED Jul 26 '21

cos(exp(-Ax+ln(п/2))) where A is a sufficiently large number for what you're looking for. Try 10100 for A

1

u/FoxTroop_ Jul 26 '21

But isn't that just an aproximation?

2

u/SOwED Jul 26 '21

It is. I also didn't realize you meant just for integers.

the exact version would be the limit as A->∞ of the above function.

3

u/SamBrev Jul 25 '21

1 - 0x

5

u/fermat1432 Jul 25 '21

I think the 00=1 might be an issue for some.

2

u/SOwED Jul 26 '21

That's fair, but I think since OP is sort of just wondering if such a thing exists without using piecewise functions, it's not a bad solution.

1

u/fermat1432 Jul 26 '21

Not bad at all!

1

u/Kasmyr Jul 25 '21

"ceiling" of | Sin |x| |?

'___________

Ceiling: 0.1 => 1

0=>0

0.5=> 1

4.175586255=5

pi =>4

3

u/macho_madness420 Jul 26 '21 edited Jul 26 '21

Trouble is, both the ceiling and the absolute value are themselves piecewise functions.

1

u/AutoModerator Jul 25 '21

This is an automated reminder:

  • What have you tried so far? (See Rule #2; to add an image, you may upload it to an external image-sharing site like Imgur and include the link in your post.)

  • Please don't delete your post. (See Rule #7)

We, the moderators of /r/MathHelp, appreciate that your question contributes to the MathHelp archived questions that will help others searching for similar answers in the future. Thank you for obeying these instructions.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/[deleted] Jul 25 '21

f(x) = (x > 0)