Place value function

This has probably already been done before, but I had lots of fun discovering it. :)

I wanted to create a function ff, which, given a number nn, would take in the place value of a digit dd of nn (xx, such that the place value of dd is 10x10^{x}), and output dd itself.

For example, if n=1345.829n = 1345.829, than f(0)=5f(0) = 5, f(3)=1f(3) = 1, and f(2)=2f(-2) = 2.

Here's what I came up with:

f(x)=nmod10x+1nmod10x10xf(x) = \dfrac{n \operatorname{mod} 10^{x+1} - n \operatorname{mod} 10^{x}}{10^{x}}

And a Desmos graph.

I came up with it somewhat inductively, noting patterns while calculating the units digit, the tens digit, and so on, but I understand now why it works. The function essentially chops off everything after the desired place value, subtracts from that everything before the desired place value, and then divides by the power of ten associated with that place value. For example:

n=1345.829n = 1345.829, x=2x = 2 (should retrieve the digit at 10210^2, or 33)

nmod102+1=345.829n \operatorname{mod} 10^{2+1} = 345.829

nmod102=45.829n \operatorname{mod} 10^{2} = 45.829

345.82945.829=300.000345.829 - 45.829 = 300.000

300.000102=3\frac{300.000}{10^{2}} = \boxed{3}

Note by David Stiff
1 month, 1 week ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Sort by:

Top Newest

Now you can trick people by making it look a little more complicated using the method I had shown earlier using trig and inverse trig, making it non-obvious to the naked eye(the formula you have shown is what I normally use for getting digits in a computer program, but I was just reminded that I had found the modulus function in terms of trig and inverse trig)

Jason Gomez - 1 month, 1 week ago

Log in to reply

How sinister! :)

I don't seem to remember seeing a note about that... could you add the link here?

David Stiff - 1 month, 1 week ago

Log in to reply

It was actually in a daily challenge, in a comment as a reply to Siddarth’s comment(one or two fire), I don’t seem to remember the name so I have to go on treasure hunt too

Jason Gomez - 1 month, 1 week ago

Log in to reply

Aha found it(joking it was quite recent) First solution, first comment, first reply to that, first reply to the first reply

Jason Gomez - 1 month, 1 week ago

Log in to reply

Rats, I'm not a Premium member. It says the problem has expired. :/

David Stiff - 1 month, 1 week ago

Log in to reply

@David Stiff Oh in that case I will put down here what I did there

Jason Gomez - 1 month, 1 week ago

Log in to reply

@David Stiff "A better one is 10πcot1(cot(3π10x))\frac{10}{π}\cot^{-1}(\cot(\frac{3π}{10}x)) "

"Got the perfect one 5+10π(tan1(tan(3π10xπ2)))5+\frac{10}{π}(\tan^{-1}(\tan(\frac{3π}{10}x-\frac{π}{2}))) "

These are both for 3xmod103x \mod {10}, a little modification should get them to xmod10nx \mod {10^n}

Jason Gomez - 1 month, 1 week ago

Log in to reply

@Jason Gomez Very cool! Confusing at first too. :)

David Stiff - 1 month, 1 week ago

Log in to reply

@David Stiff I tried out the graph using this function, it didn’t look good

Jason Gomez - 1 month, 1 week ago

Log in to reply

@Jason Gomez Hm. For the trig one you mean?

David Stiff - 1 month, 1 week ago

Log in to reply

@David Stiff Yeah I tried the trig, but I assume neither will look good

Jason Gomez - 1 month, 1 week ago

Log in to reply

@Jason Gomez Yeah, the simpler one looks the same I think. It only really looks nice if you keep nn constant and then graph f(x)f(x) for all integers between like x=10x = -10 and x=10x = 10 (or something else depending on nn).

David Stiff - 1 month, 1 week ago

Log in to reply

@Jason Gomez In fact when you add or subtract inverse trig stuff, it can be simplified to a single inverse trig expression, so after that it will look all the more confusing

Jason Gomez - 1 month, 1 week ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...