-1
$\begingroup$

EDIT: Sorry for the unclear description of what I really wanted. I have completely rewritten my question to make it clearer..

On a specific software I am creating, I want to know if there is an alternative formula on finding x here:

d = a / 100
e = b / 100
f = c / 100
g = z - (z * d)
h = g - (g * e)
x = h - (h * f)

The values of a, b, c and z are user inputted. For example, if a=5, b=4, c=3 and z=100:

d = 0.05
e = 0.04
f = 0.03
g = 95
h = 91.2
x = 88.464

Can you guys suggest of a simpler/alternative formula to find x?

EDIT: The purpose of this formula is to apply a certain discount to a product price. For example, if product's price is \$100, and 5/4/3% discount is applied, the new product price should be \$88.464

  • 3
    `the "5/4/3" percent of 100` What's your definition of `x/y/z` percentage?2017-02-08
  • 0
    What is the "5/4/3" percent of 100? Not sure what that means.2017-02-08
  • 2
    Um... if it's a constant just writing "88.464" is enough. If you did it once, why do it again?2017-02-08
  • 0
    But what you want is simply $(1-.05-.05*.04-.05*.04*.03)100$.2017-02-08
  • 0
    @dxiv That is just an example. 100, 5, 4, and 3 can be different numbers depending on User Input.2017-02-08
  • 0
    @fleablood To be specific, 100 is a user inputted value, and can be any number. "5/4/3" is another user inputted value and can be any combination of number from 1-100.2017-02-08
  • 0
    @Bibokid This doesn't answer the question, which was what your notation `x/y/z percent` means.2017-02-08
  • 0
    Or $(1-.03)(1-.04)(1-.05)100$. It's hard to understand want you actually want. You don't need formulas for a single value. Just write .88464.2017-02-08
  • 2
    What is the application of this software you are making?2017-02-08
  • 0
    @dxiv I have revised my question. My apologies.2017-02-08
  • 0
    @YuriyS It's to deduct a certain discount from a product Price. For example, if product's price is \$100, and 5/4/3% discount is applied, the new product price should be \$88.4642017-02-08
  • 0
    @Bibokid You can rewrite those as `g=z(1-d), h=g(1-e), x= h(1-f)` so in the end `x=(1-f)(1-e)(1-d)z`. The posted answers have covered that already.2017-02-08
  • 0
    @dxiv Awesome! Thanks. I think this is the simplest formula. If you could post this as answer, i'd love to select it as answer.2017-02-08
  • 0
    @Bibokid Thanks, and glad you had it sorted out. But at least one of the posted answers has that covered already, so I won't add another redundant one.2017-02-08

3 Answers 3

2

User enters $N $ and $x/y/z $.

Return $N *(1-\frac x {100})*(1-\frac y{100})*(1-\frac z {100}) $

This is assuming you actually wanted $[1 - x - y (1-x)-z (1-y (1-x))]100 $ and not $1-x -xy-xyz $ (which yields 94.794 instead of 88.464).

If you did want the other

Return $N (1-\frac x {100}-\frac {xy} {100^2}-\frac {xyz}{100^3}) $.

  • 0
    I appreciate your help very much fleablood. Sorry for the unclear description of my question. I have updated it to make it clearer.2017-02-08
  • 0
    I wanted to choose dxiv's comment as best answer but didn't realize soon enough that your formula is just the same as his. Thanks a lot fleablood.2017-02-08
1

By your example:

Suppose we want to find the $a/b/c$ percent of a number $n $, then the new number, $n_1$ is given by, $$n_1 =n -\frac {an}{100} - \frac {b}{100}[\frac {an}{100}] - \frac {c}{100}[\frac {b}{100}[\frac {an}{100}]] $$ $$\Rightarrow n_1 =n [1- \frac {a}{10^2} - \frac {ab}{10^4} - \frac {abc}{10^6}] $$

EDIT:

Just backtracking the expressions gives us the new number as: $$x =z [1-d-e-f+de+ef+df-efd] $$

Hope it helps.

  • 0
    Hi Rohan. I am sorry for the unclear description of my question. I have edited my post to make clarifications.2017-02-08
  • 0
    @Bibokid Put the value of h in x and then you will get x in terms of g, e and f. Then substitute for g and you will get x in terms of z, e, d and f.2017-02-08
  • 0
    Thank you very much Rohan!2017-02-08
1

Your solution is wrong. In second step

5% of 100 = 5. Not 95.

And try this -

Take 5% of 100 common from last three terms,

100 - 5% of 100 [ 1 + 4% + 3% × 4%]

= 100 - 5 [ 1 + 0.04 + 0.0012]

= 100 - 5 [ 1.0412]

= 100 - 5.206 = 94.794

  • 0
    Hi, sorry for a very unclear question. I have edited my question to be more specific to what I really wanted.2017-02-08
  • 0
    This is wrong. You have to ask new question instead of so many changes in this question. Because then all answers are redundant. Hope you understand.2017-02-08
  • 0
    I didn't realize that. I wouldn't repeat the same mistake in the future. Thanks for telling me.2017-02-08