Ask Your Question

richtopia's profile - activity

2014-07-17 13:49:34 +0200 received badge  Famous Question (source)
2013-10-07 08:31:03 +0200 received badge  Notable Question (source)
2013-05-24 19:19:36 +0200 received badge  Famous Question (source)
2013-03-04 08:14:43 +0200 received badge  Popular Question (source)
2012-12-28 00:46:34 +0200 received badge  Notable Question (source)
2012-09-17 15:52:14 +0200 received badge  Popular Question (source)
2012-03-28 10:51:22 +0200 marked best answer Display variable value
A=10
print 'A =',A
2012-03-27 21:25:40 +0200 asked a question Display variable value

I would like to rapidly report stored values along with the variable name. In python I can do print('A=' + A) for this, which does not seem to work in Sage. Is there a command with this function or a way to fix this print statement?

2012-01-25 19:34:28 +0200 marked best answer Decrease accuracy for floats (decrease decimal places reported)

Do you mean printing (instead of plotting) the matrices? (Not sure what it would mean to plot a matrix.) If you're just trying to get a floating point number to display with fewer digits, you might try something like

foo.n(digits = 3)

Unfortunately, this simple approach doesn't always give expressions of a uniform "width", in terms of the number of characters. For example:

print pi.n(digits = 3)
print (pi*100000).n(digits = 3)
print (pi*100000000).n(digits = 3)
print (pi/100000).n(digits = 3)
print (pi/100000000).n(digits = 3)

returns

3.14
314000.
3.14e8
0.0000314
3.14e-8
2012-01-25 19:34:27 +0200 received badge  Scholar (source)
2012-01-25 19:33:54 +0200 commented question Decrease accuracy for floats (decrease decimal places reported)

As an update, the quickest method of beautifying my matrices was taking jdc's advice. I'm plotting Markov Chains, which I should have mentioned earlier, however n.(digits) can be used even inside DiGraph. For example: DiGraph(My_Matrix.n(digits=3),format="weighted_adjacency_matrix")

2012-01-25 19:31:11 +0200 received badge  Supporter (source)
2012-01-25 14:34:56 +0200 received badge  Nice Question (source)
2012-01-25 13:42:41 +0200 received badge  Student (source)
2012-01-24 18:33:23 +0200 asked a question Decrease accuracy for floats (decrease decimal places reported)

When working with matrices of floats and plotting said matrices, the results become unreadable fast with the default accuracy. How do I only display a handful (3~4) of digits?