Page 1 of 1

how to do square root or x^2 in the dsp component.

Posted: Wed Apr 16, 2014 2:22 am
by joejoe
I've been trying to do a exponential calculation in the dsp command.

-It seems we have the exp(x) expression, but this doesn't seem to do what it should. (see attached)

-Normally on a calculator such as the TI-83 we can do 2^2= 4. Doing this in the DSP component the IDE willregisters it as a expression as it turns pink however I cant seem to find the necessary syntax to get a valid expression.

Any help is greatly appreciated.

Re: how to do square root or x^2 in the dsp component.

Posted: Wed Apr 16, 2014 3:13 am
by joejoe
looks like I figured it out!

y = pow(x,2) where x = base and 2 is the exponent.

Re: how to do square root or x^2 in the dsp component.

Posted: Wed Apr 16, 2014 8:05 am
by martinvicanek
To save CPU load, use x*x instead of pow(x,2), Use sqrt(x) instead of pow(x,0.5). There are also optimized modules for powers with arbitrary exponents.