ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 27 Aug 2016 03:28:29 -0500solve system of non-linear implicit equations numericallyhttp://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 11:06:50 -0500http://ask.sagemath.org/question/10269/Solve a simple system of non-linear equationshttp://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 02:30:18 -0600http://ask.sagemath.org/question/8557/solving systems of equations returns [] Reduxhttp://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 03:28:29 -0500http://ask.sagemath.org/question/34608/solve fails to solve a simple system and runs out of memoryhttp://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 07:09:08 -0600http://ask.sagemath.org/question/11037/Solving a simple system of equationshttp://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 05:15:49 -0600http://ask.sagemath.org/question/8613/Solve large system of linear equations over GF(2)http://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 14:10:14 -0500http://ask.sagemath.org/question/8031/System of nonlinear equationshttp://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 16:40:44 -0500http://ask.sagemath.org/question/8224/Solve system of equations with additional conditions in sagehttp://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 10:54:35 -0500http://ask.sagemath.org/question/8120/