## Discuss Scratch

chrdagos
Scratcher
500+ posts

### add "i" to operators

i think that scratch should have an
`(i ::: operators)`
block
(i is the square root of -1.)
R4356th
Scratcher
1000+ posts

### add "i" to operators

I think it would be too complex. So, no support.

Q/A Regarding the Suggestions Category & Why Some Suggestions Got Rejected
List of Scratch Modifications And Other Block-Based Programming Languages
Workarounds for Blocks Scratch Does Not Have
Scratch Translator SDS Translator Scratch Wiki Editor(Test (English and Bengali)& English) Writer Microsoft Dev 1000+ posts

If you found something offensive in my posts, I am so sorry for that.
chrdagos
Scratcher
500+ posts

### add "i" to operators

R4356th wrote:

I think it would be too complex. So, no support.
is that a pun?
because numbers of the form a+bi are called complex numbers
Za-Chary
Scratch Team
1000+ posts

### add "i" to operators

Out of curiosity — and this is for someone else to answer, not me — how often are complex numbers used in programming? I don't know of many uses for this other than maybe a complex number calculator.

Complex numbers are a little tricky, though. Workarounds do exist, although perhaps not very “clean” ones. Would you expect other blocks to adapt to complex numbers, then? For instance, would

`((i) * (i)) // colored orange for visibility`

return –1? And would

`([sqrt v] of (-1))`

return i? The issue with this one is that it might convince elementary school students that you can take square roots of negative numbers — which is true, but in a grade-school standpoint, students are not expected to know this yet.

Moreover, this would especially be troublesome if you try to do

`([sqrt v] of (i))`

as there are two square roots of i. Namely, (1+i)/sqrt(2) and (–1–i)/sqrt(2). I suppose you could make it return the principal root?

Furthermore, complex exponentials require some thought, as well. We'd need to make sure that

`([e^ v] of ((i) * (3.14159)) :: operators)`

returns something close to 1, and similarly for other complex exponentials. Complex trigonometry is also tricky; would we expect

`([arccos v] of (2) :: operators)`

to give us an answer? Ordinarily, no — but there is a complex number z such that cos(z) = 2, so this block should return something in terms of complex numbers.

Complex analysis is very tricky indeed. I feel like it could create unexpected issues in some pieces of code. But I imagine it could work. It all depends on, however, whether this really proves to be useful for Scratch programming.

University of Minnesota Mathematics major, Scratch Team member, and Nintendo enthusiast.

Za-Chary's Game Museum
The Official List of Rejected Suggestions
Interesting mathematics I am currently studying [updated 5/27/2020]
Seth_Zaw
Scratcher
100+ posts

### add "i" to operators

Workaround: NaN (the string)

All the triangular numbers 1 - 55:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55
1+3=4=2²
3+6=9=3²
6+10=16=4²
10+15=25=5²
I see a pattern.
`when Scratch [4.0 v] comes out :: events hatremove [wings v] from [hippo v] sprite`
chrdagos
Scratcher
500+ posts

### add "i" to operators

Seth_Zaw wrote:

Workaround: NaN (the string)
that doesn't work.
chrdagos
Scratcher
500+ posts

### add "i" to operators

Za-Chary wrote:

I don't know of many uses for this other than maybe a complex number calculator.
how about a quadratic equation grapher, for when the roots are imaginary.
NxNmultiply
Scratcher
100+ posts

### add "i" to operators

chrdagos wrote:

Seth_Zaw wrote:

Workaround: NaN (the string)
that doesn't work.
In case of double precision arithmetic, it's the same thing.

Or
`((0)/(0))`
or
`([sqrt v] of (-1))`
hedgehog_blue
Scratcher
1000+ posts

### add "i" to operators

NxNmultiply wrote:

chrdagos wrote:

Seth_Zaw wrote:

Workaround: NaN (the string)
that doesn't work.
In case of double precision arithmetic, it's the same thing.

Or
`((0)/(0))`
or
`([sqrt v] of (-1))`
I think the suggestion is to change the computing system entirely to be based on complex numbers instead of being limited to real numbers.

Jonathan50
Scratcher
1000+ posts

### add "i" to operators

hedgehog_blue wrote:

I think the suggestion is to change the computing system entirely to be based on complex numbers instead of being limited to real numbers.
It does seem like that. But this block would be redundant, because you would be able to simply use
`set [i v] to ([sqrt v] of (-1))`

Za-Chary wrote:

The issue with this one is that it might convince elementary school students that you can take square roots of negative numbers — which is true, but in a grade-school standpoint, students are not expected to know this yet.
The Scratch Team is responsible for hiding maths facts from students?
I suppose you could make it return the principal root?
It already does so. There are two square roots of every number but zero.

Snap! has a block library which allows the use of complex numbers like this.
Maximouse
Scratcher
1000+ posts

### add "i" to operators

This could also be an extension. It would contain variants of the built-in operators but with complex number support.

`([sqrt v] of (-1)) // NaN(complex [sqrt v] of (-1) :: pen) // 0 + 1i`

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
ggenije
Scratcher
100+ posts

### add "i" to operators

Workaround:
Instead of using one variable use two variable for complex number - one for real and one for imaginary part of complex number:
`(realPart)  (imaginaryPart)set [realPart v] to [-1]set [imaginaryPart v] to [0]`
And this is how you operate:
`define {+}sum of (a) + (b)i and (c) + (d)iset [returnReal v] to ((a)+(c))set [returnImaginary v] to ((b)+(d))define {*} product of (a) + (b)i and (c) + (d)iset [returnReal v] to (((a)*(c)) - ((b)*(d)))set [returnImaginary v] to (((a)*(d)) + ((b)*(c)))//use next script to divide a* inverse(b) = a/bdefine {^-1} inverse of (a) + (b)i set[r v] to  (((a) * (a)) + ((b) * (b)))set [returnReal v] to ((a) / (r))set [returnImaginary v] to ((()-(b)) / (r))define square root of (a) + (b)iset[r v] to ([sqrt v] of (((realPart) * (realPart)) + ((imaginaryPart) * (imaginaryPart))))set [returnReal v] to ([sqrt v] of ((0.5) * ((r) + (a))))//this can be multiplied by -1 because if e.g. x^2=1 then x can be -1set [returnImaginary v] to (((<(y) > [0]> * (2)) - (1))* ([sqrt v] of ((0.5) * ((r) - (a))) ) )//this must be multiplied by -1 if previous part is multiplied by -1`

and then
`(i ::: operators)`
is same as
`set [realPart v] to [0]set [imaginaryPart v] to [1]`

Last edited by ggenije (April 7, 2020 12:45:05)

--Explosion--
Scratcher
1000+ posts

### add "i" to operators

But what if someone used this in a repeat loop, or something of that sort? No support since i is not a real number and has norational value.
Za-Chary
Scratch Team
1000+ posts

### add "i" to operators

Jonathan50 wrote:

The Scratch Team is responsible for hiding maths facts from students?
Well… (and this viewpoint might differ from person to person) … at some point in students' lives they are told that x^2 = -1 has no solution, and I assume they would be expected to write that on a test. If they instead wrote “i and -i,” they might get the question wrong simply because they weren't supposed to have learned complex numbers yet.

This is sorta similar to another issue I've heard of, where a British student got points off on their spelling test because they spelled “favorite,” as they learned this spelling from Scratch (where they were supposed to have written the alternative British spelling, “favourite”).

University of Minnesota Mathematics major, Scratch Team member, and Nintendo enthusiast.

Za-Chary's Game Museum
The Official List of Rejected Suggestions
Interesting mathematics I am currently studying [updated 5/27/2020]
chrdagos
Scratcher
500+ posts

chrdagos
Scratcher
500+ posts

NxNmultiply
Scratcher
100+ posts

### add "i" to operators

hedgehog_blue wrote:

NxNmultiply wrote:

chrdagos wrote:

Seth_Zaw wrote:

Workaround: NaN (the string)
that doesn't work.
In case of double precision arithmetic, it's the same thing.

Or
`((0)/(0))`
or
`([sqrt v] of (-1))`
I think the suggestion is to change the computing system entirely to be based on complex numbers instead of being limited to real numbers.
Oh, you mean like https://scratch.mit.edu/discuss/topic/348293/ (it would allow reverse sound)
A-E-
Scratcher
100+ posts

### add "i" to operators

JS will return NaN for Math.sqrt(-1), so Scratch would need to use a custom solution.
lisa_wolfgang
Scratcher
100+ posts

### add "i" to operators

Although it would surely be interesting to play with, I've only ever heard of i being used in real life by electricians. Since (and I'm just going out on a limb here) I'm guessing not very many electricians use Scratch – with the exception of some Physics II students, maybe – I think it would be a very niche feature.

Want to try the stage on the left again? Go here for instructions.
Za-Chary
Scratch Team
1000+ posts

### add "i" to operators

lisa_wolfgang wrote:

Although it would surely be interesting to play with, I've only ever heard of i being used in real life by electricians. Since (and I'm just going out on a limb here) I'm guessing not very many electricians use Scratch – with the exception of some Physics II students, maybe – I think it would be a very niche feature.
They're also used pretty extensively in solving partial differential equations — which is a part of physics, not necessarily electrical engineering. Of course, not many people here study partial differential equations anyway.

University of Minnesota Mathematics major, Scratch Team member, and Nintendo enthusiast.

Za-Chary's Game Museum
The Official List of Rejected Suggestions
Interesting mathematics I am currently studying [updated 5/27/2020]