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

For general discussion related FlowStone
Post Reply
joejoe
Posts: 23
Joined: Mon Oct 21, 2013 2:28 am

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

Post 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.
Attachments
exp test.fsm
(1.23 KiB) Downloaded 968 times
joejoe
Posts: 23
Joined: Mon Oct 21, 2013 2:28 am

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

Post by joejoe »

looks like I figured it out!

y = pow(x,2) where x = base and 2 is the exponent.
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

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

Post 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.
Post Reply