Ask Your Question
0

How to print equations and numbers on a single line:

asked 2017-01-04 20:17:37 +0100

lookin03820 gravatar image

updated 2017-01-04 21:43:14 +0100

I am trying to print a string, an equation and a number on the same line using the following form:

 B=var('B')
 fce=var('fce', latex_name='f_{ce}')
 fce=2.80e6 * B
 values={B:1.0e5}
 print "Electron Gyrofrequency=", show(fce) , "= %0.5e" % fce.substitute(values)

However the output does not show as a single line. Any help would be appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-01-04 22:11:49 +0100

Try this:

 show( "Electron Gyrofrequency=", fce , "= %0.5e" % fce.substitute(values) )
edit flag offensive delete link more

Comments

Didn't work stuff after "Electron Gyrofrequency=" was not displayed

lookin03820 gravatar imagelookin03820 ( 2017-01-04 23:09:43 +0100 )edit

It works for me. Which Sage interface are you using ?

tmonteil gravatar imagetmonteil ( 2017-01-05 03:11:28 +0100 )edit

sage 6.3 on a mac 10.7.5

lookin03820 gravatar imagelookin03820 ( 2017-01-05 15:42:01 +0100 )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

Stats

Asked: 2017-01-04 20:17:37 +0100

Seen: 616 times

Last updated: Jan 04 '17