How Can You Efficiently Calculate x from y = log2(x)?

AI Thread Summary
To efficiently calculate x from the equation y = log2(x), the quickest method is to use the formula x = 2^y, which directly derives x from the known y value. This approach avoids iterative methods and significantly improves performance, making it suitable for applications where timing is critical. Implementing this solution in C++ can be done using built-in exponentiation functions for optimal efficiency. The discussion emphasizes the importance of minimizing steps in the calculation process. Overall, using the exponential function is the most effective strategy for this logarithmic equation.
macilak
Messages
1
Reaction score
0
Hello All,

I have a very impotant question for you. Any help is appreciated.

Given is a logarithmical function: y = log2x (2 is the base) and the y value is known.
I have to find out what is the x value in the fewest steps possible. It can be made by giving sample values for x and applying to the function, but the performance (timing) is a key value, so the process must be very quick. The known solution is to split the curve to lines and shrink the range of possibilities.

Later on I have to translate the solution into C++ and apply it for calibration.

Many thanks in advance for your help!
 
Physics news on Phys.org
Are you constrained to solving the problem by iteration? You could just write x=2^y and use the built-in functions.
 
I multiplied the values first without the error limit. Got 19.38. rounded it off to 2 significant figures since the given data has 2 significant figures. So = 19. For error I used the above formula. It comes out about 1.48. Now my question is. Should I write the answer as 19±1.5 (rounding 1.48 to 2 significant figures) OR should I write it as 19±1. So in short, should the error have same number of significant figures as the mean value or should it have the same number of decimal places as...
Thread 'A cylinder connected to a hanging mass'
Let's declare that for the cylinder, mass = M = 10 kg Radius = R = 4 m For the wall and the floor, Friction coeff = ##\mu## = 0.5 For the hanging mass, mass = m = 11 kg First, we divide the force according to their respective plane (x and y thing, correct me if I'm wrong) and according to which, cylinder or the hanging mass, they're working on. Force on the hanging mass $$mg - T = ma$$ Force(Cylinder) on y $$N_f + f_w - Mg = 0$$ Force(Cylinder) on x $$T + f_f - N_w = Ma$$ There's also...
Back
Top