Ask Your Question
0

Problem regarding user input in Sage manifolds

asked 2017-07-15 10:48:51 +0200

Shouvik gravatar image

updated 2017-07-15 13:31:25 +0200

vdelecroix gravatar image

I am unable to take input from user in case of sage manifold,i am working in differentiable manifold.Especially,I am having problem to take input from user in case of vector fields(differentiable manifold) Any help is appreciated

edit retag flag offensive close merge delete

Comments

1

In order to get help you need:

  1. to give details about your operating system and your Sage installation
  2. describe precisely your problem
  3. provide some code snippet
vdelecroix gravatar imagevdelecroix ( 2017-07-15 13:30:55 +0200 )edit

My operating system is windows and i am executing sage software 7.6 using sage manifold appliance (virtual box) My problem is t I am unable to take raw_input from user(just like python) for vector field on a 5 dimensional manifold. The code snippet is as follows M = Manifold(5, 'M') X.<a,b,c,d,e> = M.chart() v = M.vector_field(name='v') eU = X.frame() v[eU,:]=raw_input("enter a value") print v[0]

Shouvik gravatar imageShouvik ( 2017-07-15 17:09:41 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-07-15 18:07:48 +0200

dan_fulea gravatar image

Note that the raw input captures a string from the user - in my case from the sage interpreter:

sage: a = raw_input( "Please enter a number... >" )
Please enter a number... >7
sage: a
'7'

The code has to arrange that the input is parsed correctly. For the posted case an evaluation would be enough, if the user raw input is prepared to be evaluated. Note for this the example:

sage: eval( '17, 5, 22, 196544, -1' )
(17, 5, 22, 196544, -1)
sage: type( _ )
<type 'tuple'>

Slightly changed code:

M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]

Let's see it it works, code was copy-pasted into the sage interpreter via %cpaste:

sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]
:::::::
:--
enter five numbers (comma separated) > 17, 5, 22, 196544, -1
eU = Coordinate frame (M, (d/da,d/db,d/dc,d/dd,d/de))
v[ eU, : ] = [17, 5, 22, 196544, -1]
sage:
edit flag offensive delete link more

Comments

thank you,its working

Shouvik gravatar imageShouvik ( 2017-07-15 18:48:12 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-07-15 10:48:51 +0200

Seen: 290 times

Last updated: Jul 15 '17