Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Cube Roots
- Imaginary_Numbers
-
Scratcher
42 posts
Cube Roots
Ok, first I want to say 1 thing: Yes I Know there are other threads where this has been discussed many times over! But all the replies had was the script. What I completely don't understand is how it work! Could someone PLEASE not only give me the script, but also show me how it works, so that I could change it to 4th roots, 5th roots, and so on? Or how I could modify it to use a different way? Thx in advance 

<(SCRATCH) = (PI)>
<(PI) = [AMAZING]>
- deck26
-
Scratcher
1000+ posts
Cube Roots
I'm guessing most solutions use logarithms. With logs, instead of multiplying you can add the logs.
So log(x) + log(y) = log(x*y)
If that's the case then log (x cubed) = log(x) + log(x) + log(x).
So to get the cube root of a number convert to log, divide by 3 then convert back.
So cube root of x is
So log(x) + log(y) = log(x*y)
If that's the case then log (x cubed) = log(x) + log(x) + log(x).
So to get the cube root of a number convert to log, divide by 3 then convert back.
So cube root of x is
([10 ^] of (([log] of (x)) / (3)))
- Imaginary_Numbers
-
Scratcher
42 posts
Cube Roots
So lets say I used this script:
Then the sprite would say the “y root of x” or for example, the “cubed root of 27”
Would this script?
And are you saying that if I were to remove the
ask [What is the Base?] and wait
set [x v] to (answer)
ask [What is the Root?] and wait
set [y v] to (answer)
say ([10 ^ v] of (([log v] of (x)) / (y)))
Then the sprite would say the “y root of x” or for example, the “cubed root of 27”
Would this script?
And are you saying that if I were to remove the
(() / (y))then it would somehow give me x^1 ??
- deck26
-
Scratcher
1000+ posts
Cube Roots
So lets say I used this script:Well yes, that's effectively the definition of how logs work. NB The base is the number that is raised to the power of the log value to reverse the process so your use of the term ‘base’ is slightly confusing.ask [What is the Base?] and wait
set [x v] to (answer)
ask [What is the Root?] and wait
set [y v] to (answer)
say ([10 ^ v] of (([log v] of (x)) / (y)))
Then the sprite would say the “y root of x” or for example, the “cubed root of 27”
Would this script?
And are you saying that if I were to remove the(() / (y))then it would somehow give me x^1 ??
So
log of 100 is 2 since 10 to the power 2 is 100.
ln is the logarithm to the base e (known as natural logarithms).
- Discussion Forums
- » Help with Scripts
-
» Cube Roots

