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

#226 2011-04-23 11:54:04

DarthPickley
Scratcher
Registered: 2008-06-13
Posts: 100+

Re: Calling all math lovers and good programmers

... first of all, I think Paddle2See already made something like this.
you won't be able to do complex numbers at all probably unless you create some sort of complex number class... but if you handle the complex number data structure, I know a lot about complex numbers.

but if you don't do them, that's great... I still have another suggestion.
Include hyperbolic trig functions, and allow it to use radians... probably like a button you press to turn radians on or off. you just have to change how you do all your trig stuff by adding an if block and saying "sin( val ) " or "sin( pi / 180 * val )", and you really need to include pi as a global [static] variable...

and implementing factorial (could be tricky) but trickier would be the gamma function...

Offline

 

#227 2011-04-23 14:10:42

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

amcerbu wrote:

scimonster wrote:

What I've done so far:
Adds numbers into 1 item
Adds ops
Adds brackets
Does the following multiple letter ops:
  sqrt
  abs (and ||)
  mod
  round
  sin
  cos
  tan
  atan
  asin
  acos

You may have a TI84 or not, but I think that the multi-letter operations should work only within parentheses.  That is, sin(5), not sin 5, sqrt(5), not sqrt 5, etc.  That will clear up any unclear operations like sin 5*5: sin(5)*6 or sin(5*6)?  The "sin()" part itself will work as a unit, so 5sin(5)+2 will report 5*sin(5)+2. 

As far as your list of operations goes, I don't see anything missing. 

I think we should also provide support for user defined variables, so an input that reads "define x" will create a variable named x, and setting a variable's value will be achieved by "x=8" (storing values can be handled by two parallel lists, one for names, one for values). 

Me- Awaiting deployment.

Yes, I already knew that. For the |-3| it would add

abs
(
-3
)

Also, "sin 3-7" is (sin(3)-7).
I hope it will check for parentheses after any multiple letter thing, and sqrt.

Edit:I don't have TI84.
NonDoubleEdit: Is "sin-1" taken as "asin" or "sin(-1)"?

Last edited by scimonster (2011-04-23 14:11:59)

Offline

 

#228 2011-04-23 17:18:47

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

scimonster wrote:

Is "sin-1" taken as "asin" or "sin(-1)"?

I think sin-1 should report sin(-1).  asin is more elegant (and easier to check for) than sin-1, which contains both letters and numbers.

Offline

 

#229 2011-04-24 00:16:37

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

amcerbu wrote:

scimonster wrote:

Is "sin-1" taken as "asin" or "sin(-1)"?

I think sin-1 should report sin(-1).  asin is more elegant (and easier to check for) than sin-1, which contains both letters and numbers.

OK, I'll remove those.

EDIT: Is it worth it to have arctangent become atan, natural log become ln, and square root become √?

Last edited by scimonster (2011-04-24 03:07:28)

Offline

 

#230 2011-04-25 00:22:53

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

Hi, I'm back! What did I miss?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#231 2011-04-25 00:51:37

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

Welcome back, Hardmath! 

scimonster wrote:

amcerbu wrote:

scimonster wrote:

Is "sin-1" taken as "asin" or "sin(-1)"?

I think sin-1 should report sin(-1).  asin is more elegant (and easier to check for) than sin-1, which contains both letters and numbers.

OK, I'll remove those.

EDIT: Is it worth it to have arctangent become atan, natural log become ln, and square root become √?

scimonster- I think that would just cloud the program.  I don't think the user would want to write out "square root" anyway.  It's really up to you, but I would say leave it to abbreviations.  Of course, we could include a key to all of the operations in the project notes, but that will come later.

Offline

 

#232 2011-04-25 02:06:37

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

So, here's a list of operations/constants.  I say we keep this list running, so people should definitely add whatever I forgot. 

Constants:
pi
phi
e

Operations- note that commas cannot be removed from multi-argument expressions. 
+, -, *, /,^
sqrt(x)
abs(x) (or |x|)
mod(x,y) or x%y- (in order of operations, comes before anything else.)
log(x,y)- y is base.
ln(x) (we may not need this if we have log(x) and constant e).
rand(x,y)- x and y are minimum, maximum respectively.
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), possibly include sinh(x), cosh(x), tanh(x)?
round(x,y)- y is the power of 10 we round to.

Last edited by amcerbu (2011-04-25 22:15:09)

Offline

 

#233 2011-04-25 04:31:55

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Calling all math lovers and good programmers

What did I miss?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#234 2011-04-25 09:38:02

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

Not much, we just discussed what the proper syntax for multi-letter operations would be.  We decided that "sqrt 5" would confuse the program, so it will take "sqrt(5)" instead.

Offline

 

#235 2011-04-25 15:01:47

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

amcerbu wrote:

Not much, we just discussed what the proper syntax for multi-letter operations would be.  We decided that "sqrt 5" would confuse the program, so it will take "sqrt(5)" instead.

But it will interpret "sqrt 5" as "sqrt(5)" and "sqrt 5+5" as "(sqrt(5))+5)"

Last edited by scimonster (2011-04-25 15:02:09)

Offline

 

#236 2011-04-25 19:26:57

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

scimonster wrote:

amcerbu wrote:

Not much, we just discussed what the proper syntax for multi-letter operations would be.  We decided that "sqrt 5" would confuse the program, so it will take "sqrt(5)" instead.

But it will interpret "sqrt 5" as "sqrt(5)" and "sqrt 5+5" as "(sqrt(5))+5)"

So how will it deal with "sqrt 5*5" ?

Offline

 

#237 2011-04-25 19:40:14

Taneb
Scratcher
Registered: 2009-07-07
Posts: 100+

Re: Calling all math lovers and good programmers

amcerbu wrote:

scimonster wrote:

amcerbu wrote:

Not much, we just discussed what the proper syntax for multi-letter operations would be.  We decided that "sqrt 5" would confuse the program, so it will take "sqrt(5)" instead.

But it will interpret "sqrt 5" as "sqrt(5)" and "sqrt 5+5" as "(sqrt(5))+5)"

So how will it deal with "sqrt 5*5" ?

If I can pitch in, (sqrt(5)*5). Indices (including sqrt which is equivalent to ^0.5) take precedence over multiplication. With sqrt 5^5 it doesn't actually make a difference.

Offline

 

#238 2011-04-25 22:08:36

DarthPickley
Scratcher
Registered: 2008-06-13
Posts: 100+

Re: Calling all math lovers and good programmers

Taneb wrote:

amcerbu wrote:

scimonster wrote:


But it will interpret "sqrt 5" as "sqrt(5)" and "sqrt 5+5" as "(sqrt(5))+5)"

So how will it deal with "sqrt 5*5" ?

If I can pitch in, (sqrt(5)*5). Indices (including sqrt which is equivalent to ^0.5) take precedence over multiplication. With sqrt 5^5 it doesn't actually make a difference.

If sqrt works differently from other functions, then it doesn't matter for 5^5 ...
Order does matter for things such as sin pi ^ 2, where it would make sense to normally interpret it as ( sin (pi) ) ^ 2. however, for something like atan x ^ 0.5, it would make more sense to interpret it as atan (x^0.5). For log a ^ b, I think that log (a^b) makes more sense.
Finally, are you going to only allow e^ x, or will you also include an exp[ x ] function?
Also, I am not sure which is the best way to interpret a^b^c

Offline

 

#239 2011-04-25 22:14:13

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

DarthPickley wrote:

Taneb wrote:

amcerbu wrote:


So how will it deal with "sqrt 5*5" ?

If I can pitch in, (sqrt(5)*5). Indices (including sqrt which is equivalent to ^0.5) take precedence over multiplication. With sqrt 5^5 it doesn't actually make a difference.

If sqrt works differently from other functions, then it doesn't matter for 5^5 ...
Order does matter for things such as sin pi ^ 2, where it would make sense to normally interpret it as ( sin (pi) ) ^ 2. however, for something like atan x ^ 0.5, it would make more sense to interpret it as atan (x^0.5). For log a ^ b, I think that log (a^b) makes more sense.
Finally, are you going to only allow e^ x, or will you also include an exp[ x ] function?
Also, I am not sure which is the best way to interpret a^b^c

I am in favor of enclosing arguments for multi-letter expressions in parentheses always.  See earlier post with list of expressions and constants. 

About a^b^c, you evaluate from left to right, so (a^b)^c.

Offline

 

#240 2011-04-25 22:35:13

TVflea
Scratcher
Registered: 2010-08-14
Posts: 1000+

Re: Calling all math lovers and good programmers

i love math and am good at programming...


-iNetMaster-'s not dead, get used to it. ! big_smile .
http://is.gd/YrQzXX

Offline

 

#241 2011-04-25 23:43:26

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

amcerbu wrote:

DarthPickley wrote:

Taneb wrote:

If I can pitch in, (sqrt(5)*5). Indices (including sqrt which is equivalent to ^0.5) take precedence over multiplication. With sqrt 5^5 it doesn't actually make a difference.

If sqrt works differently from other functions, then it doesn't matter for 5^5 ...
Order does matter for things such as sin pi ^ 2, where it would make sense to normally interpret it as ( sin (pi) ) ^ 2. however, for something like atan x ^ 0.5, it would make more sense to interpret it as atan (x^0.5). For log a ^ b, I think that log (a^b) makes more sense.
Finally, are you going to only allow e^ x, or will you also include an exp[ x ] function?
Also, I am not sure which is the best way to interpret a^b^c

I am in favor of enclosing arguments for multi-letter expressions in parentheses always.  See earlier post with list of expressions and constants. 

About a^b^c, you evaluate from left to right, so (a^b)^c.

And so 15/3/5 is (15/3)/5. Always follow OOO.

No need for an exp(y) function.

EDIT:

amcerbu wrote:

scimonster wrote:

EDIT: Is it worth it to have arctangent become atan, natural log become ln, and square root become √?

scimonster- I think that would just cloud the program.  I don't think the user would want to write out "square root" anyway.  It's really up to you, but I would say leave it to abbreviations.  Of course, we could include a key to all of the operations in the project notes, but that will come later.

amcerbu, you just made my life much easier in programming the setup engine. It should be done by tonight.  smile

Last edited by scimonster (2011-04-25 23:45:11)

Offline

 

#242 2011-04-26 00:06:58

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

Glad to hear it!  When you're done I'll get started on my job.

EDIT: I'm dealing with syntax errors, right?

Last edited by amcerbu (2011-04-26 00:09:04)

Offline

 

#243 2011-04-26 00:08:57

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

Time to remove all those redundant parts!

EDIT: Does (x%y) = ((x) mod (y))?

Last edited by scimonster (2011-04-26 00:10:33)

Offline

 

#244 2011-04-26 00:13:38

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

scimonster wrote:

Time to remove all those redundant parts!

EDIT: Does (x%y) = ((x) mod (y))?

Yeah, it might not need to be included though.  It's used for modulo in Python.  By the way, are the multi-argument operations I suggested earlier working out alright?

Offline

 

#245 2011-04-26 00:23:55

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

amcerbu wrote:

scimonster wrote:

Time to remove all those redundant parts!

EDIT: Does (x%y) = ((x) mod (y))?

Yeah, it might not need to be included though.  It's used for modulo in Python.  By the way, are the multi-argument operations I suggested earlier working out alright?

I'll put it in anyways.
Where?

Everything from the () of () block is in; time to add the constants!

Last edited by scimonster (2011-04-26 00:27:09)

Offline

 

#246 2011-04-26 00:28:43

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

What is "pie"?  tongue
"pi*e" or an error?

Offline

 

#247 2011-04-26 00:29:57

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

scimonster wrote:

What is "pie"?  tongue
"pi*e" or an error?

tongue  I don't know... I guess (pi)(e).  That'll have to be a little bonus, the apple crisp constant: 8.53973422.  Remember it well.

Last edited by amcerbu (2011-04-26 00:30:40)

Offline

 

#248 2011-04-26 00:36:14

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

Here's the list from before.  By multi-argument operations, I meant mod(x,y), rand(x,y), round(x,y).  I was just wondering whether those were working alright. 

EDIT: It may be that we don't want to include that, so modulo will just be x%y, round will only take one argument instead of 2.  I'm not sure how we'll handle rand though. 

Constants:
pi
phi
e

Operations- note that commas cannot be removed from multi-argument expressions. 
+, -, *, /,^
sqrt(x)
abs(x) (or |x|)
mod(x,y) or x%y- (in order of operations, comes before anything else.)
log(x,y)- y is base.
ln(x) (we may not need this if we have log(x) and constant e).
rand(x,y)- x and y are minimum, maximum respectively.
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), possibly include sinh(x), cosh(x), tanh(x)?
round(x,y)- y is the power of 10 we round to.

Last edited by amcerbu (2011-04-26 00:51:50)

Offline

 

#249 2011-04-26 00:51:57

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Calling all math lovers and good programmers

amcerbu wrote:

scimonster wrote:

What is "pie"?  tongue
"pi*e" or an error?

tongue  I don't know... I guess (pi)(e).  That'll have to be a little bonus, the apple crisp constant: 8.53973422.  Remember it well.

LOL.  lol

Wikipedia isn't telling me the value of phi.  hmm

Why not "x mod y"?

Oh, I'll have to do "round (x) to (y)"

Offline

 

#250 2011-04-26 00:54:18

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Calling all math lovers and good programmers

scimonster wrote:

amcerbu wrote:

scimonster wrote:

What is "pie"?  tongue
"pi*e" or an error?

tongue  I don't know... I guess (pi)(e).  That'll have to be a little bonus, the apple crisp constant: 8.53973422.  Remember it well.

LOL.  lol

Wikipedia isn't telling me the value of phi.  hmm

Why not "x mod y"?

Oh, I'll have to do "round (x) to (y)"

Phi is approx. 1.618... Also written as (1+sqrt 5)/2

I think x mod y might allow for some ambiguity, just like sqrt x+y.  What would we do about 5 mod 2+3?  Also, the operation would require spaces...  Maybe we should only permit x%y.

Last edited by amcerbu (2011-04-26 00:58:10)

Offline

 

Board footer