▼
Posts: 896
Threads: 183
Joined: Jul 2005
It would be great if someone here could help me symbolically solve the following equation  it is part of an upcoming program to calculate the "processability" of a business area (i.e. if it is a sound business decision to create a process for a certain area of business). To be able to solve the bigger equation, I need help solving this one:
Solve for x:
(a^x)/x = b
▼
Posts: 7
Threads: 4
Joined: Jul 2007
wolfram alpha is always your friend...
http://www.wolframalpha.com/input/?i=%28a^x%29%2Fx+%3D+b+solve+for+x
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Wow. Excellent. Wolfram is a better resource after this.
Posts: 896
Threads: 183
Joined: Jul 2005
Looking into this further, I am unsure of how I would go about resolving the following in an HP41 program:
How do I handle the Lambert WFunction in a program?
▼
Posts: 882
Threads: 23
Joined: Jan 2005
Quote:
I am unsure of how I would go about resolving the following in an HP41 program
If you really need to... :) try with HP41Z module by Ángel.
Greetings, Massimo
Edited: 29 Dec 2010, 1:22 p.m.
▼
Posts: 896
Threads: 183
Joined: Jul 2005
▼
Posts: 564
Threads: 72
Joined: Sep 2005
This gives a good explanation as well as the numerical evaluation at the bottom
as well as here in Wolfram Alpha
[link:http://www.google.com/url?sa=t&source=web&cd=2&ved=0CCUQFjAB&url=http%3A%2%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.86.9305%26rep%3Drep1%26type%3Dpdf&rct=j&q=how%20to%20calculate%20the%20lambert%20W%20function&ei=8o0bTcrBIoLGlQfxh6jJCw&usg=AFQjCNGzCdFCPNBNVvFeSmeqBIbaY59AA&sig2=qIe1lZhmayysqt745QTmg&cad=rja]and here if you *really* want to know a whole lot about the W (as well as a last chapter on numerical evaluation)[/link]
Cheers
Peter
Edited: 29 Dec 2010, 2:43 p.m.
▼
Posts: 896
Threads: 183
Joined: Jul 2005
I am looking for a simpler, more basic approximation  see further down on the "math challenge"; An approximation of the original function to make the symbolic solve easier without it becoming recursive and such.
Posts: 735
Threads: 34
Joined: May 2007
Here's the Lambert W function:
01 LBL "W"
02 STO M
03 0
04 STO N
05 LBL 00
06 RCL N
07 ENTER
08 ENTER
09 E^X
10 *
11 LASTX
12 1
13 R^
14 +
15 *
16 LASTX
17 1/X
18 1
19 +
20 2
21 /
22 R^
23 RCL M
24 
25 ENTER
26 RDN
27 *
28 
29 /
30 ST N
31 ABS
32 RND
33 X#0?
34 GTO 00
35 RCL N
36 END
Here's how to use it:
a ENTER b
X<>Y
LN
CHS
STO 00
X<>Y
/
XEQ "W"
RCL 00
/
I'm using:
HTH
Thomas
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Posts: 2,761
Threads: 100
Joined: Jul 2005
Alternatively, if you have the Advantage Module:
01 LBL 'W
02 STO 01
03 CLx
04 ENTER
05 10^x
06 'L
07 SOLVE
08 RTN
01 LBL 'L
02 e^x
03 *
04 RCL 01
05 
06 RTN
Example, using your procedure:
2 ENTER 32
x<>y
LN
CHS
STO 00
x<>y
/
XEQ "W"
RCL 00
/ > 0.031949779
2 x<>y y^x LASTx / > 31.99999999
Another solution is x = 8, but this requires the other real branch of Lambert W.
Regards,
Gerson.
▼
Posts: 2,761
Threads: 100
Joined: Jul 2005
The following program can be used to compute the second real solution:
01 LBL 'WM
02 CHS
03 1/x
04 STO 01
05 ENTER
06 ENTER
07 ENTER
08 LBL 00
09 STO 02
10 LN
11 *
12 RCL 02
13 x<>y
14 
15 x=0?
16 GTO 01
17 CLx
18 RCL 01
19 LASTx
20 GTO 00
21 LBL 01
22 LASTx
23 RCL 01
24 /
25 CHS
26 END
2 ENTER 32
x<>y
LN
CHS
STO 00
x<>y
/
XEQ WM
RCL 00
/ > 7.999999999 (x_{2})
2 x<>y y^x LASTx / > 31.99999998
▼
Posts: 896
Threads: 183
Joined: Jul 2005
As this should not fade away to oblivion as programs buried deep into an HP Forum thread, I decided to put the two solutions to the W Lambert fuction into one program here:
http://www.isene.com/isene.cgi?hp41_WL
▼
Posts: 2,761
Threads: 100
Joined: Jul 2005
The program for the second real branch of Lambert's W function above (W_{p} or W_{1})is based on this formula, found quite by chance when playing with the RPN stack:
W_{1}(1/x) = (...x*ln(x*ln(x*ln(x*ln(x))))...)/x
This is not a fast method, especially for arguments close to 1/e, it was originally meant for the HP12C+:
http://www.hpmuseum.org/cgisys/cgiwrap/hpmuseum/archv019.cgi?read=159032
W_{1}(0.367) = 1.070791879 (about 5 seconds on the HP12C+ and 2 min 20 sec on the HP41CX). Actual 10digit result: 1.070791887.
A faster method for the second branch should be appreciated.
The steps 05 through 07 in the previous program made sense only for manual calculations. This shorter version is better:
01 LBL 'WM
02 CHS
03 1/x
04 STO 01
05 LBL 00
06 STO 02
07 LN
08 RCL 01
09 *
10 RCL 02
11 x<>y
12 
13 x=0?
14 GTO 01
15 LASTx
16 GTO 00
17 LBL 01
18 LASTx
19 RCL 01
20 /
21 CHS
22 END
Edited: 1 Jan 2011, 12:00 p.m. after one or more responses were posted
▼
Posts: 896
Threads: 183
Joined: Jul 2005
▼
Posts: 2,761
Threads: 100
Joined: Jul 2005
You've been quick! My editing involved checking my result upon Egan's Ford LAMBERTW program for the HP50g and other minor changes. No changes to the listing have been made.
Now, sorry for the dumb question: how to enter STO M, N, on the HP41? Thanks!
▼
Posts: 735
Threads: 34
Joined: May 2007
Quote:
how to enter STO M, N, on the HP41?
Cheers
Thomas
▼
Posts: 2,761
Threads: 100
Joined: Jul 2005
Quote:
Just use register 00 and 01 instead of M and N.
I'll stick to that :)
Thanks,
Gerson.
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Just as well.
Using registers N and M (part of the Alpha register) saves using standard registers that are often used by other programs.
Posts: 2,761
Threads: 100
Joined: Jul 2005
Quote:
W_{1}(0.367) = 1.070791879 (about 5 seconds on the HP12C+ and 2 min 20 sec on the HP41CX). Actual 10digit result: 1.070791887.
A faster method for the second branch should be appreciated.
A much faster program, using the Solver:
01 LBL 'WW
02 CHS
03 STO 01
04 1/x
05 LN
06 ENTER
07 LN
08 +
09 ENTER
10 ENTER
11 .5
12 +
13 'LL
14 SOLVE
15 CHS
16 END
01 LBL 'LL
02 e^x
03 /
04 RCL 01
05 
06 RTN
.367 XEQ WW > 1.070791885 (12 seconds). Actual 10digit result: 1.070791887.
▼
Posts: 1,253
Threads: 117
Joined: Nov 2005
WL0 and WL1 are available in the SandMath module. MCODE implementation, not using SOLVE (but internal iteration routine instead).
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Ah, thanks for that.
The Sandmath includes just about everything. Should have checked that listing of course.
Posts: 2,761
Threads: 100
Joined: Jul 2005
Hola Ángel,
I'm sure the SandMath module tackles these and other special functions hands down. I'll try it in an emulator, if this is possible. I was never an HP41 user, mine is used only occasionally.
Cheers,
Gerson.
▼
Posts: 1,253
Threads: 117
Joined: Nov 2005
Gerson you can use V41 from TOS  it works like a charm.
Cheers,
AM
Posts: 1,253
Threads: 117
Joined: Nov 2005
There´s a WL0 (and WL1 as well) MCODE function in the sandmath, so I´d suggest you use it to program your own expression and then use the Advantage´s SOLVE upon it.
Have you considered taking exponentials on each side of the equation?
Cheers,
ÁM
Edited: 29 Dec 2010, 2:42 p.m.
Posts: 896
Threads: 183
Joined: Jul 2005
To elaborate on the task at hand;
I am looking to see if a business area would benefit from a formalized process.
A task has the total cost (C) after N repetitions of c*N (where "c" is the cost of doing the task once). If N = n*y (where "n" is the number of times a task is done per year, and "y" is the number of years), we get the total cost of a task done over a certain number of years (or fraction(s) of years):
C = nyc (pun not intended) [#1]
If introducing a standardized process for the task gives an efficiency ratio of "E" (a number hopefully between 0 and 1), after the process is introduced we get:
C = nycE [#2]
But establishing a process has an initial cost of "I". To recuperate the cost, we get:
nyc  nycE > IR^y [#3]
where "R" is the needed return on investment: R = (1 + r/100) where "r" is the percentage needed as annual return on the investment. In some instances the initial cost is recuperated after a certain time, in other cases, the initial cost is never recuperated and a formalized process is not warranted.
If the task is repeated often and the cost of introducing a process is not too costly, it would be a sound business decision to formalize a process for the task  as is the case with an assembly belt production line. Other more unpredictable and emergent tasks are very seldom repeated and the initial cost is never recuperated.
The challenge is to solve equation #3 for y. Actually it would be good to create a program that would solve for any variable given the other variables in the equation (as in the Ohms Law program discussion recently).
I could settle for approximations instead of wild and complex equations as the real world cases are approximations in any case.
Take this as a math challenge :)
Any suggestions?
▼
Posts: 564
Threads: 72
Joined: Sep 2005
why dont you just use solve to find the value 'y' for which the left side equals the right side? You can use any number of available 'solve' programs, but probably the MCODE one in AdvantageMod should be just fine. You can even get fancy and use the FOCAL to MCODE program from a module (forgot its name right now) if speed is an issue. That way no fancy math is needed and that's what I probably would do as the required accuracy is probably pretty low and hence convergence would be very fast.
Cheers
Peter
▼
Posts: 896
Threads: 183
Joined: Jul 2005
I would like a direct approach with a symbolic solving of the equation and not to rely on a brute force SOLVE approach.
Edited: 29 Dec 2010, 2:54 p.m.
▼
Posts: 564
Threads: 72
Joined: Sep 2005
then wolfram has given you already the symbolic solution of your equation and you can go ahead and program it via one of the numerical procedures mentioned to evaluate W for a particular x.
My guess is that this will require a longer and slower Focal program (but I can see the greater appeal in programing the symbolic solution 100%)
Cheers
Peter
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Right, but I can't get my wits around how to treat the W function in a program  and so I am looking for approximations and creative genius to simplify the (to me) daunting Wolfram answer.
▼
Posts: 735
Threads: 34
Joined: May 2007
Try to transform the equation so that you can apply the Lambert W function:
Substitution:
No Wolfram Alpha required. QED.
Best regards
Thomas
Posts: 320
Threads: 59
Joined: Dec 2006
The LambertW function can't be written in terms of elementary functions, but may be approximated with a recipe of elementary functions depending on the domain for x you have in mind and the maximum allowable error. Any idea what the domain and error desired is?
CHUCK
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Well, in the equation #3 above, clarified is:
(nc(1E))/I > (R^y)/y [4]
then from my original equation;
"a" is R
"b" is (nc(1E))/I
A value for y here would have to lie in the area 07 for a sound business decision to be made.
▼
Posts: 735
Threads: 34
Joined: May 2007
I assume r > 0, thus a > 1.
The function
has a minimum at:
I suggest you have a look at the
graph.
To get real, positive solutions for
b has to be bigger than that:
In this case you will always get two solutions. The bad thing is, that you will lose in the long term: the exponential function outperforms any polynomial.
So you might want to rethink your model. Why is it that you don't get any interest for what you gain thanks to the more efficient standardized process? At least you could use that to pay back the initial cost.
Cheers
Thomas
Edited: 30 Dec 2010, 10:01 a.m.
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Quote:
Why is it that you don't get any interest for what you gain thanks to the more efficient standardized process? At least you could use that to pay back the initial cost.
Now that is a good point. One should of course accumulate interest on the gain per year after the implemented process...
Firstly:
The cost gain per year equals nc  ncE, and that should gain interest:
(n*c  n*c*E)*R
times number of years:
(n*c  n*c*E)*R*y > I*R^y
And then:
n*c*(1E)*R/I > (R^y)/y
I substitute E = (1f/100) to make the input in a program more intuitive as "f" would be the percentage of efficiency given by the process. I also substitute R = (1 + r/100) where "r" is the percentage needed as annual return on the investment for a more intuitive use. And to keep with only lower case and to make the initial cost easier to read, I substitute the letter "I" with "i". We get:
ncf(1+r/100)/100i > (1+r/100)^y/y [or: ncf(1+r/100)/100i > (1+r/100)^y/(1+r/100)y ]
Seems correct?
Then it is a matter of applying the Lambert W function to this and we get the result...
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Oops, not correct.
The compounded interest for the cost saving of the implemented process would actually be:
We need to divide every element by two as one would only get half the gain of each year as the process gets repeated throughout the year.
Now, to solve the resulting equation for the value "y" gets to be hell IMO  and beyond my current skills set. Can we simplify/approximate/make a shortcut somewhere?
Any takers?
▼
Posts: 564
Threads: 72
Joined: Sep 2005
at the risk of sounding like a broken record  what is so bad about using solve for such real life problems problems? Its fast, short and lets you change and adapt the code to fit the actual problem of your client quickly and easily. Given that you are interested in a reallife answer I simply don't see the benefit in writing an analytical solution that will for sure require some special function for which you need to write a numerical approximation etc etc
but that's just me...
Cheers
Peter
▼
Posts: 896
Threads: 183
Joined: Jul 2005
I am starting to lean toward your solution... :/
I would like to write a selfcontained program, though.
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
Looking at the graph, the function seems to be well behaved so writing the solver (e. g. Newton) yourself should not be the problem. You can even use the analytical derivative instead of an approximation in the algorithm because the function to be solved is known in advance.
Posts: 896
Threads: 183
Joined: Jul 2005
After excellent input here and some pondering and tweaking, I have come to this formula for the processability of a business area (whether an area warrants the formalization of a process):
 p = initial cost of implementing a process
 i = interest rate (return) needed for a sound business decision (as a percentage)
 t = number of time periods (the time period corresponds to "i"; usually yearly)
 n = number of times a task is done per time period (i.e. the number of times a process would get run per time period)
 c = cost of doin the task without a formalized process in place
 f = efficiency benefit from executing the task as a formalized process (as a percentage indicating how much one would benefit from the formalized process)
As long as one can estimate the initial cost (p) and the process efficiency (f), set the time period  usually yearly, the maximum payback time (t), set the required return (i) and estimate the number of times the process would be repeated per time period [per year] (n), the job of calculating whether the area would yield a profit from introducing a process is pretty straight forward. But if one would attempt to solve for e.g. "t", this gets tough.
How would I go about using SOLVE to solve this equation for "t"?
BTW: A short explanation of the elements in the equation: The first part is the initial cost with the compounded interest for the period evaluated. The second part is the economic gain from an implemented process  the gain comes from each repetition of the process and that gain gets compounded interest as well. The total cost of the implementation minus the total gain for the process should be negative to indicate a profit durin the time period one evaluates for.
Edited: 31 Dec 2010, 11:55 a.m. after one or more responses were posted
▼
Posts: 4,587
Threads: 105
Joined: Jul 2005
First, I'd throw away the unnecessary stuff:
by expressing i and f in real numbers. Then I'd turn back to your question:
Quote:
How would I go about using SOLVE to solve this equation for "t"?
Well, I have to admit I don't know how you would go about that ... d;>
▼
Posts: 896
Threads: 183
Joined: Jul 2005
:)
Well, those elements are unnecessary. But... It's a matter of using the numbers most familiar to a business person ("i" and "f" being percentages and all).
Posts: 3,283
Threads: 104
Joined: Jul 2005
If you'd expect to be t a non integer, I must admit I don't have a solution but with t being a (hopefully small) positive integer you can just compute the part left of the "" by repetitive multiplication and the sum by repetitive addition until the condition is met. You'll do n additions per multiplication.
If you want the result to be exact to the level of single instances of the process, just stop the summation as soon as the condition is met even if j is below n*t. j is then the total number of process executions for the break even.
Posts: 735
Threads: 34
Joined: May 2007
Though I'm not familiar with your business process I guess the interest of the economic gain is payed at the end of the time period and not when the task is done. So in fact you have a variant of an ordinary "time value of money" (TVM) problem with the following payment at the end of the period (year):
The interest rate i in this formula is already divided by 100 as suggested by Walter.
The present value PV corresponds to your initial cost of implementing a process while the future value FV = 0 (breakeven). Most solvers (e.g. HP12C, HP48GX, ...) use n for the number of time periods. So take care because you use this variable for the number of tasks (and that's also the meaning in my formula above). It might be better to use another variable instead.
It appears that the Advantage module contains a TVMsolver adapted from Finance Pac. So you can use either of these.
Best regards
Thomas
Edited: 2 Jan 2011, 12:40 p.m.
Posts: 896
Threads: 183
Joined: Jul 2005
Thanks for the input, guys  it's highly appreciated. I have now concluded with the following formula:
 p = initial cost of implementing a process
 i = interest rate (return) needed for a sound business decision (as a percentage)
 n = number of time periods (the time period corresponds to "i"; usually yearly)
 r = number of repetitions of the task per time period (i.e. the number of times a process would get run per time period)
 m = maintenance cost of having the process in place per time period (knowledge management cost, training cost)
 c = cost of doing the task without a formalized process in place
 f = efficiency benefit from executing the task as a formalized process (as a percentage indicating how much one would benefit from the formalized process)
With this, we now have a complete formula to identify whether it is an economically sound decision to formalize a process in a business area.
▼
Posts: 4,587
Threads: 105
Joined: Jul 2005
Watch out, this formula won't work with values entered as percenteages. Use real values instead.
▼
Posts: 896
Threads: 183
Joined: Jul 2005
I know. I took your advice :)
Posts: 735
Threads: 34
Joined: May 2007
Still I think the 3rd term in your equation is wrong.
Taking the additional maintenance cost into account I get:
From your formula I assumed m is paid at the end of the time period.
Then I used this formula for TVM calculations:
This may be simplified since FV = 0:
In your case PV and PMT have different signs:
That's what I end up with:
Now all you have to do is solve this equation for n. You're lucky! This can be done symbolically.
Best regards
Thomas
Edited: 3 Jan 2011, 2:53 p.m.
▼
Posts: 896
Threads: 183
Joined: Jul 2005
The reason I think the third term is correct is that for every time the process is run, one gets the profit "cf", but from then on and out until r*n, one will accrue interest on that one profit. The first profit will result in a total profit of cf(1+i/r)^(nr1), the next process run will result in a profit with accrued interest of one less, i.e. cf(1+i/r)^(nr2), all the way until the last process run which will accrue only cf as profit (which means that my third term is actually a tad wrong as it should be summed from j=0 [not j=1] until (nr1). All those profits with accrued interests are summed up for a total of the process gain over the time periods n.
I have updated the formula above to correct the error found.
▼
Posts: 735
Threads: 34
Joined: May 2007
It all depends on when the interest is paid: if it's at the end of the process I agree with you. But that's not how the banks I know handle it: the interest is usually paid at the end of the year. The interest is proportional to the time and of course the interest rate. The annual temporal ratio of the first process is (r1)/r while the last process (still of the first year) doesn't get any interest. Assuming the process is run monthly then r = 12 and the first process gets interest for 11 months and the last process gets none. If you sum all this up you get the annual payment PMT. Only from now on you get compound interest every year. It's up to you to decide whether to subtract the maintenance m once at the end of the year (as I did) or monthly. In the latter case the formula will slightly change.
You might also ignore this consideration altogether and use PMT = cfr  m instead if you're just interested in a rough approximation of n. As long as i << 1 and n is not too big it should still be quiet accuarate.
I hope I could clarify my objection.
Kind regards
Thomas
Bonus question:
What happens with your 3rd expression when r gets bigger and bigger but still the annual cost cr is constant?
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Yes, you did clarify your objection.
However, from a business viewpoint, you get compounded interest for every process gain as the alternative is not to put the money in the bank (as very few businesses do for investment). The alternative is to invest the money otherwise in the business that would get (also) immediate return/profit.
Do you agree that the formula is correct given that interest is calculated from every process repetition?
Edited: 4 Jan 2011, 2:10 a.m.
Posts: 735
Threads: 34
Joined: May 2007
Quote:
You might also ignore this consideration altogether and use PMT = cfr  m instead if you're just interested in a rough approximation of n.
Of course you want to use LN1+X to calculate that with your HP41. This should also be a good initial value for a solver of your equation.
Cheers
Thomas
Edited: 4 Jan 2011, 4:25 a.m.
Posts: 896
Threads: 183
Joined: Jul 2005
Rethinking this, I believe you are right  it would be the usual business optimism that interests are accrued after each gain (that would be the maximum of the gain, but not a realistic one). So, unless you have something to add to your formula above, I think we can conclude that your equation is the final answer for this chapter.
The next chapter would be to add Risk Management to the equation; We simply RCS to cf to obtain the gain from each process run, where R is the risk of the task going wrong (real number), C is the cost when/if it goes wrong and S is the security offered by the process (a real number between 0 and 1, where 0.1 indicates a 10% security added by the process). Thus, given that a task has 0.001 chance of failure and the corresponding average cost of such failure is 10000, the added risk cost per task is then 10. If a process would help the security of the process by 10%, the added value of doing the task via a formalized process is then 0.001*10000*0.1 = 1.
I use capital letters for RCS as it indicates a more "virtual" gain through Risk Management.
Viewpoints?
Edited: 4 Jan 2011, 7:31 a.m. after one or more responses were posted
▼
Posts: 896
Threads: 183
Joined: Jul 2005
And would you agree that the breakeven of the equation would be:
▼
Posts: 896
Threads: 183
Joined: Jul 2005
This equation is easy to solve for all variables, except "i". I'm up against a brick wall on that one.
▼
Posts: 735
Threads: 34
Joined: May 2007
cf. Calculating i
Not the solution but shows the way to go.
Posts: 735
Threads: 34
Joined: May 2007
What's the meaning of $^2 (or NOK^2) when you multiply cost c with cost C?
▼
Posts: 896
Threads: 183
Joined: Jul 2005
Sorry, changed it to addition, not multiplication  there is an economic gain from efficiency of the process and there is a "virtual" economic gain from the process minimizing failure of the task. Added, not multiplied. Thus, one could justify implementing a process purely from a security perspective or an efficiency perspective or both.
Posts: 735
Threads: 34
Joined: May 2007
Still you can use:
▼
Posts: 896
Threads: 183
Joined: Jul 2005
True. And nice.
But how do you account for p(1+i)^n?
I mean, one would get compounded interest over n periods for the initial investment if one would rather invest that cost into something else.
