Finding the Separate RHS of a/b when b = b' + c

  • Context: Undergrad 
  • Thread starter Thread starter jobyts
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around algebraic manipulation and computational approximations, specifically focusing on separating expressions and converting numerical ranges. Participants explore methods to express a fraction in different forms and address challenges related to integer operations in microcode.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • Some participants inquire about separating the expression a/(b'+c) into a/b' plus another term, suggesting that the additional term could be a/(b'+c) - a/b' and discussing common denominators.
  • Others introduce a problem of converting a numerical range, proposing a method to approximate division using bit shifts and questioning the error introduced by assuming certain values.
  • There is a suggestion to use multiplication as an alternative to division, with participants discussing the feasibility of making approximations independent of the variable x.
  • Some participants provide calculations and examples to illustrate the scaling factor used in the conversion process, noting the potential for deviation in results for higher values of x.
  • A later reply asks for clarification on how a specific equation was derived, indicating interest in the underlying methodology.

Areas of Agreement / Disagreement

Participants express various viewpoints on the methods of manipulation and approximation, with no consensus reached on the best approach or the implications of the approximations discussed.

Contextual Notes

Limitations include assumptions made about the values of a and x, the dependence on specific definitions of operations, and the unresolved nature of the error introduced in approximations.

Who May Find This Useful

Readers interested in algebraic manipulation, numerical methods in computing, and those dealing with integer operations in programming or microcode may find this discussion relevant.

jobyts
Messages
226
Reaction score
60
let's say a/b = a/(b'+c)
where b = b'+c.
I need to separate the RHS into a/b' + something. What's that something?
 
Physics news on Phys.org
jobyts said:
let's say a/b = a/(b'+c)
where b = b'+c.
I need to separate the RHS into a/b' + something. What's that something?

What's the context? Is it just algebraic manipulation?

Something = a/(b'+c) - a/b'

and put over a common denominator?
 
I need to convert x (ranging between 0 - 1,000,000) to y (ranging between 0 - (2^32)-1).

so y = (x * 2^32)/1M => (x << 32)/ 1M

We, the software guys have no problem doing it. But the microcode group says they don't have division operation.
I was trying to provide a solution by converting (x << 32)/ 1M to (x <<32) / ((2^20) + a)
(2^20 is the closest approximation to 1M)

I need to measure the error I'm introducing if I assume a=0.
If possible, I want to come up with a calculation as
(x<<32) /((2^20) + a) => (x << 12) + b.
What is b?
 
jobyts said:
I need to convert x (ranging between 0 - 1,000,000) to y (ranging between 0 - (2^32)-1).

so y = (x * 2^32)/1M => (x << 32)/ 1M

We, the software guys have no problem doing it. But the microcode group says they don't have division operation.
I was trying to provide a solution by converting (x << 32)/ 1M to (x <<32) / ((2^20) + a)
(2^20 is the closest approximation to 1M)

I need to measure the error I'm introducing if I assume a=0.
If possible, I want to come up with a calculation as
(x<<32) /((2^20) + a) => (x << 12) + b.
What is b?

Do they have a multiply? Just multiply x * 4295

Will that work?
 
berkeman said:
Do they have a multiply? Just multiply x * 4295

Will that work?

They have multiply operation for integers. Is it possible to make the approximation independent of x? We can use if-then-else.
 
jobyts said:
They have multiply operation for integers. Is it possible to make the approximation independent of x? We can use if-then-else.

Not sure what you mean by approximation. That multiplicative factor is pretty exact for doing the scaling that you asked about. Nice integer multiplication...
 
1000000*4295 = 0x1 0000 7FC0
1000000*4294 = 0x0 FFF1 3D80
1000000*1125899906 >> 18 = 4294967292 (0x0 FFFF FFFC)
1000000*2251799813 >> 19 = 4294967294 (0x0 FFFF FFFE)
 
Last edited:
berkeman said:
Not sure what you mean by approximation. That multiplicative factor is pretty exact for doing the scaling that you asked about. Nice integer multiplication...

2^32 / 1M = 4,294.967296
We rounded 4,294.967296... to 4295.

So, for higher values of x, the deviation would be high.
 
Thanks Berkeman and Xitami for your answers. Xitami's equation gives pretty accurate results.

Xitami, can you tell how you derived that equation?
 
  • #10
Code:
PARI/GP >[B]{
K=2^32-1;
T=1000000;
m=K/T;
for(i=0,20,
        n=T*truncate(m*2^i)>>i;
        print(i" "K-n))}[/B]
0 967295
1 467295
2 217295
3 92295
4 29795
5 29795
6 14170
7 6358
8 2452
9 499
10 499
11 10
12 10
13 10
14 10
15 10
16 10
17 3
18 3
19 1
20 1
PARI/GP > [B]truncate(m*2^19)[/B]
%2 = 2251799813
PARI/GP > [B]#binary(truncate(m*2^19)*1000000)[/B]
%3 = 51
51 bits of intermediate result
 
Last edited:

Similar threads

  • · Replies 52 ·
2
Replies
52
Views
9K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
4
Views
4K
  • · Replies 0 ·
Replies
0
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 36 ·
2
Replies
36
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K