Re: Simple RPN with EXP goes wrong
Steve Shipway <[email protected]> Sat, 13 Feb 2016 23:10:03 +0000
| Newsgroups | gmane.comp.db.rrdtool.user |
|---|---|
| Message-ID | <5820DC553954E44FA1A36C78323AD148A408569D@uxcn10-6.UoA.auckland.ac.nz> |
> Example: 3*x^2 > I thought this would be in rpn: 3,x,2,EXP,* > However, rrdtool is complaining "ERROR: RPN final stack size != 1" EXP is the reverse of the natural log, sometimes called 'antilog' ; IE, e^X, NOT X squared. It also does not take a second argument as it always uses e (2.71828etc). Thus, your RPN above ens up with two items in the stack (3, and x(e^2)) If you want to raise X to the power of Y, then there is no single RPN function to do it. Instead, you need to work through logarithms. e^( log(x) + log(y) ) == x * y ( a long way to go about it ) e^( log(x) * y ) == x ^ y Or, in RPN, x,LOG,y,*,EXP I agree it would be helpful to have a new command (eg. 'x,y,POW') to do this in a single operation, but nobody has submitted it yet... Steve Steve Shipway University of Auckland ITS UNIX Systems Design Lead [email protected] Ph: +64 9 373 7599 ext 86487