[sage-edu] Can you make @interact have a variable # of input boxes...

2009-01-22 Thread Jonathan Gutow

I'm probably being dense hereBut would appreciate any suggestions/ 
help.  What I want to do is ask students to interactively input a  
variable number of expressions based on some randomly generated  
'story' problems (actually chemical kinetic mechanisms).  I can  
generate the problems and check them, but cannot figure out how to  
make the @interact construct accept a variable number of  
input_boxes.  Is it possible, and, if so, how?

thanks,
Jonathan

  Dr. Jonathan H. Gutow
Chemistry Department gu...@uwosh.edu
UW-Oshkosh   Office:920-424-1326
800 Algoma Boulevard FAX:920-424-2042
Oshkosh, WI 54901
  http://www.uwosh.edu/faculty_staff/gutow/





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Can you make @interact have a variable # of input boxes...

2009-01-22 Thread Harald Schilly

On Jan 22, 3:39 pm, Jonathan Gutow  wrote:
> I'm probably being dense hereBut would appreciate any suggestions/
> help.  What I want to do is ask students to interactively input a
> variable number of expressions based on some randomly generated
> 'story' problems (actually chemical kinetic mechanisms).  I can
> generate the problems and check them, but cannot figure out how to
> make the @interact construct accept a variable number of
> input_boxes.  Is it possible, and, if so, how?

Hi, just a quick idea, what about using just one box and split the
string into individual tokens?
i.e. ' 1  2   3  '.split() returns ['1', '2', '3']

H
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Can you make @interact have a variable # of input boxes...

2009-01-22 Thread Luiz Felipe Martins

This worked for me, but it is definitely hackish and cumbersome. You
basically define the function in a string, exec the string to create
the function, and then use the function interact, instead using the
decoration @interact. (I've read it is frowned up, but...)

# first cell
fields = ['a','b','c','d','e']
init_values = [10,15,31,14,-5, 6]
fields_def = ','.join(['%s=%d' % t for t in zip(fields,init_values)])
fdef= 'def _(' + fields_def + '):\n' \
+ '\tprint sum([' + ','.join(fields) + '])\n'
print fdef   # just to check

# second cell
exec(fdef)
interact(_)

On Thu, Jan 22, 2009 at 9:39 AM, Jonathan Gutow  wrote:
>
> I'm probably being dense hereBut would appreciate any suggestions/
> help.  What I want to do is ask students to interactively input a
> variable number of expressions based on some randomly generated
> 'story' problems (actually chemical kinetic mechanisms).  I can
> generate the problems and check them, but cannot figure out how to
> make the @interact construct accept a variable number of
> input_boxes.  Is it possible, and, if so, how?
>
> thanks,
> Jonathan
>
>  Dr. Jonathan H. Gutow
> Chemistry Department gu...@uwosh.edu
> UW-Oshkosh   Office:920-424-1326
> 800 Algoma Boulevard FAX:920-424-2042
> Oshkosh, WI 54901
>  http://www.uwosh.edu/faculty_staff/gutow/
>
>
>
>
>
> >
>



-- 
"The main things which seem to me important on their own account, and
not merely as means to other things, are knowledge, art, instinctive
happiness, and relations of friendship or affection."
   -Bertrand Russell

L. Felipe Martins
Department of Mathematics
Cleveland State University
luizfelipe.mart...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Can you make @interact have a variable # of input boxes...

2009-01-22 Thread Jonathan

Thanks,  this looks like it might do what I want.  I have some
questions for below on exactly what you are doing.

On Jan 22, 10:30 am, Luiz Felipe Martins
 wrote:
> This worked for me, but it is definitely hackish and cumbersome. You
> basically define the function in a string, exec the string to create
> the function, and then use the function interact, instead using the
> decoration @interact. (I've read it is frowned up, but...)
>
> # first cell
> fields = ['a','b','c','d','e']
> init_values = [10,15,31,14,-5, 6]
> fields_def = ','.join(['%s=%d' % t for t in zip(fields,init_values)])
What is the zip(...) doing?  Does this change the type of the values
or is it a sneaky way of
indexing both values at once?
> fdef= 'def _(' + fields_def + '):\n' \
>     + '\tprint sum([' + ','.join(fields) + '])\n'
> print fdef   # just to check
>
> # second cell
> exec(fdef)
> interact(_)
>
>
>
> On Thu, Jan 22, 2009 at 9:39 AM, Jonathan Gutow  wrote:
>
> > I'm probably being dense hereBut would appreciate any suggestions/
> > help.  What I want to do is ask students to interactively input a
> > variable number of expressions based on some randomly generated
> > 'story' problems (actually chemical kinetic mechanisms).  I can
> > generate the problems and check them, but cannot figure out how to
> > make the @interact construct accept a variable number of
> > input_boxes.  Is it possible, and, if so, how?
>
> > thanks,
> > Jonathan
>
> >                          Dr. Jonathan H. Gutow
> > Chemistry Department                                 gu...@uwosh.edu
> > UW-Oshkosh                                           Office:920-424-1326
> > 800 Algoma Boulevard                                 FAX:920-424-2042
> > Oshkosh, WI 54901
> >                  http://www.uwosh.edu/faculty_staff/gutow/
>
> --
> "The main things which seem to me important on their own account, and
> not merely as means to other things, are knowledge, art, instinctive
> happiness, and relations of friendship or affection."
>    -Bertrand Russell
>
> L. Felipe Martins
> Department of Mathematics
> Cleveland State University
> luizfelipe.mart...@gmail.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Can you make @interact have a variable # of input boxes...

2009-01-22 Thread jason-sage

Jonathan wrote:
> Thanks,  this looks like it might do what I want.  I have some
> questions for below on exactly what you are doing.
>
> On Jan 22, 10:30 am, Luiz Felipe Martins
>  wrote:
>   
>> This worked for me, but it is definitely hackish and cumbersome. You
>> basically define the function in a string, exec the string to create
>> the function, and then use the function interact, instead using the
>> decoration @interact. (I've read it is frowned up, but...)
>>
>> # first cell
>> fields = ['a','b','c','d','e']
>> init_values = [10,15,31,14,-5, 6]
>> fields_def = ','.join(['%s=%d' % t for t in zip(fields,init_values)])
>> 
> What is the zip(...) doing?  Does this change the type of the values
> or is it a sneaky way of
> indexing both values at once?
>   

zip is just a way of combining two lists, element-wise:

sage: zip([1,2,3],[4,5,6])
[(1, 4), (2, 5), (3, 6)]
sage: zip?
Type:builtin_function_or_method
Base Class:
String Form:
Namespace:Python builtin
Docstring:
zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]
   
Return a list of tuples, where each tuple contains the i-th element
from each of the argument sequences.  The returned list is truncated
in length to the length of the shortest argument sequence.
Class Docstring:




Jason


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Can you make @interact have a variable # of input boxes...

2009-01-22 Thread Luiz Felipe Martins

On Thu, Jan 22, 2009 at 11:47 AM, Jonathan  wrote:
>
> Thanks,  this looks like it might do what I want.  I have some
> questions for below on exactly what you are doing.
>
> On Jan 22, 10:30 am, Luiz Felipe Martins
>  wrote:
>> This worked for me, but it is definitely hackish and cumbersome. You
>> basically define the function in a string, exec the string to create
>> the function, and then use the function interact, instead using the
>> decoration @interact. (I've read it is frowned up, but...)
>>
>> # first cell
>> fields = ['a','b','c','d','e']
>> init_values = [10,15,31,14,-5, 6]
>> fields_def = ','.join(['%s=%d' % t for t in zip(fields,init_values)])
> What is the zip(...) doing?  Does this change the type of the values
> or is it a sneaky way of
> indexing both values at once?

The zip simply makes a list of pairs of the field names and initial values:
[('a',10), ('b',15),('c',31),...]
and then the pairs are passed to the formatting string.

A better solution might be to use a dictionary:
 dfields = dict(a=10,b=15,c=31,d=14,e=-5)

I think it would even be possible to write a function with a signature like:

create_function(name, body='pass', **kwargs)

That would generate the string that has to be exec'ed, and the field
definitions would go in the dictionary kwargs.

One thing I thought is that if you have several interactions in the
same worksheet, you probably cannot use the same function name `_' for
all of them, since the functions are created in the global namespace.

>> fdef= 'def _(' + fields_def + '):\n' \
>> + '\tprint sum([' + ','.join(fields) + '])\n'
>> print fdef   # just to check
>>
>> # second cell
>> exec(fdef)
>> interact(_)
>>
>>
>>
>> On Thu, Jan 22, 2009 at 9:39 AM, Jonathan Gutow  wrote:
>>
>> > I'm probably being dense hereBut would appreciate any suggestions/
>> > help.  What I want to do is ask students to interactively input a
>> > variable number of expressions based on some randomly generated
>> > 'story' problems (actually chemical kinetic mechanisms).  I can
>> > generate the problems and check them, but cannot figure out how to
>> > make the @interact construct accept a variable number of
>> > input_boxes.  Is it possible, and, if so, how?
>>
>> > thanks,
>> > Jonathan
>>
>> >  Dr. Jonathan H. Gutow
>> > Chemistry Department gu...@uwosh.edu
>> > UW-Oshkosh   Office:920-424-1326
>> > 800 Algoma Boulevard FAX:920-424-2042
>> > Oshkosh, WI 54901
>> >  http://www.uwosh.edu/faculty_staff/gutow/
>>
>> --
>> "The main things which seem to me important on their own account, and
>> not merely as means to other things, are knowledge, art, instinctive
>> happiness, and relations of friendship or affection."
>>-Bertrand Russell
>>
>> L. Felipe Martins
>> Department of Mathematics
>> Cleveland State University
>> luizfelipe.mart...@gmail.com
> >
>



-- 
"The main things which seem to me important on their own account, and
not merely as means to other things, are knowledge, art, instinctive
happiness, and relations of friendship or affection."
   -Bertrand Russell

L. Felipe Martins
Department of Mathematics
Cleveland State University
luizfelipe.mart...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Can you make @interact have a variable # of input boxes...

2009-01-22 Thread kcrisman

Just passing this thread on to sage-support, since it more properly
belongs there and some people there but not here might have
comments.

Also, is there any conceivable way that this sort of overloading could
somehow automatically make it into the definition of how interact
works, maybe via a keyword "function" or "create_function" or
something like that?  This is probably hopelessly naive, especially
since "function" is probably what one wants to call one of the
variables going in a text box!  But oh well.

- kcrisman

> >> On Thu, Jan 22, 2009 at 9:39 AM, Jonathan Gutow  wrote:
>
> >> > I'm probably being dense hereBut would appreciate any suggestions/
> >> > help.  What I want to do is ask students to interactively input a
> >> > variable number of expressions based on some randomly generated
> >> > 'story' problems (actually chemical kinetic mechanisms).  I can
> >> > generate the problems and check them, but cannot figure out how to
> >> > make the @interact construct accept a variable number of
> >> > input_boxes.  Is it possible, and, if so, how?
>
> >> > thanks,
> >> > Jonathan

Luiz said:

This worked for me, but it is definitely hackish and cumbersome. You
basically define the function in a string, exec the string to create
the function, and then use the function interact, instead using the
decoration @interact. (I've read it is frowned up, but...)
# first cell
fields = ['a','b','c','d','e']
init_values = [10,15,31,14,-5, 6]
fields_def = ','.join(['%s=%d' % t for t in zip(fields,init_values)])
fdef= 'def _(' + fields_def + '):\n' \
+ '\tprint sum([' + ','.join(fields) + '])\n'
print fdef   # just to check
# second cell
exec(fdef)
interact(_)

> A better solution might be to use a dictionary:
>  dfields = dict(a=10,b=15,c=31,d=14,e=-5)
>
> I think it would even be possible to write a function with a signature like:
>
> create_function(name, body='pass', **kwargs)
>
> That would generate the string that has to be exec'ed, and the field
> definitions would go in the dictionary kwargs.
>
> One thing I thought is that if you have several interactions in the
> same worksheet, you probably cannot use the same function name `_' for
> all of them, since the functions are created in the global namespace.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Where books on how teach calculus/math with computer math software?

2009-01-22 Thread seber...@spawar.navy.mil

Anyone know of any place that has collected lots of wisdom on how to
effectively teach math classes with math software?

I teach calculus with Sage.  If there are any books on how to do this
better I'd love to hear about it.

Chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Where books on how teach calculus/math with computer math soft...

2009-01-22 Thread CalcPage
 
 
In a message dated 1/22/2009 2:46:30 P.M. Eastern Standard Time,  
seber...@spawar.navy.mil writes:

I teach  calculus with Sage.  If there are any books on how to do this
better  I'd love to hear about it.



Have you looked on _www.sagemath.org_ (http://www.sagemath.org)   under help 
or books or publications?  There's a number of free online texts  in pdf 
format including:
 
Calc 1 (differential calculus)
Calc 2 (integral calculus)
DiffEqus
Linear Alg
 
I'd love something on Statistics and Vector Calc though.  There is a  book on 
R and undergraduate stats on another site I can't remember right  now
 
BTW, if anyone has any other sources, I'd love to hear about them  too!  I'm 
implementing a lab component for my AP Calculus BC class that  will include 
Sage.
 
HTH,
A.  Jorge Garcia
calcp...@aol.com
http://calcpage.tripod.com

Teacher  & Professor
Applied Mathematics, Physics & Computer  Science
Baldwin Senior High School & Nassau Community College



**A Good Credit Score is 700 or Above. See yours in just 2 easy 
steps! 
(http://pr.atwola.com/promoclk/10075x1215855013x1201028747/aol?redir=http://www.freecreditreport.com/pm/default.aspx?sc=668072%26hmpgID=62%26bcd=De
cemailfooterNO62)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Where books on how teach calculus/math with computer math soft...

2009-01-22 Thread David Joyner

On Thu, Jan 22, 2009 at 5:10 PM,   wrote:
> In a message dated 1/22/2009 2:46:30 P.M. Eastern Standard Time,
> seber...@spawar.navy.mil writes:
>
> I teach calculus with Sage.  If there are any books on how to do this
> better I'd love to hear about it.
>
> Have you looked on www.sagemath.org under help or books or publications?
> There's a number of free online texts in pdf format including:
>
> Calc 1 (differential calculus)
> Calc 2 (integral calculus)
> DiffEqus
> Linear Alg
>
> I'd love something on Statistics and Vector Calc though.  There is a book on
> R and undergraduate stats on another site I can't remember right now
>
> BTW, if anyone has any other sources, I'd love to hear about them too!  I'm
> implementing a lab component for my AP Calculus BC class that will include
> Sage.


I've been collecting some worksheets here
http://sage.math.washington.edu/home/wdj/teaching/worksheets/
If you want yours added, just email them to me.


>
> HTH,
> A. Jorge Garcia
> calcp...@aol.com
> http://calcpage.tripod.com
>
> Teacher & Professor
> Applied Mathematics, Physics & Computer Science
> Baldwin Senior High School & Nassau Community College
>
>
> 
> A Good Credit Score is 700 or Above. See yours in just 2 easy steps!
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: Where books on how teach calculus/math with computer math software?

2009-01-22 Thread Harald Schilly

Here are two wiki pages
http://wiki.sagemath.org/Teaching_with_SAGE
http://wiki.sagemath.org/Teaching_using_SAGE

h

On Jan 22, 8:36 pm, "seber...@spawar.navy.mil"
 wrote:
> Anyone know of any place that has collected lots of wisdom on how to
> effectively teach math classes with math software?
>
> I teach calculus with Sage.  If there are any books on how to do this
> better I'd love to hear about it.
>
> Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: draft of "Ani invitation to Sage"

2009-01-22 Thread CalcPage
 
In a message dated 1/21/2009 9:57:27 P.M. Eastern Standard Time,  
wdjoy...@gmail.com writes:

I posted  a new version which I think takes all your comments into  account.
http://sage.math.washington.edu/home/wdj/teaching/calc1-sage/an-invitation-to-
sage.pdf
Thanks  again.


Great timing!  I'm demoing Sage in a couple of weeks to my prospective  
Calculus students!
 
I was going to develop some worksheets online with them in my computer lab  
showing how they could use Sage at different levels of High School  math:
arithmetic
algebra
trig
calculus
plus plot, plot3d and tachyon
 
But I could definitely use this document!
 
Thanx,
A. Jorge  Garcia
calcp...@aol.com
http://calcpage.tripod.com

Teacher &  Professor
Applied Mathematics, Physics & Computer Science
Baldwin  Senior High School & Nassau Community College



**A Good Credit Score is 700 or Above. See yours in just 2 easy 
steps! 
(http://pr.atwola.com/promoclk/10075x1215855013x1201028747/aol?redir=http://www.freecreditreport.com/pm/default.aspx?sc=668072%26hmpgID=62%26bcd=De
cemailfooterNO62)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---



[sage-edu] Re: draft of "Ani invitation to Sage"

2009-01-22 Thread CalcPage
Oh, and some python too!
 
HTH,
A.  Jorge Garcia
calcp...@aol.com
http://calcpage.tripod.com

Teacher  & Professor
Applied Mathematics, Physics & Computer  Science
Baldwin Senior High School & Nassau Community College



**A Good Credit Score is 700 or Above. See yours in just 2 easy 
steps! 
(http://pr.atwola.com/promoclk/10075x1215855013x1201028747/aol?redir=http://www.freecreditreport.com/pm/default.aspx?sc=668072%26hmpgID=62%26bcd=De
cemailfooterNO62)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~--~~~~--~~--~--~---