This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-30 23:45:57

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Complex number, exponentiation, etc. support

I think maybe we could add in complex number support, as well as things like this:

<(x)^(y)>, computes x^y,
<log (x) base (y)>, computes ln(x)/ln(y), the logarithm of x to base y,
and sin, cos, tan, asin, acos, and atan taken out of the sqrt, e^, 10^, log, ln, etc. menu and put in a block which is like this:

<[sin v] of (x) in [degrees v]>. Note that the first dropdown menu should contain sin, cos, tan, asin, acos, and atan and the second should contain degrees, radians, and hyperbolic.

Offline

 

#2 2012-10-30 23:49:23

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Oh, sorry, it should have been:

I think maybe we could add in complex number support, as well as things like this:

<(x)^(y)> //computes x^y
<log (x) base (y)> //computes ln(x)/ln(y), the logarithm of x to base y
,
and sin, cos, tan, asin, acos, and atan taken out of the sqrt, e^, 10^, log, ln, etc. menu and put in a block which is like this:

<[sin v] of (x) in [degrees v]>
. Note that the first dropdown menu should contain sin, cos, tan, asin, acos, and atan and the second should contain degrees, radians, and hyperbolic.

Offline

 

#3 2012-10-30 23:52:32

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Sorry again, it should have been:


<(x)^(y)> //computes x^y
,
and
<log (x) base (y)> //computes the logarithm of x to base y

Offline

 

#4 2012-10-30 23:56:34

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Sorry, maybe instead of adding hyperbolic to the second dropdown list, there should be sinh, cosh, tanh, asinh, acosh, and atanh added to the e^, 10^, log, ln, sqrt, etc. menu.

Offline

 

#5 2012-10-31 00:19:07

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Complex number, exponentiation, etc. support

Yes. Support. I'd love to choose degrees or radians and have better exponentation and logarithms.


........................................................................................................................................................................................................................................

Offline

 

#6 2012-10-31 00:26:39

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

zubblewu wrote:

Yes. Support. I'd love to choose degrees or radians and have better exponentation and logarithms.

Did you remember the complex numbers and the hyperbolic trig functions?

Offline

 

#7 2012-10-31 00:35:04

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Complex number, exponentiation, etc. support

Yep. Those would be useful as well. Maybe also secant.


........................................................................................................................................................................................................................................

Offline

 

#8 2012-10-31 01:00:03

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Yes. I thought about it, then I decided that we could do 1 divided by the functions we already have, then I realized it would be just as much of a shortcut as tan(x)=sin(x)/cos(x). Also maybe cotangent and cosecant.

Offline

 

#9 2012-10-31 01:37:38

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Complex number, exponentiation, etc. support

wiz99903 wrote:

Yes. I thought about it, then I decided that we could do 1 divided by the functions we already have, then I realized it would be just as much of a shortcut as tan(x)=sin(x)/cos(x). Also maybe cotangent and cosecant.

Yes, definitely.


........................................................................................................................................................................................................................................

Offline

 

#10 2012-10-31 16:22:25

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Complex number, exponentiation, etc. support

Support, esp. the complex numbers. Would be realyl helpful for things like mandelbrot set, though you're going to have a hard time to explain it to the little kids.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#11 2012-10-31 18:00:59

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Complex number, exponentiation, etc. support

You can (technically) do this (and anything) yourself in scratch as it is Turing complete. Scratch is a language for kids, and even many adults don't understand complex numbers and hyperbolic trigonometry. I support for maybe an "advanced scratch" or scratch with an advanced mode, but I really think it will confuse most scratchers.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#12 2012-10-31 18:01:39

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Yes. Then we could do things like:


<[e^ v] of (3.14159265i)>
and





<[sqrt v] of <[log v] of 0.1>>

Offline

 

#13 2012-10-31 18:16:11

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Complex number, exponentiation, etc. support


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#14 2012-10-31 18:40:47

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

In fact, I made a program that was supposed to be able to calculate exponentials and absolute values of complex numbers, until I realized that De Moivre's formula e^(ix)=cos(x)+sin(x)i, was being computed in radians. The code I used was:


say [I can calculate the exponential or absolute value of a complex number.]
ask [What is the real part of the complex number?] and wait
set [rez0 v] to (answer)
ask [What is the imaginary part of the complex number?] and wait
set [imz0 v] to (answer)
ask [Do you want the exponential or absolute value of the number? (0=exponential, 1=absolute value)] and wait
set [op v] to (answer)
if <(op)=0>
set [rez1 v] to <<[e^ v] of (rez0)>*<[cos v] of (imz0)>>
set [imz1 v] to <<[e^ v] of (rez0)>*<[sin v] of (imz0)>>
else
if <(op)=1>
set [rez1 v] to <[sqrt v] of <<(rez0)*(rez0)>+<(imz0)*(imz0)>>>
set [imz1 v] to (0)
end

The code should have been:

say [I can calculate the exponential or absolute value of a complex number.]
ask [What is the real part of the complex number?] and wait
set [rez0 v] to (answer)
ask [What is the imaginary part of the complex number?] and wait
set [imz0 v] to (answer)
ask [Do you want the exponential or absolute value of the number? (0=exponential, 1=absolute value)] and wait
set [op v] to (answer)
if <(op)=0>
set [rez1 v] to <<[e^ v] of (rez0)>*<[cos v] of (imz0) in [radians v]>>
set [imz1 v] to <<[e^ v] of (rez0)>*<[sin v] of (imz0) in [radians v]>>
else
if <(op)=1>
set [rez1 v] to <[sqrt v] of <<(rez0)^2>+<(imz0)^2>>>
set [imz1 v] to (0)
end

Offline

 

#15 2012-10-31 18:43:47

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Sorry again! The code should have been:



say [I can calculate the exponential or absolute value of a complex number.]
ask [What is the real part of the complex number?] and wait
set [rez0 v] to (answer)
ask [What is the imaginary part of the complex number?] and wait
set [imz0 v] to (answer)
ask [Do you want the exponential or absolute value of the number? (0=exponential, 1=absolute value)] and wait
set [op v] to (answer)
if <(op)=0>
set [rez1 v] to <<[e^ v] of (rez0)>*<[cos v] of (imz0) in [radians v]>>
set [imz1 v] to <<[e^ v] of (rez0)>*<[sin v] of (imz0) in [radians v]>>
else
if <(op)=1>
set [rez1 v] to <[sqrt v] of <<(rez0)^2>+<(imz0)^2>>>
set [imz1 v] to (0)
end

Offline

 

#16 2012-10-31 18:47:09

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

Or maybe we could just use the e^ and abs functions with complex number support.

Offline

 

#17 2012-10-31 20:20:23

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Complex number, exponentiation, etc. support

wiz99903 wrote:

<(x)^(y)> //computes x^y
<log (x) base (y)> //computes ln(x)/ln(y), the logarithm of x to base y

x^y is easily calculatable using repeats. It may not be efficient, but it works.
Why would you need a block to calculate ln(x)/ln(y) if there already exists ln(z) and a/b?

Last edited by kayybee (2012-10-31 20:20:53)

Offline

 

#18 2012-10-31 21:01:04

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Complex number, exponentiation, etc. support

kayybee wrote:

wiz99903 wrote:

<(x)^(y)> //computes x^y
<log (x) base (y)> //computes ln(x)/ln(y), the logarithm of x to base y

x^y is easily calculatable using repeats. It may not be efficient, but it works.
Why would you need a block to calculate ln(x)/ln(y) if there already exists ln(z) and a/b?

Neither of those are there. I'm not sure if the log had a work around, I don't remember right now.. To the power of can be worked around with e and ln or the normal log and ^10. Still, these would be very useful.


........................................................................................................................................................................................................................................

Offline

 

#19 2012-10-31 23:14:26

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

The complex number support would help me with my creation of complex number calculators.

Offline

 

#20 2012-10-31 23:21:55

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Complex number, exponentiation, etc. support

wiz99903 wrote:

The complex number support would help me with my creation of complex number calculators.

Or perhaps you can code that yourself?

Scratch is about figuring out how to do things, not requesting things to make others easier.

It's possible to program a complex number system. It's just that each variable will need a countervariable for the imaginary part.

Or you can use one variable and make a script that can separate it like 5:-2 would be 5-2i.

Last edited by kayybee (2012-10-31 23:23:19)

Offline

 

#21 2012-10-31 23:57:42

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

I would make a mod or something, except I don't know how to do it. Has anyone already made a mod?

Offline

 

#22 2012-11-01 00:25:14

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Complex number, exponentiation, etc. support

wiz99903 wrote:

I would make a mod or something, except I don't know how to do it. Has anyone already made a mod?

It's not necessary to create a mod of Scratch just for a calculator; all you need to do is make your project compute complex numbers.

Offline

 

#23 2012-11-01 00:44:09

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

I have some problems. I don't know how to get the argument, logarithm (in any base), or anything like that for a complex number.

Offline

 

#24 2012-11-01 01:08:59

wiz99903
New Scratcher
Registered: 2012-10-23
Posts: 53

Re: Complex number, exponentiation, etc. support

If we had complex number support, we could add arg to the sin/cos/tan menu described earlier:



<[arg v] of (1+i) in [degrees v]>


would give 45.

Offline

 

#25 2012-11-01 01:11:03

BoltBait
Scratcher
Registered: 2009-03-09
Posts: 1000+

Re: Complex number, exponentiation, etc. support

Funny, when I saw the title of this thread, I assumed when you were talking about complex numbers you were talking about this:

a + bi

and, I was wondering how you might use such a number in a script.  hmm

Last edited by BoltBait (2012-11-01 01:12:50)


Animated sigs must be banned!
http://boltbait.com/j.pnghttp://boltbait.com/s.pnghttp://boltbait.com/d.pnghttp://boltbait.com/a.pnghttp://boltbait.com/p.png

Offline

 

Board footer