In article 
<5820dc553954e44fa1a36c78323ad148a4085...@uxcn10-6.uoa.auckland.ac.nz>,
Steve Shipway <s.ship...@auckland.ac.nz> wrote:
> > 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...

Of course if you just want the square, replace x^2 with x*x to give 3*x*x: 
3,x,DUP,*,*

Cheers
Tony
-- 
Tony Mountifield
Work: t...@softins.co.uk - http://www.softins.co.uk
Play: t...@mountifield.org - http://tony.mountifield.org

_______________________________________________
rrd-users mailing list
rrd-users@lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

Reply via email to