ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 27 Apr 2020 18:59:50 +0200RuntimeError Groebner basis for a Boolean systemhttps://ask.sagemath.org/question/51072/runtimeerror-groebner-basis-for-a-boolean-system/ Hello everyone,
i've started using sage for a few days and i'm having a rough time trying to use groebner basis with big boolean systems. Right now my goal is to verify the time it takes to solve these systems in this way: keep in mind that these equation are extracted from a cipher, and they are roughly 150 for 130 variables.
var = "x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x40, x41, x42, x43, x44, x45, x46, x47, x49, x54, x70, x81, x89, x92, x93, y01, y02, y03, y04, y05, y06, y07, y08, y09, y10, y11, y12, y13, y14, y15, y16, y17, y18, y19, y20, y21, y22, y23, y24, y25, y26, y27, y28, y29, y30, y31, y32, y33, y34, y35, y36, y37, y38, y39, y40, y41, y42, y43, y44, y45, y46, y47, y48, y49, y50, y52, y80, y83, y84"
B = BooleanPolynomialRing(var)
System = [B('x93 + y84'), B('x92 +y83'), B('x89 + y80'), B('x54 + x81'), B('x49 + y52')]
I = ideal(System)
G = I.groebner_basis()
The thing is that when i try to call the method 'variety' on the ideal 'I', i get a runtime error (even with this reduced example):
RuntimeError: error in Singular function call 'groebner':
int overflow in hilb 1
error occurred in or before standard.lib::stdhilb line 299: ` intvec hi = hilb( Id(1),1,W );`
expected intvec-expression. type 'help intvec;'
leaving standard.lib::stdhilb
leaving standard.lib::groebner
Do you have any idea why this happens? Or if you have any suggestions with the approach i could take, i'm happy to listen to them.
Thank you in advance for your time.torresMon, 27 Apr 2020 18:59:50 +0200https://ask.sagemath.org/question/51072/Algebra of functions f:Z_3 -> Rhttps://ask.sagemath.org/question/45402/algebra-of-functions-fz_3-r/ I want to create an implementation of an algebra of functions with domain {0,1,2} and range in R. The sum and the product is the usual pointwise sum and product. I have the idea of represent it as a 3 dimensional vectors with the usual sum of vectors, bot I need implement a new product.
The implementation of this algebra will be used for create a polynomial system of equations that I need to solve, so the implementation should be compatible with the procedure indicated in the entry titled *Find algebraic solutions to system of polynomial equations*
If someone have any idea please help me.
Thanks in advance.JulioNAQSat, 09 Feb 2019 22:01:49 +0100https://ask.sagemath.org/question/45402/Use system-wide installation of graphviz in sage?https://ask.sagemath.org/question/37188/use-system-wide-installation-of-graphviz-in-sage/ I am trying to install pygraphviz in sage 7.3 on a Debian jessy machine, but it already fails at:
`sage -i graphviz`
================================ WARNING =================================
You are about to download and install an unmaintained experimental
package. This probably won't work at all for you! There is no guarantee
that it will build correctly, or behave as expected. Use at your own risk!
This package will be removed in future versions of SageMath. If you care
about this package, you should make a proper new-style package instead.
For more information about making Sage packages, see
http://doc.sagemath.org/html/en/developer/packaging.html
==========================================================================
I don't want to break sage, so I am wondering if there is a way to make sage use the system-wide installation of pygraphviz instead.
stanThu, 06 Apr 2017 10:13:45 +0200https://ask.sagemath.org/question/37188/problem solving equation systemshttps://ask.sagemath.org/question/36786/problem-solving-equation-systems/ var('V1', 'V2')
solve([V1+V2==0.5,7.20 == 5.5 - log(V1/V2,10)], V1, V2)
SageMath do not solve this system but when with Ctrl+C the calculation end and show in terminal the solution.
If I use natural logarithm in the expression Sage solve this system without any problem.eancedegThu, 02 Mar 2017 16:33:42 +0100https://ask.sagemath.org/question/36786/How to Plot/Graph/Show a system of linear equationshttps://ask.sagemath.org/question/36780/how-to-plotgraphshow-a-system-of-linear-equations/Disclaimer: I'm new to Sage Math and Linear equations.
Background: Google will plot/graph this search: "plot 3x+4y"
Questions:
1. In Sage Math, how can I show similar output as Google?
2. Is there a better way, in 2D or 3D, to plot the following? 3x+4y=2.5 AND 5x-4y=25.5 ?
x, y = var('x,y')
a=3*x+4*y==2.5
b=5*x-4*y==25.5
p1=implicit_plot(a, (x,-2,5), (y,-4,4), axes="true", aspect_ratio=1)
p2=implicit_plot(b, (x,-2,5), (y,-4,4), axes="true", aspect_ratio=1)
show(p1+p2)mellow-yellowWed, 01 Mar 2017 22:07:21 +0100https://ask.sagemath.org/question/36780/solve system of non-linear implicit equations numericallyhttps://ask.sagemath.org/question/10269/solve-system-of-non-linear-implicit-equations-numerically/I am attempting to solve for a solution of a system of two non-linear implicit equations using the following code:
x = var('x')
y = var('y')
P = [(-1,-5), (1,-5), (-5,0), (5,5)]
# Defining the function
d = sum([sqrt( (x-p[0])^2 + (y-p[1])^2 ) for p in P])
show(d)
# Differentiate with respect to x and y
eqx = d.diff(x)
eqy = d.diff(y)
# Plot both implicit curves
g1 = implicit_plot( eqx==0, (x,-10,10), (y,-10,10), color="blue" )
g2 = implicit_plot( eqy==0, (x,-10,10), (y,-10,10), color="red" )
show(g1 + g2) # note that you can clearly see an intersection of the two curves
# Solve for the solution
print("Solving...")
sol = solve([eqx==0, eqy==0], x, y) # this gets stuck or takes a long time
show(sol)
Everything runs, up to the point of the solve function, which continues to run for what appears to be indefinitely. The code show(g1 + g2) shows a graph that clearly shows there exists an intersection for both curves. I tried to use to_poly_solve=True without success. I do not mind an approximate solution, however I was unable to find a numeric solver for a system such as this (find_root afaik only works on one variable) that will work.
Does there exist a numeric solver which is capable of solving a system of this form? What other alternatives are there?
Thanks,
menturimenturi628Fri, 21 Jun 2013 18:06:50 +0200https://ask.sagemath.org/question/10269/Solve a simple system of non-linear equationshttps://ask.sagemath.org/question/8557/solve-a-simple-system-of-non-linear-equations/Maple can solve a system of equations such as $\sin x + y =0, \sin x - y =0$. However,
var('x y')
solve([sin(x) + y ==0, sin(x) - y==0], [x, y])
produces no useful answer.
Is there any other way to proceed?jllbThu, 15 Dec 2011 09:30:18 +0100https://ask.sagemath.org/question/8557/Numerical solution of a system of non linear equationshttps://ask.sagemath.org/question/8546/numerical-solution-of-a-system-of-non-linear-equations/Hi everybody! I would like to know whether there exists a simple way to solve in a numerical way a system of non linear equations (the system cannot be solved analytically).
In particular, the system (in the variables a,b) I'd like to solve is the following:
-2*(a*b/sqrt(-1/2*a^2 + b^2) - 2/(a^2*b^2))*(sqrt(-1/2*a^2 + b^2)*b - 1/(a*b^2)) - 16/(a^5*b^2)=0
4*b^3 + 4*(sqrt(-1/2*a^2 + b^2)*b - 1/(a*b^2))*(b^2/sqrt(-1/2*a^2 + b^2) + sqrt(-1/2*a^2 + b^2) + 2/(a*b^3)) - 8/(a^4*b^3)=0
Thanks in advanced,
FrancescoFrancescoMon, 12 Dec 2011 05:21:08 +0100https://ask.sagemath.org/question/8546/d²y/dt² (1-2α)dy/dt (α²-α e^(-2t))y = u find the impulse response of equationhttps://ask.sagemath.org/question/36316/d2ydt2-1-2adydt-a2-a-e-2ty-u-find-the-impulse-response-of-equation/ d²y/dt² (1-2α)dy/dt (α²-α e^(-2t))y = u find the impulse response of equation
HabertTue, 17 Jan 2017 03:14:02 +0100https://ask.sagemath.org/question/36316/solving systems of equations returns [] Reduxhttps://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/I searched the wiki and found the "solve always returns []" question. But it doesn't help me. I will admit that I am a complete neophyte with Sagemath and have been playing with version 7.2 on my windows machine.
I was trying to do something very simple: solve a basic Lagrange Multiplier problem, so I defined the following:
- var('x' ,'y' ,'z', 'lam')
- var('F')
- F = x*y*z - lam * (x*y*z-9)
- var('dFx', 'dFy', 'dFz', 'dFlam')
- dFx=diff(F,x)
- dFy=diff(F,y)
- dFz=diff(F,z)
- dFlam=diff(F,lam)
- solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)
but the **solve** returns []. It should return something like x==3, y==3, z==3, shouldn't it? Is there an alternative way to approach this?
Thanks.
BobM
BobMSat, 27 Aug 2016 10:28:29 +0200https://ask.sagemath.org/question/34608/Unable to create a contour_plot of a system of inequalitieshttps://ask.sagemath.org/question/34111/unable-to-create-a-contour_plot-of-a-system-of-inequalities/I am trying to plot a system of inequalities, dependent on a matrix H. Here is my function I am planning to contour_plot: <br>
def reg(x, y):
f1 = H[0,0] * H[0,0] * x + H[1,0] * H[1,0] * y
f2 = H[0,0] * H[0,1] * x + H[1,0] * H[1,1] * y
f3 = H[0,1] * H[0,1] * x + H[1,1] * H[1,1] * y
if f1 < 0 or f2 < 0 or f3 < 0:
return 0
else:
return 1
I then have H be
> H
> [2.220446049250313e-16 -0.9999999999999998]
> [ -0.9999999999999998 2.220446049250313e-16]
However
contour_plot(reg, (x,-Integer(5),Integer(5)), (y,-Integer(5),Integer(5)))
yields an error. It says
zero-size array to reduction operation minimum which has no identity
The strange part is that when
> H
> [-1 0]
> [ 0 1]
the same contour_plot yields exactly what I want without any errors <br>
Help would be much appreciated, I have just picked up SAGE this week and have much to learn
petkusSat, 16 Jul 2016 21:30:45 +0200https://ask.sagemath.org/question/34111/numerical computation of roots (maple equivalent of fsolve) of a system of nonlinear equations with multiple variables parametershttps://ask.sagemath.org/question/34002/numerical-computation-of-roots-maple-equivalent-of-fsolve-of-a-system-of-nonlinear-equations-with-multiple-variables-parameters/ Hi All, the following is my code:
### Begin Code#####
#Parameters:
k0 = 0.1
kd = 0.05
k1 = 20
j1 = 0.1
km1 = 0.2
jm1 = 0.1
k2 = 0.055
j2 = 0.1
pPTEN = 0.001
dPTEN = 0.0054
k3 = 0.006
j3 = 2
k4 = 0.15
j4 = 0.1
km4 = 73
jm4 = 0.5
pMdm2 = 0.018
dMdm2 = 0.015
dMdm2s = 0.015
k5 = 0.024
j5 = 1
k6 = 10
j6 = 0.3
km6 = 0.2
jm6 = 0.1
n1 = 3
n2 = 3
PIPtot = 1
AKTtot = 1
#Variables to solve
p53 = var('p53')
AKTs = var('AKTs')
Mdm2 = var('Mdm2')
Mdm2s = var('Mdm2s')
PIP3 = var('PIP3')
PTEN = var('PTEN')
AKT = AKTtot - AKTs
PIP2 = PIPtot - PIP3
#Rate Equations
v0 = k0
v1 = (k1 * PIP3 * AKT) / (j1 + AKT)
vm1 = (km1 * AKTs) / (jm1 + AKTs)
v2 = (k2 * Mdm2s * p53) / (j2 + p53)
v3 = (k3 * ((p53)^n1))/(((j3)^n1) + ((p53)^n1))
v4 = (k4 * PIP2)/(j4 + PIP2)
vm4 = (km4 * PTEN * PIP3)/(jm4 + PIP3)
v5 = (k5 * ((p53)^n2))/(((j5)^n2) + ((p53)^n2))
v6 = (k6 * Mdm2 * AKTs)/(j6 + Mdm2)
vm6 = (km6 * Mdm2s)/(jm6 + Mdm2s)
ss_p53 = v0 - v2 - kd*p53
ss_AKTs = v1 - vm1
ss_PIP3 = v4 - vm4
ss_PTEN = pPTEN + v3 - dPTEN * PTEN
ss_Mdm2s = v6 - vm6 - dMdm2s*Mdm2s
ss_Mdm2 = pMdm2 + v5 - v6 + vm6 - dMdm2*Mdm2
#Equation to Solve
z = solve([ss_p53==0, ss_AKTs==0, ss_PIP3==0, ss_PTEN==0, ss_Mdm2s==0, ss_Mdm2==0],\ [p53, AKTs, PIP3,PTEN, Mdm2s, Mdm2])
End Code
I tried using Sage "solve" to analytically solve the system of equations. I got a "FloatingPointError: Floating point exception"
I thought of ways to get round this exception by
1) using log and exp in my math equations -- I can't work round this
2) I have no idea how to create exceptions for this since I can't access the sub-solutions while the solutions are still underway
3)Then I tried maxima.solve --> no roots could be found
Maybe, this problem can't be solved analytically, so I thought maybe I could do so numerically.
Hence my following question,
I can only find functions that tackle univariate equations. Is there a sage equivalent of maple's f-solve which numerically computes all roots of multivariate system of nonlinear equations without the need of initial conditions?
Thanks a lot! I would really appreciate this
Rgds
Samantha
sam_kjmSun, 03 Jul 2016 19:02:15 +0200https://ask.sagemath.org/question/34002/Plot the intersection of two surfaces (or solutions of a system of eqs)https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/ Hi everybody,
I'd like to plot the solutions of the system
$$(X + Y )(X − Z^3)=0,$$
$$XY + Y^2=0.$$
in 3D, I mean, the set of points (X,Y,Z) in IR^3 that verify the system. I don't know how to do it. I was searching how to plot the intersection of both surfaces, but neither I could. ¿Could anyone tell me how to do it?
Thanks in advanceMinkowskiMon, 16 May 2016 18:03:59 +0200https://ask.sagemath.org/question/33418/Solving a system of equations using mpmath.findroothttps://ask.sagemath.org/question/32678/solving-a-system-of-equations-using-mpmathfindroot/ Hi All,
A few weeks ago, the code below, which was designed to compute some points was working perfectly.
After compiling it a few days ago, I got :
ValueError: Could not find root within given tolerance. (7235.55 > 2.1684e-19)
Try another starting point or tweak arguments.
Please I will be very pleased if someone could help me solve this problem. Thanks for your understanding
import mpmath
theta=pi/12
p1=vector([0,0,0])
p2=vector([-12,0,0])
p3=vector([1/24,-17/24*sqrt(287),0])
#Calcul du point p4
x4,r4=var('x4,r4')
T4=solve([(p1[0]-x4)^2+(p1[1]-r4*cos(theta))^2+(p1[2]-r4*sin(theta))^2==25,(p2[0]-x4)^2+(p2[1]-r4*cos(theta))^2+(p2[2]-r4*sin(theta))^2==100],x4,r4,solution_dict=True)
a=T4[0].values()
b=T4[1].values()
p4=vector([a[1],0,0])
if b[0]<0:
p4[1]=a[0]*cos(theta)
p4[2]=a[0]*sin(theta)
else:
p4[1]=b[0]*cos(theta)
p4[2]=b[0]*sin(theta)
var(" x5 y5 z5 x6 y6 z6 x7 y7 z7")
eq25 = (p2[0]-x5)^2+(p2[1]-y5)^2+(p2[2]-z5)^2-100 == 0
eq46 = (p4[0]-x6)^2+(p4[1]-y6)^2+(p4[2]-z6)^2-144 == 0
eq45 = (p4[0]-x5)^2+(p4[1]-y5)^2+(p4[2]-z5)^2-121 == 0
eq16 = (p1[0]-x6)^2+(p1[1]-y6)^2+(p1[2]-z6)^2-100 == 0
eq27 = (p2[0]-x7)^2+(p2[1]-y7)^2+(p2[2]-z7)^2-144 == 0
eq37 = (p3[0]-x7)^2+(p3[1]-y7)^2+(p3[2]-z7)^2-144 == 0
eq56 = (x6-x5)^2+(y6-y5)^2+(z6-z5)^2-144 == 0
eq67 = (x6-x7)^2+(y6-y7)^2+(z6-z7)^2-100 == 0
eq57 = (x7-x5)^2+(y7-y5)^2+(z7-z5)^2-25 == 0
# Calcul des points p5, p6, et p7
f= [lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq25.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq46.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq45.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq16.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq27.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq37.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq56.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq67.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7)),
lambda x5,y5,z5,x6,y6,z6,x7,y7,z7: eq57.lhs().subs(x5=RR(x5), y5=RR(y5), z5=RR(z5), x6=RR(x6), y6=RR(y6), z6=RR(z6), x7=RR(x7), y7=RR(y7), z7=RR(z7))]
found_root = mpmath.findroot(f, (-5,-6,-3.5, 3.5, 0.1,-9,-5,-5,-8))
found_root = Matrix(RR, found_root.tolist())
p5=vector([found_root[0][0], found_root[1][0], found_root[2][0]])
p6=vector([found_root[3][0], found_root[4][0], found_root[5][0]])
p7=vector([found_root[6][0], found_root[7][0], found_root[8][0]])
print p5
cyrilleSat, 27 Feb 2016 08:55:33 +0100https://ask.sagemath.org/question/32678/Solving system of inequalities in one variablehttps://ask.sagemath.org/question/26941/solving-system-of-inequalities-in-one-variable/ I am probably missing something about how to use sage:
If I run this:
x = var('x')
a = var('a')
solve([a*x>0,a>0],[x])
I get this results:
[[0 < x, a > 0], [x < 0, -a > 0, a > 0]]
However, I would expect something like:
[0 < x, a > 0]
What am I missing?
Thanksabc321Tue, 26 May 2015 11:38:05 +0200https://ask.sagemath.org/question/26941/Solving system of linear Diophantine equationshttps://ask.sagemath.org/question/23666/solving-system-of-linear-diophantine-equations/I have an $m \times n$ integer matrix $A$ with $m>n$, and a set $S \subset \mathbb{Z}$, for example $S=\\{-1,0,1\\}$.
I want to enumerate all possible $X \in S^n$ such that $AX=0$.
I tried using smith_form(), but then i could not figure out how to force the solution to belong to elements of $S$.
----------
EDIT. Thank you Dima for the solution. It works well. I am adding an example here to illustrate your solution.
lb = -1
ub = 1
A = matrix(ZZ, [(8,2,10,0,12,2,0), (4,6,9,1,14,5,2), (2,0,1,1,0,1,0), (2,1,3,0,4,0,1)])
eq1 = [(0,8,2,10,0,12,2,0), (0,4,6,9,1,14,5,2), (0,2,0,1,1,0,1,0), (0,2,1,3,0,4,0,1)]
ieq1 = [(-lb,1,0,0,0,0,0,0), (ub,-1,0,0,0,0,0,0),
(-lb,0,1,0,0,0,0,0), (ub,0,-1,0,0,0,0,0),
(-lb,0,0,1,0,0,0,0), (ub,0,0,-1,0,0,0,0),
(-lb,0,0,0,1,0,0,0), (ub,0,0,0,-1,0,0,0),
(-lb,0,0,0,0,1,0,0), (ub,0,0,0,0,-1,0,0),
(-lb,0,0,0,0,0,1,0), (ub,0,0,0,0,0,-1,0),
(-lb,0,0,0,0,0,0,1), (ub,0,0,0,0,0,0,-1)]
p = Polyhedron(eqns=eq1, ieqs=ieq1, base_ring=QQ)
p.integral_points()
returns the answer
((-1, -1, 1, 1, 0, 0, 0),
(0, -1, -1, 1, 1, 0, 0),
(0, -1, 0, -1, 0, 1,1),
(0, 0, 0, 0, 0, 0, 0),
(0, 1, 0, 1, 0, -1, -1),
(0, 1, 1, -1, -1, 0,0),
(1, 1, -1, -1, 0, 0, 0))
which is exactly what i needed. Thanks again.arunayyarSat, 02 Aug 2014 12:17:47 +0200https://ask.sagemath.org/question/23666/Nodal analysis in networkhttps://ask.sagemath.org/question/23624/nodal-analysis-in-network/Hi experts!
I have:
* Q nodes (Q stick-stick intersections)
* a list 'NODES'=[(x,y,i,j)_1,........, (x,y,i,j)_Q], where each element (x,y,i,j) represent the intersection point (x,y) of the sticks i and j.
* a matrix 'H' with QxQ elements {H_k,l}.
H_k,l=0 if nodes 'k' and 'l' aren't joined by a edge, and H_k,l = R_k,l = the electrical resistance associated with the union of the nodes 'k' and 'l' (directly proportional to the length of the edge that connects these nodes).
* a list 'nodes_resistances'=[R_1, ....., R_Q].
All nodes with 'j' (or 'i') = N+1 have a electric potential 'V' respect all nodes with 'j' or 'i' = N.
Now i must apply NODAL ANALYSIS for determinate the electrical current through each of the edges, and the net current. I have no ideas about how to do that. Can you help me?
Thanks a lot!
Best regards
mresimulatorTue, 29 Jul 2014 14:24:51 +0200https://ask.sagemath.org/question/23624/solving system of polynomial equations over reals using newton methodhttps://ask.sagemath.org/question/11359/solving-system-of-polynomial-equations-over-reals-using-newton-method/I have a set of polynomial equations and I want to find one of its real solutions close to some point, and I need only one solution. Here is an example:
This is the list of equations and variables:
Equations = [x_0*x_1*x_2*x_3 - x_0*x_1 - x_0*x_2 - x_0*x_3 - x_1*x_2 - x_1*x_3 + 2*x_0 + 2*x_1 - 448, -x_0*x_1*x_2 - x_0*x_1*x_3 - x_0*x_2*x_3 - x_1*x_2*x_3 + 3*x_0 +
3*x_1 + 2*x_2 + 2*x_3 + 452, x_0*x_1 + x_0*x_2 + x_0*x_3 + x_1*x_2 + x_1*x_3 + x_2*x_3 - 159, -x_0 - x_1 - x_2 - x_3 + 21]
Variables = [x_0, x_1, x_2, x_3]
If I ask Sage to solve this
S = solve(Equations,Variables)
it returns a bunch of solutions. But in some cases it doesn't give me any real solutions. I can prove that the above set of equations has a real solution close to `[2,4,7,8]`. Is there any way that I can perform an algorithm like the Newton's method with the start point `[2,4,7,8]`, and find that real solution?k1Sat, 19 Apr 2014 19:12:09 +0200https://ask.sagemath.org/question/11359/solve fails to solve a simple system and runs out of memoryhttps://ask.sagemath.org/question/11037/solve-fails-to-solve-a-simple-system-and-runs-out-of-memory/Hello,
I have a system of linear algebraic equations formed by the nodal equations of a linear electric circuit. The nodal voltages are the unknowns.
There are 16 unknowns.
sage runs forever and in the end I obtain:
RuntimeError: ECL says: Memory limit reached. Please jump to an outer pointer,
quit program and enlarge the
memory limits before executing the program again.
Am I missing something or doing something wrong ?
It is possible that sage cannot solve this linear algebraic system in a reasonable (short) time with "only" 16 unknowns ?
The unknowns are
[V_3, V_4, V_5, V_8, V_7, V_1, V_8, V_10, V_9l, V_4, V_4, V_7, V_2, V_3, V_6, V_9]
and the system is:
[V_10/RLOAD + ((V_1 - V_8)*K1*sqrt(Ltrafo6) - sqrt(Ltrafo5)*V_10)/((K1^2*Ltrafo6*s - Ltrafo6*s)*sqrt(Ltrafo5)) == 0,
-(V_9 - V_9l)/RL2 + ((V_4 - V_7)*(K3*K4 - K2)*sqrt(L1)*sqrt(L2) + ((K4^2 - 1)*(V_4 - V_9l)*sqrt(L1) + (V_2 - V_3)*(K2*K4 - K3)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*L2*sqrt(L3)) == 0,
(V_1 - V_7)/R4 + (V_1 - V_2)/R1 + V_1/RI + (K1*sqrt(Ltrafo5)*V_10 - (V_1 - V_8)*sqrt(Ltrafo6))/((K1^2*Ltrafo5*s - Ltrafo5*s)*sqrt(Ltrafo6)) - ICC_small_signal_0_1(s) == 0,
(V_3 - V_4)*CBC_Q1*s + (V_4 - V_5)*GM_Q1 + (V_3 - V_5)/RO_Q1 - ((V_4 - V_7)*(K2*K3 - K4)*sqrt(L1)*sqrt(L2) - ((K2^2 - 1)*(V_2 - V_3)*sqrt(L2) + (V_4 - V_9l)*(K2*K4 - K3)*sqrt(L1))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*L1*sqrt(L2)*sqrt(L3)) == 0,
Cbp1*V_2*s - (V_1 - V_2)/R1 + V_2/RCbp1 + ((V_4 - V_7)*(K2*K3 - K4)*sqrt(L1)*sqrt(L2) - ((K2^2 - 1)*(V_2 - V_3)*sqrt(L2) + (V_4 - V_9l)*(K2*K4 - K3)*sqrt(L1))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*L1*sqrt(L2)*sqrt(L3)) == 0,
(V_5 - V_7)*CBE_Q2*s + (V_5 - V_7)*GM_Q2 - (V_4 - V_5)*GM_Q1 + (V_5 - V_8)/RO_Q2 + (V_5 - V_7)/RPI_Q2 - (V_4 - V_5)/RPI_Q1 - (V_3 - V_5)/RO_Q1 + (V_5 - V_6)/(LRFC1*s) == 0, -(V_3 - V_4)*CBC_Q1*s + (V_4 - V_5)/RPI_Q1 - ((V_4 - V_7)*(K3*K4 - K2)*sqrt(L1)*sqrt(L2) + ((K4^2 - 1)*(V_4 - V_9l)*sqrt(L1) + (V_2 - V_3)*(K2*K4 - K3)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*L2*sqrt(L3)) - ((K3^2 - 1)*(V_4 - V_7)*sqrt(L1)*sqrt(L2) + ((V_4 - V_9l)*(K3*K4 - K2)*sqrt(L1) - (V_2 - V_3)*(K2*K3 - K4)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*sqrt(L2)*L3) == 0,
(V_7 - V_8)*CBC_Q2*s - (V_5 - V_7)*CBE_Q2*s + Cbp2*V_7*s - (V_5 - V_7)/RPI_Q2 - (V_1 - V_7)/R4 + V_7/R3 + ((K3^2 - 1)*(V_4 - V_7)*sqrt(L1)*sqrt(L2) + ((V_4 - V_9l)*(K3*K4 - K2)*sqrt(L1) - (V_2 - V_3)*(K2*K3 - K4)*sqrt(L2))*sqrt(L3))/((2*K2*K3*K4*s - K2^2*s - K3^2*s - K4^2*s + s)*sqrt(L1)*sqrt(L2)*L3) == 0,
V_6/R2 - (V_5 - V_6)/(LRFC1*s) == 0,
C2*V_9*s + (V_9 - V_9l)/RL2 == 0,
-(V_7 - V_8)*CBC_Q2*s - (V_5 - V_7)*GM_Q2 - (V_5 - V_8)/RO_Q2 - (K1*sqrt(Ltrafo5)*V_10 - (V_1 - V_8)*sqrt(Ltrafo6))/((K1^2*Ltrafo5*s - Ltrafo5*s)*sqrt(Ltrafo6)) == 0]
Thank you
ekaSat, 15 Feb 2014 14:09:08 +0100https://ask.sagemath.org/question/11037/A very nonlinear system of three equationshttps://ask.sagemath.org/question/10506/a-very-nonlinear-system-of-three-equations/Here's a fun little problem: determine the exponential curve f(x) = c + ba^x defined by three points, (2,10), (4,6), and (5,5).
The system of three equations and three unknowns is
10 = c + ba^2
6 = c + ba^4
5 = c + ba^5
It's not that hard to solve numerically. With a little algebraic substitution and iteration, the answer turns out to be
a = 0.640388203
b = 16.53456516
c = 3.219223594
But is there a more elegant way to use Sage to arrive at this result? I'm stumped.OrionNavThu, 05 Sep 2013 04:15:08 +0200https://ask.sagemath.org/question/10506/Minimal notebook system requirementshttps://ask.sagemath.org/question/8176/minimal-notebook-system-requirements/Hello!
Could somebody please tell me what are the actual minimum system requirements to start Sage Notebook?
I've tried to start it on a little virtual server with about 256MB of RAM. If I just start Sage, it seems to work, but when I try to launch the Notebook, it gives this error:
Error: [Errno 12] Cannot allocate memory
Is there a way to launch a Sage Notebook server on such machine?
Thanksv_2eTue, 21 Jun 2011 13:16:24 +0200https://ask.sagemath.org/question/8176/sage doesn't load properly in mac osx 10.7.1 (Lion)https://ask.sagemath.org/question/8364/sage-doesnt-load-properly-in-mac-osx-1071-lion/How do I get sage to load properly on a Macbook Pro, OSX 10.7.1 (Lion), 2.26 GHz Intel Core 2 duo,
2 GB 1067 MHz DDR3? Terminal log follows:
Last login: Sun Oct 9 11:03:19 on ttys000
mth-pe201g-mac02:~ angel1jr$ cd ..
mth-pe201g-mac02:Users angel1jr$ cd ..
mth-pe201g-mac02:/ angel1jr$ ls
Applications discreteharvestingreport
FinalReport_726_pm etc
Library home
Network mach_kernel
System mathworks_downloads
User Guides And Information net
Users private
Volumes sbin
bin tmp
cores usr
dev var
mth-pe201g-mac02:/ angel1jr$ cd Applications
mth-pe201g-mac02:Applications angel1jr$ cd sage
mth-pe201g-mac02:sage angel1jr$ ls
COPYING.txt README.txt devel ipython sage
Makefile data examples local spkg
mth-pe201g-mac02:sage angel1jr$ ./sage
----------------------------------------------------------------------
| Sage Version 4.7.1, Release Date: 2011-08-11 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
Setting permissions of DOT_SAGE directory so only you can read and write it.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Applications/sage/local/bin/<string> in <module>()
/Applications/sage/local/lib/python2.6/site-packages/sage/misc/preparser_ipython.py in <module>()
6 ###########################################################################
7
----> 8 import sage.misc.interpreter
9
10 import preparser
/Applications/sage/local/lib/python2.6/site-packages/sage/misc/interpreter.py in <module>()
100
101 import os
--> 102 import log
103 import re
104
/Applications/sage/local/lib/python2.6/site-packages/sage/misc/log.py in <module>()
63
64 import interpreter
---> 65 import latex
66 import misc
67
/Applications/sage/local/lib/python2.6/site-packages/sage/misc/latex.py in <module>()
37 import subprocess
38
---> 39 from misc import tmp_dir, graphics_filename
40 import sage_eval
41 from sage.misc.misc import SAGE_DOC
/Applications/sage/local/lib/python2.6/site-packages/sage/misc/misc.py in <module>()
102 print "Setting permissions of DOT_SAGE directory so only you can read and write it."
103 # Change mode of DOT_SAGE.
--> 104 os.chmod(DOT_SAGE, _desired_mode)
105
106
OSError: [Errno 1] Operation not permitted: '/Users/angel1jr/.sage/'
WARNING: Failure executing code: 'import sage.misc.preparser_ipython; sage.misc.preparser_ipython.magma_colon_equals=True'
Setting permissions of DOT_SAGE directory so only you can read and write it.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Applications/sage/local/lib/python2.6/site-packages/IPython/ipmaker.pyc in force_import(modname)
64 reload(sys.modules[modname])
65 else:
---> 66 __import__(modname)
67
68
/Applications/sage/local/bin/ipy_profile_sage.py in <module>()
1 import os
2 if 'SAGE_CLEAN' not in os.environ:
----> 3 import sage.misc.misc
4 from sage.misc.interpreter import preparser, _ip
5 preparser(True)
/Applications/sage/local/lib/python2.6/site-packages/sage/misc/misc.py in <module>()
102 print "Setting permissions of DOT_SAGE directory so only you can read and write it."
103 # Change mode of DOT_SAGE.
--> 104 os.chmod(DOT_SAGE, _desired_mode)
105
106
OSError: [Errno 1] Operation not permitted: '/Users/angel1jr/.sage/'
Error importing ipy_profile_sage - perhaps you should run %upgrade?
WARNING: Loading of ipy_profile_sage failed.
<ERROR: name 'sage_prompt' is not defined>
JRAngelSun, 09 Oct 2011 13:39:42 +0200https://ask.sagemath.org/question/8364/desolve_system error "unable to make sense of Maxima expression"https://ask.sagemath.org/question/9591/desolve_system-error-unable-to-make-sense-of-maxima-expression/ t = var('t')
y = function('y', t)
w = function('w', t)
p = function('p', t)
de1 = diff(y,t) == - 0.5*y - 0.9*p + 0.5*w
de2 = diff(w,t) == 1.0*p + 0.7*w
de3 = diff(p,t) == + 0.5*y - 0.3*w
desolve_system([de1, de2, de3], [y,p,w])
The function desolve_system stops with the error:
> TypeError: unable to make sense of
> Maxima expression
> 'y(t)=ilt((200*y(0)*?g1090327^2+(-140*y(0)+100*w(0)-180*p(0))*?g1090327+60*y(0)+54*w(0)+226*p(0))/(200*?g1090327^3-40*?g1090327^2+80*?g1090327-83),?g1090327,t)'
> in Sage
Why? Thanks in advance!
petresFri, 30 Nov 2012 07:51:59 +0100https://ask.sagemath.org/question/9591/Numerically solving of a system of nonlinear inequalitieshttps://ask.sagemath.org/question/9531/numerically-solving-of-a-system-of-nonlinear-inequalities/Hello,
I have a highly nonlinear system of 14 inequalities in seven variables l_1, l_2,l_3, I_q1, I_q2,I_q,R_C consisting of inequalities like 0.2135674961e136 * I_q2 ^ 3 * I_q1 * l_1 ^ 2 * l_3 + 0.1359729300e138 * I_q2 ^ 2 * l_2 * l_1 ^ 3 * l_3 + 0.4748826459e137 * I_q2 * l_2 ^ 2 * l_1 ^ 3 * l_3 + 0.1023634311e139 * I_q2 ^ 2 * l_2 * I_q1 * l_1 ^ 2 * l_3 + 0.4926161933e138 * I_q2 * l_2 ^ 2 * I_q1 * l_1 ^ 2 * l_3 + 0.1817765067e139 * l_1 * l_2 * l_3 * I_q1 ^ 2 * I_q2 ^ 2 + 0.1022307261e139 * l_1 * l_2 ^ 2 * l_3 * I_q1 ^ 2 * I_q2 + 0.6124318199e136 * I_q2 ^ 3 * I_q1 ^ 2 * l_1 * l_3 + 0.4722141070e137 * l_2 ^ 3 * I_q1 * l_1 ^ 2 * l_3 + 0.1354133707e138 * l_1 * l_2 ^ 3 * l_3 * I_q1 ^ 2 + 0.4099750199e136 * l_2 * l_3 * I_q1 ^ 3 * I_q2 ^ 2 + 0.1431829278e136 * l_2 ^ 2 * l_3 * I_q1 ^ 3 * I_q2 + 0.2895936503e138 * l_1 * l_2 ^ 2 * l_3 ^ 2 * I_q1 ^ 2 + 0.4828612500e136 * l_1 ^ 2 * l_2 * l_3 * I_q2 ^ 3 + 0.1587988317e138 * l_1 ^ 2 * l_2 ^ 2 * l_3 * I_q2 ^ 2 + 0.1009872263e138 * l_1 ^ 2 * l_2 ^ 2 * l_3 ^ 2 * I_q1 + 0.5487021423e137 * l_1 ^ 2 * l_2 ^ 3 * l_3 * I_q2 + 0.8649483590e137 * I_q2 ^ 2 * l_2 * I_q1 * l_1 ^ 2 * I_q + 0.3020814254e137 * I_q2 * l_2 ^ 2 * I_q1 * l_1 ^ 2 * I_q + (0.4371323541e134 * I_q2 * l_2 ^ 2 * I_q1 * l_1 ^ 2 * l_3 + 0.1253532341e135 * l_1 * l_2 ^ 2 * l_3 * I_q1 ^ 2 * I_q2 + 0.1251639064e135 * I_q2 ^ 2 * l_2 * I_q1 * l_1 ^ 2 * l_3 + 0.3589233398e135 * l_1 * l_2 * l_3 * I_q1 ^ 2 * I_q2 ^ 2) * (I_q ^ 2 + 0.1824e4 * l_3) + 0.4611303613e136 * I_q2 ^ 2 * l_2 * l_1 ^ 3 * R_C * I_q1 * l_3 + 0.1610488249e136 * I_q2 * l_2 ^ 2 * l_1 ^ 3 * R_C * I_q1 * l_3 + 0.1331893542e137 * I_q2 ^ 2 * l_2 * I_q1 ^ 2 * l_1 ^ 2 * R_C * l_3 + 0.4651610646e136 * I_q2 * l_2 ^ 2 * I_q1 ^ 2 * l_1 ^ 2 * R_C * l_3 + 0.9547565330e134 * R_C * l_1 * l_2 ^ 2 * l_3 * I_q1 ^ 3 * I_q2 + 0.2733750000e135 * R_C * l_1 * l_2 * l_3 * I_q1 ^ 3 * I_q2 ^ 2 + 0.4083749998e138 * I_q * l_1 * l_2 * l_3 * I_q1 ^ 2 * I_q2 + 0.1424087112e138 * I_q * l_1 ^ 2 * l_2 * l_3 * I_q1 * I_q2 + 0.1012500000e137 * l_1 * l_2 * l_3 * I_q1 * I_q2 ^ 3 + 0.6072418752e138 * l_1 * l_2 * l_3 ^ 2 * I_q1 ^ 2 * I_q2 + 0.3329814043e138 * l_1 * l_2 ^ 2 * l_3 * I_q1 * I_q2 ^ 2 + 0.1150560165e138 * l_1 * l_2 ^ 3 * l_3 * I_q1 * I_q2 + 0.2117576562e138 * l_1 ^ 2 * l_2 * l_3 ^ 2 * I_q1 * I_q2 + 0.2480348871e138 * I_q * l_1 * l_2 * I_q1 ^ 2 * I_q2 ^ 2 + 0.8662567131e137 * I_q * l_1 * l_2 ^ 2 * I_q1 ^ 2 * I_q2 + 0.1947540375e138 * I_q * l_1 * l_2 ^ 2 * l_3 * I_q1 ^ 2 + 0.6791471439e137 * I_q * l_1 ^ 2 * l_2 ^ 2 * l_3 * I_q1 >0 or more complicated inequalities and I am looking for some particular numerical solutions, not necessarily for all solutions. (I know that there are solutions to the subsystem of the first 13 inequalties.) Is there a routine or another way in Sage to do this? If I understand correctly, solve tries to find all solutions by symbolic calculations and gives a RuntimeError: floating point exception.
Thanks a lot in advance,
Urs Hackstein
Addition: scipy.optimize.fsolve and newton_krylov solve systems numerically, but only systems of equalities, not those of inequalities.
HacksteinWed, 14 Nov 2012 08:33:34 +0100https://ask.sagemath.org/question/9531/Getting help inside Sagehttps://ask.sagemath.org/question/8708/getting-help-inside-sage/Sorry if it's a dumb question, folks.
What are all the ways of getting help inside Sage? I would like some table like this:
item?? | see code
help(item) | see help about item
I ask this question because I only know the ?? and help() ways. But they don't always work: I tried simplify_full?? and help(simplify_full) but ... got errors!
Green diodSat, 11 Feb 2012 13:38:50 +0100https://ask.sagemath.org/question/8708/Solving a simple system of equationshttps://ask.sagemath.org/question/8613/solving-a-simple-system-of-equations/Hey Guys,
New to Sage and just trying to solve a simple system of equations. The system is below:
x,y,z,w,ha,hb,e,c = var('x y z w ha hb e c')
f1 = (c*(x+y)*(ha-x))-(e*x)
f2 = (c*(z+w)*(ha-x-z))-(c*z*(x+y)) - (e*z)
f3 = (c*(x+y)*(hb-y-w))-(c*y*(z+w)) - (e*y)
f4 = (c*(z+w)*(hb-w))-(e*w)
I want to find the equilibrium solutions, solving for x, y, z, w, when equations f1-f4 are equal to zero. So I try:
solve([f1==0,f2==0,f3==0,f4==0],x,y,z,w)
Unfortunately this causes Sage to hang (or it takes a remarkably long time to solve that I interrupt the process). This problem shouldn't be difficult to solve, but I am at a loss as to what to do. Perhaps I am going about this the wrong way??
BalderSat, 07 Jan 2012 12:15:49 +0100https://ask.sagemath.org/question/8613/Basis of invariant polynomial systemhttps://ask.sagemath.org/question/8509/basis-of-invariant-polynomial-system/I've been trying to compute a Grobner basis for a specific invariant polynomial system. It has 6 variables, 6 constants and 6 equations and is invariant to a group of cardinality 2. Various algorithms have been ran on it, including FGb/Gb through Maple and Singular through SAGE system. In both cases, the invariance was ignored and the computation of the Grobner basis failed to finish after hours (sometime days) of computation, while occupying all the memory available. Please note, I do not know what exactly the underlying algorithm was (Buchberger/F4/F5...).
It is an engineering application and in practice, I would only need the first few polynomials of the Grobner basis, that is the ones with as low degree as possible. I'm an engineer not a mathematician, so my knowledge of the topic is very limited. I did however understood, that in case of invariant systems, a SAGBI basis (or invariant Grobner basis) can be computed much more efficiently. More important, the invariant Grobner basis can be computed "up to a given degree", which is exactly what I probably need.
I got a hint that such algorithm might exist in SAGE. I've been searching through the SAGE documentation, but it seems I don't know what to search for and the system is huge.
If anyone can point me to right direction it would be great!
The problem:
X0 + Y0 - S0 = 0
X0 X1 + Y0 Y1 - S1 = 0
X0 ( X1^2 + 2 X2 )+ Y0 ( Y1^2 + 2 Y2 )- 2 S2 = 0
X0 ( X1^3 + 6 X2 X1 )+ Y0 ( Y1^3 + 6 Y2 Y1 ) - 6 S3 = 0
X0 ( X1^4 + 12 X2 X1^2 + 12 X2^2 )+ Y0 ( Y1^4 + 12 Y2 Y1^2 + 12 Y2^2 )- 24 S4 = 0
X0 ( X1^5 + 20 X2 X1^3 + 60 X2^2 X1 ) + Y0 ( Y1^5 + 20 Y2 Y1^3 + 60 Y2^2 Y1 ) - 120 S5 = 0
Where X0,X1,X2,Y0,Y1,Y2 are variables S0...S5 are constants, all are complex numbers.musevicThu, 24 Nov 2011 13:20:32 +0100https://ask.sagemath.org/question/8509/Solve large system of linear equations over GF(2)https://ask.sagemath.org/question/8031/solve-large-system-of-linear-equations-over-gf2/I need to solve a pretty large system of linear equations over GF(2) (The matrix is around 20000 x 20000). The straightforward approach used to solve linear equation systems (by using MatrixSpace and octave) will ran out of memory before even building up the matrix.
I wonder if there is any method i could use to solve such a system. Also note that the system i try to solve is sparse in general.ji-oMon, 28 Mar 2011 21:10:14 +0200https://ask.sagemath.org/question/8031/System of nonlinear equationshttps://ask.sagemath.org/question/8224/system-of-nonlinear-equations/Hello,
Is it possible to solve the following using Sage?
http://www.wolframalpha.com/input/?i=solve%28%5Bx1%2Bx2%2Bx3-6%3D%3D0%2Cx1*x2*x3-6%3D%3D0%2Cx1%5E2%2Bx2%5E2%2Bx3%5E2-14%3D%3D0%5D%2Cx1%29
Thanks in advance.Eviatar BachWed, 13 Jul 2011 23:40:44 +0200https://ask.sagemath.org/question/8224/Solve system of equations with additional conditions in sagehttps://ask.sagemath.org/question/8120/solve-system-of-equations-with-additional-conditions-in-sage/Hi Sage users,
I've got a system of equations like the following example:
- **eq1 = a + b == n * (c + d)**
- **eq2 = b == k * d**
with n and k must be integers.
for the other variables, there are additional conditions like
- **a >= 80**
- **b >= 1000**
- **c >= 20**
- **d >= 40**
- **a + b <= 2000**
- **c + d <= 90**
I want to get all solutions of this system where n and k are integers.
Is there a way to find these with sage?
Would be great to get any possible hint to do this!
Thanks for your suggestions,
TobitwkWed, 18 May 2011 17:54:35 +0200https://ask.sagemath.org/question/8120/