Maths Puzzle
A = 10 (COST)
B = 20 (Sell Price)
C = 15% (Fee)
D = Tax at 20% or 1/6th if you are taking it away
E = Margin
B x C = 3.60
B / 6 in Reverse = 3.33
E = B - A - (B x C) - (B / 6) = 3.07
Ok The above works correct when i i provide B Sell Price
I want a formula that will Give me E, If i say E = 3.07 It says B = 20
How would i do that, the math
Any boffins can help
Thanks
First:
You did not use D: I suppose instead of B / 6, it should read B x D, where D can be either 20% or 16,666...%
There is a mistake: B x C is not 3.60 for the given values (B=20, C=15%), it is 3.
This is a matter of mathematical deduction:
Given the equation:
E = B - A - (B x C) - (B x D)
Add A to both sides:
E + A = B - (B x C) - (B x D)
Isolate B:
E + A = B x (1 - C - D)
Divide both sides by (1 - C - D). Condition: C + D cannot equal 100%
(E + A) / (1 - C - D) = B
So there is your formula for calculating B. Take note of the condition: this only holds true when C + D is not equal to 100%.
Related
I am trying to formulate a constrain for my math model. the constrain goal is:
if A = 1 and B = 1 then C <= D
otherwise (A or B or both are 0) there is no constraint.
A and B are binary variables. C and D are integer numbers.
so far I was able to come up with this equation:
M(A - 1) - (B - 1) + C <= D (M is a big big number)
this formulation does not hold when A = 1 and B = 0
You could do this in two steps, first introduce a variable X representing logical and of A and B.
X >= A + B - 1
X <= A
X <= B
Then use X to express the inequality:
C - M(1-X) <= D
Given two sets of numbers, i.e.,
[3, 4, 5] and [7, 8, 9].
Are the results for (3/7 + 4/8 + 5/9) and 3 * (3 + 4 + 5) / (7 + 8 + 9) similar to each other? Are there any theorems for this?
Let's put the reversed question:
Can difference between a / d + b / e + c / f and 3 * (a + b + c) /
(d + e + f) be arbitrary large?
The answer is positive:
let a = c = d = e = 1 and b = f is a large number. We have:
a / d + b / e + c / f = 1 / 1 + b / 1 + 1 / b ~ b + 1
3 * (1 + b + 1) / (1 + 1 + b) = 3
The difference is
b + 1 - 3 = b - 2
When f = b is arbitrary large, the difference (b - 2) is arbitrary large as well.
That's why the answer to the original question is
there's no guarantee that the results will be similar, i.e. close
enough
So...
I've been banging my head on the wall over this problem for a few days now, but still couldn't find a solution.
I have two ranges of numbers
A -> B
C -> D
A given number (x) is on the A -> B range.
I need to find it's equivalent in the C -> D range.
eg:
A -> B = (2 -> 4)
C -> D = (-148 -> -50)
x = 2.3
What is the equivalent value on the (-148 -> -50) range?
Your requirements are a bit loose, but I would be tempted to believe you want to find an affine transformation from the interval [2;4] to [-148;-50].
Calling f(x) = a.x + b this transformation, you have:
f(2) = 2.a + b = -148
f(4) = 4.a + b = -50
=> 2.f(2) = 4.a + 2.b = -296
=> 2.f(2) - f(4) = b = -246
=> a = (-148 - b)/2 = 49
=> f(x) = 49.x - 246
So the point you are looking for would be f(2.3) = -133.3
You can use ((X - A) * (D - C) / (B - A)) + C.
Size of first range is: B - A
Size of second range is: D - C
Ratio between (X - A) and (Y - C) should be proportional to that of (B - A) and (D - C).
If I have a graph structure that looks like the following
a level-1
b c level-2
c d e level-3
e f g h level-4
...... level-n
a points to b and c
b points to c and d
c points to d and e
and so on
how can i calculate the n from the size(number of existing nodes) of the graph/tree?
The number of nodes present if the height is h is given by
1 + 2 + 3 + ... + h = h(h + 1) / 2
This means that one simple option would be to take the total number of nodes n and do a simple binary search to find the right value of h that such that h(h + 1) / 2 = n.
Alternatively, since n = h(h + 1) / 2, you can note that
n = h(h + 1) / 2
2n = h2 + h
0 = h2 + h - 2n
Now you have a quadratic equation (in h) that you can solve to directly get back the value of h. The solution is
h = (-1 ± √(1 + 8n)) / 2
If you take the minus branch, you'll get back a negative number, so you should take the positive branch and compute
(-1 + √(1 + 8n)) / 2
to directly get back h.
Hope this helps!
Note: I'm assuming all operators below are left-associative.
a - b - c is equal to a - (b + c).
a / b / c is equal to a / (b * c).
Are there any similar equivalences for the modulo operator?
I've figured that a % b % c is equal to a % b if b <= c and a % c if b > c && b % c == 0. However, I can't figure out what a % b % c equals when b > c && b % c != 0. Is there a more general or elegant way to think about chained modulo operators? Additionally, can you think of any algorithms or usages of chained modulo operators of the last type?
Let's take b = q0*c + r0
You decompose
a = q1 * b + r1
r1 = q2 * c + r2
a = q1 * (q0 * c + r0) + q2 * c + r2
a = (q1 * q0 + q2) * c + q1 * r0 + r2
So you can say that
r2 = (a - q1 * r0) % c
Or in other words
(a%b%c) = (a - (a/b)*(b%c)) % c
This also works when b<c, because (a - (a/b)*b) is just a%b
But I doubt that this is very usefull
Chained modulo operators have no particular meaning in general, and the result may actually be ill-defined.
If you think of modulo p as a projection from integral numbers to some set {k, ... k + p - 1} then chaining two projections may not be clearly defined mathematically since the chaining depends on the choice of k (more precisely, chaining % p and % q depends on k % q).
To take this to the programming world, note that the C standard mandates that the sign of a % b is implementation defined when a is not positive.
As an example: -1 % 3 may be -1 or 2 depending on the implementation. Then, (-1 % 3) % 2 may be 0, 1, or -1 one depending on the implementation...