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

In summary, the floor function does not have an inverse, so we will find multiple solutions (or none if L is not an integer). We know that floor(x)=y if and only if y is an integer such that y\leq x<y+1. So we know that floor(x/B)=L-1 if and only if L is an integer such that L-1\leq \frac{x}{B}<L. Can you go from here?
  • #1
GreenPrint
1,196
0
Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable?

Homework Statement



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

Homework Equations


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!
 
Physics news on Phys.org
  • #2


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?
 
  • #3


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
 
  • #4


I guess I could just let
C=24*B+.00000000001
 
  • #5


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?
 
  • #6


*reading above post*
 
  • #7


it would be
24*B <= C < B*25
 
  • #8


Indeed, so won't C=24B work?
 
  • #9


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
 
  • #10


GreenPrint said:
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

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.
 
  • #11


Oh wow, I can't believe I didn't realize that. Thanks!
 

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

1. What is the purpose of this equation?

The equation "Solve, floor(x/B)+1=L, for x, where B & L are constants & is a variable" is used to find the value of x that satisfies the equation. It can be used in various calculations and problem-solving scenarios.

2. How do I solve this equation?

To solve this equation, you can follow these steps:
1. Subtract 1 from both sides of the equation: floor(x/B) = L-1
2. Multiply both sides by B: x = B(L-1)
3. Simplify: x = BL-B

3. What is the meaning of "floor" in this equation?

"Floor" refers to the mathematical function that rounds a number down to the nearest integer. In this equation, the function is applied to x/B, meaning that the value of x/B is rounded down to the nearest integer.

4. Can this equation have multiple solutions?

Yes, this equation can have multiple solutions depending on the values of B and L. For example, if B=5 and L=2, then x=5, 10, 15, etc. can all be possible solutions.

5. How can I use this equation in real-life scenarios?

This equation can be used in various real-life scenarios, such as calculating the number of boxes needed to pack a certain number of items, determining the number of days needed to complete a project, or finding the number of employees required to finish a task. It can also be used in computer programming to round numbers or to create loops in algorithms.

Similar threads

Back
Top