Help with a Formula pls

Maxi_Mus

New member
Joined
Jul 14, 2018
Messages
3
Hi Guys

I have the following formula:- capPO = capA * 2 ^ capB + capA * 2 ^ capB * capC * 0.25

capA = 50
capB is a number between 1 ~ 5
capC is a number between 1 ~ 5

If I do the following:-
50 * 2 ^ 1 + 50 * 2 ^ 1 * 1 * 0.25 , I get 125. I am actually expecting an answer of 50 which I can do if I add brackets like this (
50 * 2 ^ 1 + 50 * 2 ^ 1) * 1 * 0.25
.

However if I do the following:- (
50 * 2 ^ 1 + 50 * 2 ^ 1) * 2 * 0.25 [by changing capC only] , I get 100.
I am actually expecting an answer of 62.5.

My results for changing capC are:-

Me Actual
1 = 50 50
2 = 75 62.5
3 = 100 75
4 = 125 87.5
5 = 150 100

I can't change the formula however I just would like to know how the program is resolving the formula to give me the unexpected results in the list, where do I actually need to put the brackets to get what it is giving me?

Any help would be appreciated.

Maxi
 
By moving brackets you are changing the formula. But as you wrote yourself, you can't change it. Please explain what's going on.
 
Ok, I got the formula out of an lua program for a pc program. As I have said that is how the formula is written in lua and it seems the way the pc program resolves the formula is peculiar.

I took that exact formula and replicated it in excel. When excel calculates an answer from that formula it is actually giving me an answer of 125, 150, 175, 200, 225. These are not the figures I am seeing in the pc program.

Regardless of correct or not the pc program is the figures I want so I need to redo my excel formula so that I get the same results and the only way I can do that is adding brackets but I can't seem to replicate the numbers I am seeing no matter where I put the brackets. My BODMAS is failing me.
 
Hi Guys

I have the following formula:- capPO = capA * 2 ^ capB + capA * 2 ^ capB * capC * 0.25

capA = 50
capB is a number between 1 ~ 5
capC is a number between 1 ~ 5

If I do the following:-
50 * 2 ^ 1 + 50 * 2 ^ 1 * 1 * 0.25 , I get 125. I am actually expecting an answer of 50 which I can do if I add brackets like this (
50 * 2 ^ 1 + 50 * 2 ^ 1) * 1 * 0.25
.

However if I do the following:- (
50 * 2 ^ 1 + 50 * 2 ^ 1) * 2 * 0.25 [by changing capC only] , I get 100.
I am actually expecting an answer of 62.5.

My results for changing capC are:-

Me Actual
1 = 50 50
2 = 75 62.5
3 = 100 75
4 = 125 87.5
5 = 150 100

I can't change the formula however I just would like to know how the program is resolving the formula to give me the unexpected results in the list, where do I actually need to put the brackets to get what it is giving me?


Please tell us more about the formula and the "program" you mention. Is the latter the reason you "expect" different numbers than you are getting? What do the columns Me and Actual refer to (considering they seem to disagree with what you wrote above it)? What inputs did you use?

The more you can tell us about the meaning of the formula, where it comes from, how it is related to the program, and so on, the more likely we can figure out what you want.
 
… I have the following formula: capPO = capA * 2 ^ capB + capA * 2 ^ capB * capC * 0.25

… If I do the following [in my Excel spreadsheet]:

50 * 2 ^ 1 + 50 * 2 ^ 1 * 1 * 0.25 , I get 125. I am actually expecting an answer of 50 which I [get using the same formula in Lua] …
I pasted the formula above into the online Lua demo, and the result is not 50.

Code:
[FONT=courier new]
capA = 50

capB = 1

capC = 1

capPO = capA * 2^capB + capA * 2^capB * capC * 0.25

print(capPO)
[/FONT]

Lua's output is 150.0

Maybe you're looking at misinformation or you have misinterpreted something. Can you take a picture of the source formula, so we can see what you're looking at?
 
… What do the columns Me and Actual refer to … What inputs did you use?
Maxi_Mus seems to claim that the same capPO formula and parameter values were used in both Excel and a Lua program, yet the outputs were different.

Later, Maxi_Mus changed the formula (inserting a pair of grouping symbols), and tried again (while letting capC vary from 1 through 5).

I parsed their chart like this:

Code:
[FONT=courier new]
capPO = (capA * 2^capB + capA * 2^capB) * capC * 0.25

capA = 50

capB = 1

capC = n


 n    Excel capPO    Lua capPO
---  -------------  -----------
 1         50           50.0
 2         75           62.5
 3        100           75.0
 4        125           87.5
 5        150          100.0
[/FONT]

Using the altered formula, I don't get the results shown in either column (except for 50).
 
Last edited:
Ok, I got the formula out of an lua program for a pc program. As I have said that is how the formula is written in lua and it seems the way the pc program resolves the formula is peculiar.

I took that exact formula and replicated it in excel. When excel calculates an answer from that formula it is actually giving me an answer of 125, 150, 175, 200, 225. These are not the figures I am seeing in the pc program.

Regardless of correct or not the pc program is the figures I want so I need to redo my excel formula so that I get the same results and the only way I can do that is adding brackets but I can't seem to replicate the numbers I am seeing no matter where I put the brackets. My BODMAS is failing me.

This response was not available when I initially answered; it answers some of my questions, but as others have said, it is inconsistent. We need to see the original program. Lua's documentation shows that it has the same operator precedence (order of operations -- your BODMAS) that we expect, and it gives the same result you got from Excel, so you must be missing something in the program itself.

On the other hand, we may be able to determine the correct formula if you give us more data. Can you generate results for 3 or 4 values of each variable, in various combinations, so we can at least make a guess as to how the variables are used?

Your data suggest that capC is multiplied by 12.5 (which in your formula would happen when capA = 50 and capB = 0 rather than 1). Is it possible that you are misinterpreting what capB is in your example?
 
This response was not available when I initially answered; it answers some of my questions, but as others have said, it is inconsistent. We need to see the original program. Lua's documentation shows that it has the same operator precedence (order of operations -- your BODMAS) that we expect, and it gives the same result you got from Excel, so you must be missing something in the program itself.

On the other hand, we may be able to determine the correct formula if you give us more data. Can you generate results for 3 or 4 values of each variable, in various combinations, so we can at least make a guess as to how the variables are used?

Your data suggest that capC is multiplied by 12.5 (which in your formula would happen when capA = 50 and capB = 0 rather than 1). Is it possible that you are misinterpreting what capB is in your example?


Hi everyone,

Sorry for wasting your time, As Dr Peterson pointed out capB and capC actually seem to both start at 0 instead of 1 which is what I based my test on. When I change both my starting points to 0 I get the results I was expecting.

Below are the 2 grids, left is my original table (the figures I wasn't expecting), the right is the one I was expecting and with Dr Peterson's suggestion is now the figures I get, so thank you for all your help.

capB/capC12345
112525050010002000
215030060012002400
317535070014002800
420040080016003200
522545090018003600
capB/capC01234
050100200400800
162.51252505001000
2751503006001200
387.51753507001400
41002004008001600
 
Top