Ask Your Question

dom's profile - activity

2018-06-25 04:43:14 -0500 received badge  Necromancer (source)
2017-07-14 02:28:07 -0500 answered a question reference request

Answer to one of the questions : try the 3D plotting.

I don't clearly understand the other questions : "geometric interpretation of linear algebra ?" ... it looks like a math question (not related sagemath). Geometry and linear algebra are both parts of "mathematics. They are linked sometimes but not always. For example, if you use polar coordinates instead of cartesian coordinates, you have no more "linear" algebra.

Your words are inaccurate shortcuts : there is no "difference" between to planes. There are geometric objects which doesn't exist in real life : a line has no width, a Moebius strip has only one "face"... But OK, you mean "intersection" of two sets, the intersection of two sets of points elements in the 3D space (the "geometric interpretation", in fact a bijective map, of R^3 the set of real triples).

If you want to work in cartesian coordinates (R^3 for the real world space) then yes, you have to code using symbolics functions. For example : var('x,y,z"); f1(x,y,z) = x + y + z ; f2(x,y,z) = x + y -2*z ; res = solve([f1 == 0,f2 == 0],x,y,z). The solve() function returns values for x,y,z and here, because intersection of two planes is usually a line (could be a plane or an empty set of points too), you will get a parametrized answer.

"why are ... have ..." : two verbs in one sentence. In geometry, there are "axioms" which are sentences you cannot prove. So no answer for that "why" question or the philosophical : "faith" is not "truth". One of geometry axioms is Euclid's : two parallel lines have no intersection.

"Invertible matrixes have solutions" : not at all, it's a crazy verbal mix (read again what you type). Mix of: "solutions set of a system of equations" (for example the empty set of (x,y,z) triples if your two planes are parallel) and "a matrix is invertible or not".

2017-06-20 15:23:53 -0500 answered a question Can I define a symbolic equation where the variables are concatenating?

Defining the equation is easy :

x = var('x',domain='integer') res =solve([x^2 ==1,2^9+2^8+2^7+2^6+2^5+x+2^3+2^2+2^1+2^0 == 2*x+2],x) print "res = ",res # no solution

but like Dan Fuela pointed out, your equation has no solution when x in F2 + you should accept the fact that you mix up many things "the concatening operator" (no meaning in maths), F2 is for you exactly the same than the set of the two integers {0,1} and so on.

2017-06-02 17:27:22 -0500 received badge  Teacher (source)
2017-06-02 16:27:45 -0500 answered a question Export Answer To Text File

Make a dom.sage file containing :

s = str(2^1000)
f = open('filename.txt', 'w')

Then run using sage :

sage dom.sage

and you get a file 'filename.txt' which contains :


on a Linux operating system (with sage locally installed).

For a Windows operating system (I guess from "C: syntax") I don't know.

2017-06-02 16:27:45 -0500 answered a question Periodic function

For mapping one real interval to another interval, you have the numpy function interp() (linear approximation).

Example :

import numpy as np
from numpy import interp
prec = 200
xp = np.linspace(0.0, 99.0, prec)
yp = np.linspace(-1.0, 1.0, prec)
print interp([52.0],xp,yp)

The printed value is near 0.0 (middle of interval [-1,1]) because 52.0 is near 50.0 (middle of interval [0,99])

2017-06-02 16:27:45 -0500 answered a question How can I display a plot from a script?

I suppose you have a local Linux (Ubuntu) operating system installed on your desktop/laptop (eg : you don't use a SMC terminal).

fill your test.sage with these lines :

g = plot(x^2, (x,-2,2)) 
os.system('display /tmp/dom.png')

then execute (if 'sage' command is in PATH):

sage test.sage

A window opens (because you have a X server running in your Linux OS) displaying the PNG file.

You need to have 'imagemagick' installed un order to use display command (last line of the script) .. eg sudo apt-get install imagemagick

2017-06-02 16:27:45 -0500 answered a question Efficient algorithms for simplification

I use factor()

2013-08-09 21:25:04 -0500 answered a question Solving polynomial equations over p-adic fields

Hi all, I found very curious not to find any example of Hensel's lifting in p-adics on various SAGE pages (maybe because I am too much newbie in maths,Sage,ask,.. ??). I had same experience than others about the "solve()" : discovering than it's not an all purpose solver... Here is my example for Hensel lifting in p-adics. One hidden difficulty was about 'Symbolic Expression' : very difficult to cast one integer p-adic to constant Expression :-)...explaining why code has various "I want to stay inside Integer scope!" parts.

# Sample for 7-adics: search quadratic root of 2

# We define ring of p-adics here...but only for printing end result
# because Hensel lemma algorithm is NOT Taylor tangent approximation algorithm

w = Integer(7) ; q = 5 ; R = Zp(w,q) ; print 'Working in ring ',R

# Define function, symbolic expression over integer
f(x) = x^2 - 2 ; print 'f : ',f

# Compute derivate functions
F0 = f.diff(0) ; F1 = f.diff(1)

# Set one integer local solution of f(x) = 0 
r0 = Integer(3) ; f0r0 = F0(x=r0) ; f1r0 = F1(x=r0)
print 'Is ',r0,' one local solution ? ', (Mod(f0r0,w) == 0) and (Mod(f1r0,w) != 0)

# Get one new local solution from older one at each step of loop
rk = r0 ; wk = Integer(1)
for k in range(q-1):  
    print ; print '********** Step ',k,'***********' ; print

    # Compute k-th power of w
    wk = w * wk

    # Compute value of F0 and F1 for rk
    f0rk = Integer(F0(x=rk)) ; print 'F0(rk) = ', f0rk 
    f1rk = Integer(F1(x=rk)) ; print 'F1(rk) = ', f1rk 

    # Most important part: 
    #  - f0rk / wk is "Integer" division, removing the w^k factor
    #  - negative (-), multiply and inverse_mod operation in ring R
    t = Integer(f0rk / wk) * inverse_mod(-f1rk,w) ; print t
    rk = rk + Integer(t*wk) ; print rk

# Print result
print ; print  'Result in ring R,  f(',R(rk),') = ',R(f(rk))