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.Sun, 09 Dec 2018 20:28:31 +0100Solving linear congruencehttps://ask.sagemath.org/question/44618/solving-linear-congruence/ Is there a simple way to solve a linear congruence modulo an integer with large prime factors in Sage? `solve_mod` function cannot handle such large moduli apparently.kdr01Sun, 09 Dec 2018 20:28:31 +0100https://ask.sagemath.org/question/44618/Characteristic polynomial wont be used in solvehttps://ask.sagemath.org/question/39746/characteristic-polynomial-wont-be-used-in-solve/ When I try to find roots in a characteristic polynomial it gives me errors:
sage: #Diagonalmatrix
....:
....:
....: A=matrix([[1,-1,2],
....: [-1,1,2],
....: [2,2,-2]])
....: var('x')
....: poly=A.characteristic_polynomial()
....: eq1=solve(poly==0,x)
....:
x
--------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-86-fee7a7de2ea1> in <module>()
7 var('x')
8 poly=A.characteristic_polynomial()
----> 9 eq1=solve(poly==Integer(0),x)
/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
sage:
What can I do in order to use the polynomial in an equation I wish to solve?PoetastropheThu, 23 Nov 2017 18:18:11 +0100https://ask.sagemath.org/question/39746/how to get simplified result of solving equationhttps://ask.sagemath.org/question/28853/how-to-get-simplified-result-of-solving-equation/Hi there!
In a linear algebra assignment I have the following equation I need to find a solution for:
`-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0`. I know the result is pi/3.
Now, when I use solve, `solve(-2*sqrt(3)*sin(t)^2+2*cos(t)*sin(t)+sqrt(3)==0, t)`. I get:
[sin(t) == -1/6*sqrt(3)*(sqrt(cos(t)^2+6)-cos(t), sin(t) == 1/6*sqrt(3)*sqrt(cos(t)^2+6)+cos(t))].
How do I use the solve function to get the more simplified result?
NB: I have also tried to use `find_root` and different simplify functions, but also without any luck. I am new to sage, so it is quite possible that I don't know a specification to the solve function which I should use.
Thank you in advance!
Sincerly SimonismonMon, 17 Aug 2015 19:38:14 +0200https://ask.sagemath.org/question/28853/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/Find linear combinations that meet certain criteriahttps://ask.sagemath.org/question/10881/find-linear-combinations-that-meet-certain-criteria/Hey,
I am quite new to SAGE, this is my first project. I'm not even sure if it is solvable or not, but here is what I want to do:
- w_1 is the smallest multiple of 5 that is >=
(volume / 30)
- w_n = w_1 + 5*n
- w_max is the largest multiple of 5 that is <=
((volume / 24) + 30)
- were n increases until w_n == w_max
I want to find all solutions to:
- (w_1)*(r_1) + (w_2)*(r_2) + ... +
(w_n)*(r_n) == volume
Given each/any r can be any integer from 5 to 10 and that the sum of all r's is less than or equal 30. Volume is just some constant integer multiple of 5 between 5425 and 7200. Its just an initial condition I want to be able to change. Is this possible or is it too many possibilities for SAGE to handle? I have some programing experience (C and .net ) and a little math experience(Calc 1,2 and 3 as well as differential equations) but I don't know were to start really. If there is any more information I can provide that would be useful I would be very happy to do so. I don't expect someone to make it for me, but I'm not quite sure what kind of approach I should be trying use, so I don't really know what to look up. Any help or advice is welcome.
Thanks.waryhermitFri, 03 Jan 2014 12:19:54 +0100https://ask.sagemath.org/question/10881/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/