1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable?

  1. Jul 4, 2011 #1
    Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    1. The problem statement, all variables and given/known data

    I'm trying to solve this for x

    floor(x/B)+1=L

    where
    x is a variable
    B and L are just some constants
    2. Relevant equations



    3. The attempt at a solution
    I have no idea were to go after this
    floor(x/B)=L-1
    I don't know how to solve this further because I don't know what the inverse of the floor function is.

    Thanks for any help!
     
  2. jcsd
  3. Jul 4, 2011 #2

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    Hi GreenPrint! :smile:

    The floor function does not have an inverse since it is not injective. So we will find multiple solutions (or none if L is not an integer).

    In general, we know that floor(x)=y if and only if y is an integer such that

    [tex]y\leq x<y+1[/tex]

    So we know that floor(x/B)=L-1 if and only if L is an integer such that

    [tex]L-1\leq \frac{x}{B}<L[/tex]

    Can you go from here?
     
  4. Jul 4, 2011 #3
    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    Well see the reason why I asked this question was because I was trying to solve a problem for this course that I'm taking in which I'm trying to learn how to use MATLAB. This question came up because I was confused by the math that was required to solve the question. Basically I'm trying to create a conversion table from degrees Celsius to degrees Rankine were the user inputs the starting temperature in degrees Celsius and the increments at which degrees Celsius is increased by from row to row.

    "Generate a table of conversions from Celsius to Rankine. Allow the user to enter the stating temperature and the increment between lines. Print 25 lines in the table. Use disp and fprintf to create a table with a title, column headings, and appropriate spacing."

    disp('The table about to be generated is a degrees Celsius to degrees Rankine conversion table, and will contain 25 lines.')
    A=input('At which starting temperature, in degrees Celsius, would you like the table to start at?');
    B=input('At what increment would you like the degrees Celsius to be displayed?');
    table=[A:B:?;C_to_R(A:B:?)];
    disp('degrees C to degrees R')
    disp('degrees C degrees R')
    fprintf('%4.2f %12.2f\n',table)

    and I was having trouble coming up with what to place in the question marks. Note that C_to_R is a function I created in a earlier problem were the user inputs value(s) in degrees Celsius to convert them to degrees Rankine. Note that the notation "A:B:?" is nothing more than a series of values were A is the starting point, B is the increments at which to increase between each value after A, and ? is the ending point at which MATLAB doesn't list values past.

    Hence 0:2:10 yields
    0 2 4 6 8 10

    and the equation I came up with if we let the three values be A:B:C and L the number of lines desired, was
    C/B + 1 = L

    hence
    0:2:10 would yield 6 values because
    C=10
    B=2
    10/2 + 1 = 5 + 1 = 6

    I however realized that
    C/B + 1 = L
    didn't work on all occasions when C/B didn't produce a whole number and that the proper equation was actually
    floor(C/B) + 1 = L
    which works every single time
    I'm just lost as how to solve for C and sense it's a value that I have to enter and not the user of the program I'm making I have to some how come up with the value myself given the number of lines, this case L=25, the starting value A, and the increments at which to increase B... but A really is irrelevant

    hence I'm stuck because a range of values is the yielded answer when solving
    floor(C/B)+1=25
    sense were given L=25
     
  5. Jul 4, 2011 #4
    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    I guess I could just let
    C=24*B+.00000000001
     
  6. Jul 4, 2011 #5

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    There will be multiple values for C that work. Let's see if I can help you find them.

    You know that floor(C/B)+1=25, thus floor(C/B)=24. This means that

    [tex]24\leq C/B<25[/tex]

    What must hold for C now?
     
  7. Jul 4, 2011 #6
    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    *reading above post*
     
  8. Jul 4, 2011 #7
    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    it would be
    24*B <= C < B*25
     
  9. Jul 4, 2011 #8

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    Indeed, so won't C=24B work?
     
  10. Jul 4, 2011 #9
    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    Nope =(
    24*B
    if B = 5
    24*5=120
    I only get 24 results and not 25. Maybe my equation was wrong but I thought it was correct. floor(C/B) + 1 = L

    4:5:120

    ans =

    Columns 1 through 19

    4 9 14 19 24 29 34 39 44 49 54 59 64 69 74 79 84 89 94

    Columns 20 through 24

    99 104 109 114 119
     
  11. Jul 4, 2011 #10

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    Yes, of course you will get only 24 results here since your A=4. Your formula only works with A=0!!

    You'll need to do something like 24*B+A to get the right answer.
     
  12. Jul 4, 2011 #11
    Re: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable???

    Oh wow, I can't believe I didn't realize that. Thanks!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable?
Loading...