BrocParticipant
Average
Is there a Prorealtime POWER math function e.g.
y = x^3 as in 4^3 = 64?
Unfortunately no, this is a already a query for new instruction in the users wish list: https://www.prorealcode.com/topic/centralization-of-queries-and-suggestions-on-prorealtime/
The best you could do to get the result of this math function is by making a loop like this:
number=4
pow=3
result=0
i=1
while i<pow do
if i=1 then
result=number
endif
result=result*number
i=i+1
wend
return result
Let me know if it’s clear for you.
BrocParticipant
Average
Hi Nicolas
Thanks for the prompt reply!
I have found a mathematical equivalent if the Prorealtime LOG function (called Napierian log in the manual) is actually the common LN function:
y = x^p = e^(p*LN(x))
This could then be coded as:
y = EXP(p*LOG(x))
This works fine.
W
Thanks for your answer wessel 😉
How did you know that ?
BrocParticipant
Average
I had to do a bit of math research… Prorealtime could use this formula to create an easy power math function.
B-)
MazParticipant
Veteran
I have a power function like this?
// n = 2
// x = 3
// r = n^x
once j = x-1
r = n
if x > 0 then
for i = 1 to j do
r = (r * n)
next
else
for i = 1 to j do
r = (r / n)
next
endif
return r
MazParticipant
Veteran
Here’s tanh (subsequently sinh and cosh)
// x = 2
// result = tanh(x)
once e = exp(1)
mx = x * -1
eX = CALL fnPower[e, x]
eXm = CALL fnPower[e, mx]
sinh = 0.5* (eX - eXm)
cosh = 0.5* (ex + eXm)
tanh = sinh / cosh
return tanh
See above for powers
MazParticipant
Veteran
You’re welomce; unfortunately it’s very slow but that’s all we have for now 🙂