Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix some octave optional doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed May 1, 2018
1 parent f46abe6 commit 31a5f1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
14 changes: 4 additions & 10 deletions src/doc/en/constructions/linear_algebra.rst
Expand Up @@ -429,33 +429,27 @@ You can even nicely typeset the solution in LaTeX:
To have the above appear onscreen via xdvi, type ``view(s)``.

You can also solve linear equations symbolically using the
``solve`` command:

::
``solve`` command::

sage: var('x,y,z,a')
(x, y, z, a)
sage: eqns = [x + z == y, 2*a*x - y == 2*a^2, y - 2*z == 2]
sage: solve(eqns, x, y, z)
[[x == a + 1, y == 2*a, z == a - 1]]

Here is a numerical Numpy example:

::
Here is a numerical Numpy example::

sage: from numpy import arange, eye, linalg
sage: A = eye(10) ## the 10x10 identity matrix
sage: b = arange(1,11)
sage: x = linalg.solve(A,b)

Another way to solve a system numerically is to use Sage's octave
interface:

::
interface::

sage: M33 = MatrixSpace(QQ,3,3)
sage: A = M33([1,2,3,4,5,6,7,8,0])
sage: V3 = VectorSpace(QQ,3)
sage: b = V3([1,2,3])
sage: octave.solve_linear_system(A,b) # optional - octave
[-0.33333299999999999, 0.66666700000000001, 0]
[-0.333333, 0.666667, 0]
13 changes: 8 additions & 5 deletions src/doc/en/developer/coding_in_other.rst
Expand Up @@ -691,19 +691,22 @@ dumps the user into an Octave interactive shell::
Use octave to compute a solution x to A*x = b, as a list.

INPUT:
A -- mxn matrix A with entries in QQ or RR
b -- m-vector b entries in QQ or RR (resp)
- A -- mxn matrix A with entries in QQ or RR
- b -- m-vector b entries in QQ or RR (resp)

OUTPUT:
An list x (if it exists) which solves M*x = b

EXAMPLES:
An list x (if it exists) which solves M*x = b

EXAMPLES::

sage: M33 = MatrixSpace(QQ,3,3)
sage: A = M33([1,2,3,4,5,6,7,8,0])
sage: V3 = VectorSpace(QQ,3)
sage: b = V3([1,2,3])
sage: octave.solve_linear_system(A,b) # optional - octave
[-0.33333299999999999, 0.66666700000000001, -3.5236600000000002e-18]
[-0.333333, 0.666667, 0]

AUTHOR: David Joyner and William Stein
"""
Expand Down

0 comments on commit 31a5f1d

Please sign in to comment.