获取帮助

Sage拥有强大的内置文档,只需要输入函数或者常数的名字,再加个问号即可:

  1. sage: tan?
  2. Type: <class 'sage.calculus.calculus.Function_tan'>
  3. Definition: tan([noargspec])
  4. Docstring:
  5. The tangent function
  6. EXAMPLES:
  7. sage: tan(pi)
  8. 0
  9. sage: tan(3.1415)
  10. -0.0000926535900581913
  11. sage: tan(3.1415/4)
  12. 0.999953674278156
  13. sage: tan(pi/4)
  14. 1
  15. sage: tan(1/2)
  16. tan(1/2)
  17. sage: RR(tan(1/2))
  18. 0.546302489843790
  19. sage: log2?
  20. Type: <class 'sage.functions.constants.Log2'>
  21. Definition: log2([noargspec])
  22. Docstring:
  23. The natural logarithm of the real number 2.
  24. EXAMPLES:
  25. sage: log2
  26. log2
  27. sage: float(log2)
  28. 0.69314718055994529
  29. sage: RR(log2)
  30. 0.693147180559945
  31. sage: R = RealField(200); R
  32. Real Field with 200 bits of precision
  33. sage: R(log2)
  34. 0.69314718055994530941723212145817656807550013436025525412068
  35. sage: l = (1-log2)/(1+log2); l
  36. (1 - log(2))/(log(2) + 1)
  37. sage: R(l)
  38. 0.18123221829928249948761381864650311423330609774776013488056
  39. sage: maxima(log2)
  40. log(2)
  41. sage: maxima(log2).float()
  42. .6931471805599453
  43. sage: gp(log2)
  44. 0.6931471805599453094172321215 # 32-bit
  45. 0.69314718055994530941723212145817656807 # 64-bit
  46. sage: sudoku?
  47. File: sage/local/lib/python2.5/site-packages/sage/games/sudoku.py
  48. Type: <... 'function'>
  49. Definition: sudoku(A)
  50. Docstring:
  51. Solve the 9x9 Sudoku puzzle defined by the matrix A.
  52. EXAMPLE:
  53. sage: A = matrix(ZZ,9,[5,0,0, 0,8,0, 0,4,9, 0,0,0, 5,0,0,
  54. 0,3,0, 0,6,7, 3,0,0, 0,0,1, 1,5,0, 0,0,0, 0,0,0, 0,0,0, 2,0,8, 0,0,0,
  55. 0,0,0, 0,0,0, 0,1,8, 7,0,0, 0,0,4, 1,5,0, 0,3,0, 0,0,2,
  56. 0,0,0, 4,9,0, 0,5,0, 0,0,3])
  57. sage: A
  58. [5 0 0 0 8 0 0 4 9]
  59. [0 0 0 5 0 0 0 3 0]
  60. [0 6 7 3 0 0 0 0 1]
  61. [1 5 0 0 0 0 0 0 0]
  62. [0 0 0 2 0 8 0 0 0]
  63. [0 0 0 0 0 0 0 1 8]
  64. [7 0 0 0 0 4 1 5 0]
  65. [0 3 0 0 0 2 0 0 0]
  66. [4 9 0 0 5 0 0 0 3]
  67. sage: sudoku(A)
  68. [5 1 3 6 8 7 2 4 9]
  69. [8 4 9 5 2 1 6 3 7]
  70. [2 6 7 3 4 9 5 8 1]
  71. [1 5 8 4 6 3 9 7 2]
  72. [9 7 4 2 1 8 3 6 5]
  73. [3 2 6 7 9 5 4 1 8]
  74. [7 8 2 9 3 4 1 5 6]
  75. [6 3 5 1 7 2 8 9 4]
  76. [4 9 1 8 5 6 7 2 3]

Sage还提供了”Tab补全”功能:输入函数名的前面几个字母,然后按tab键。比如,如果你输入ta再按TAB,Sage就会列出tachyon, tan, tanh, taylor. 这是一个查找Sage函数或者其他结构的好方法。