ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 Mar 2020 04:19:57 -0500How to solve numericaly with arbitrary precisionhttps://ask.sagemath.org/question/50197/how-to-solve-numericaly-with-arbitrary-precision/Hello,
I want to solve a numerical equation for which I can only access by a lambda function, the M matrix is to big for the determinant to be computed on the symbolic ring.
f = lambda om: RRR(M.subs({omega:om}).change_ring(RRR).det())
But , find-root solve in the built in float type of Python which is lacking the precision I need. Is there a way in sage to solve numericaly with arbitrary precision?
Thank you
Regards
*(edited with example more in line with what I am trying to achieve)*
sage: x=var('x')
sage: M= Matrix(SR,[[cos(x),cosh(x)],[sin(x),sinh(x)]])
sage: RRR = RealField(200)
sage: f = lambda om: M.subs({x:om}).change_ring(RRR).det()
sage: find_root(f,1,2)JonasAMon, 09 Mar 2020 04:19:57 -0500https://ask.sagemath.org/question/50197/Solving two-variate polynomial identities https://ask.sagemath.org/question/9674/solving-two-variate-polynomial-identities/Hi, some help is appreciated concerning the following search.
Suppose **P1**,**P2**,**P3** are two-variate polynomials with integer coefficients in A,B. I'm searching for all sets (**P1**,**P2**,**P3**) such that:
i) **P1**(A,B)+**P2**(A,B)=**P3**(A,B)
ii) Greatest common denominator **P1** and **P2** equals 1 (Thus gcd( **P1**,**P2** )=1)
iii) The product **P1** * **P2** * **P3** can be divided by AB(A+B) (Thus gcd( **P1**.**P2**.**P3**, AB(A+B) )=AB(A+B))
Some well-known identities are A^2 + B(2A+B) = (A+B)^2, (B-A)^2 + 4AB = (A+B)^2 and
(A+2B)A^3 + B(2A+3B)^3 = (A+B)(A+3B)^3. Most interesting are polynomials with *only* linear factors such as: 16(A+B)B^3 + A(3A+4B)^3+(A+2B)(3A+2B)^3 and 27(B-A)(A+B)^5 + (3A+2B)A^3(3A+5B)^2 = (2A+3B)B^3(5A+3B)^2.
I'm curious if via Sage one could develop a generating algorithm (maybe there is a connection to Graphs and/or Combinatorics ...). N.B.: A [related question](http://ask.sagemath.org/question/1452/polynomial-identity) was raised earlier.
Thanks in advance for any support!
RolandRolandbTue, 01 Jan 2013 07:49:28 -0600https://ask.sagemath.org/question/9674/Solving a system of 5 polynomial equationshttps://ask.sagemath.org/question/40346/solving-a-system-of-5-polynomial-equations/I have a system of 5 polynomial equations. I solved the equations in Maple but I'm trying to solve them also in sagemath since it's open source. I've been trying for a long time (weeks) and still couldn't solve the equations in sagemath (Maple finds all the solutions in 10 seconds). I don't need the complex solutions (if exist). only the real solutions.
I have posted before a similar question but with 18 equations and it took Maple 40 minutes to solve them. But since then I was able to reduce the number of equations from 18 to 5. This time Maple solved the equations much faster (10 seconds instead of 40 minutes). But unfortunately, still can't solve the equations with sagemath.
The goal is to find all the possible (real) solutions of the equations. Maple did it and found 20 solutions (the code is attached bellow). But I wasn't able to solve the equations in sagemath at all (I attached the code for sagemath bellow as well).
I tried to use groebner basis in sagemath but there are so many different implementations with different order of the polynomials ('lex', 'degrevlex',etc). I tried many of them and none of them could solve the equations.
I will appreciate if anyone can suggest other ways to solve the equations. Maybe not groebner? any method that works and returns all the 20 solutions.
This is the code in Maple that defines the 5 equations and finds all the solutions:
restart;
eq1:=-18889.48706*qd+467.29186*qb+2982.844413*qd*qc*qb+30136.14351*qc-1115.07186*qc^2*qd-45629.75749*qa*qd*qb-23697.88597*qd^2*qc+4316.66628*qa*qc*qb-15135.14056*qb^2*qc-21851.63993*qa*qd*qc+7902.042467*qb^2*qd-5483.40637*qd^2*qb-11776.45729*qc^2*qb+40621.75090*qa+11348.58548*qd^3-18144.72833*qb^3-19544.23125*qc^3+2*b*qa+32521.65211*qa*qc^2+25623.87525*qa*qd^2+26225.65173*qa*qb^2;
eq2:=-29579.52853*qd+73144.02842*qb+8748.09605*qd*qc*qb+2240.035087*qc+26343.71460*qc^2*qd+2344.316752*qa*qd*qb-25331.91138*qd^2*qc+1444.808993*qa*qc*qb+6290.87549*qb^2*qc+2982.844337*qa*qd*qc+49189.98407*qb^2*qd-29432.25353*qd^2*qb-17559.89085*qc^2*qb-7338.23254*qa+2*b*qb+21944.51817*qd^3-11930.76271*qb^3+2394.88100*qc^3-3970.93290*qa*qc^2+2322.11803*qa*qd^2-23212.08740*qa*qb^2;
eq3:=-3375.795773*qd+2240.03510*qb+7057.67167*qd*qc*qb+56197.14569*qc+52577.03189*qc^2*qd+2982.84431*qa*qd*qb-17977.24342*qd^2*qc-136.341409*qa*qc*qb-23855.89112*qb^2*qc-15689.91200*qa*qd*qc+15299.86799*qb^2*qd-25331.91138*qd^2*qb+11501.30926*qc^2*qb+19564.44679*qa-963.74805*qd^3+658.069730*qb^3-24654.25363*qc^3-16345.90692*qa*qc^2-13126.18932*qa*qd^2-4563.44385*qa*qb^2+2*b*qc;
eq4:=37246.67872*qd-29579.52855*qb-46347.15644*qd*qc*qb-3375.795773*qc-11079.46666*qc^2*qd+12449.76046*qa*qd*qb-24742.88407*qd^2*qc+2982.844222*qa*qc*qb+15299.86800*qb^2*qc-15680.68187*qa*qd*qc-28830.47715*qb^2*qd+20203.79697*qd^2*qb+26343.71462*qc^2*qb-14402.89763*qa-14953.58829*qd^3+31606.58056*qb^3+24809.55728*qc^3-5601.66129*qa*qc^2+16099.39874*qa*qd^2+3415.45305*qa*qb^2+2*b*qd;
eq5:=qa^2+qb^2+qc^2+qd^2-1;
vars:=[b, qa, qb, qc, qd];
polysys:={eq1,eq2,eq3,eq4,eq5};
sols:=CodeTools:-Usage(RootFinding:-Isolate(polysys, vars, output = numeric, method = RS));
These are all the solutions that Maple found (20 solutions):
sols :=
[[b = -6104.435348, qa = -.2144080500, qb = -.2880353207, qc = -.1836576407, qd = -.9150599506],
[b = -12366.14419, qa = -.5402828747, qb = -.3634451559, qc = .1841090309, qd = -.7362784111],
[b = -24212.37926, qa = .2546299302, qb = .6836963191, qc = -.4499174642, qd = -.5150701091],
[b = -23961.92853, qa = .2585879982, qb = .7021280140, qc = -.4278033463, qd = -.5070826324],
[b = -6007.960508, qa = -.3010769760, qb = -.1196072448, qc = .8107192013, qd = -.4876280735],
[b = -22102.25884, qa = .7018528580, qb = -.1525453855, qc = -.5362892523, qd = -.4433128793],
[b = -26791.96626, qa = .3384082623, qb = -.1163579699, qc = -.8287561155, qd = -.4302371112],
[b = -26003.78615, qa = 0.7746836766e-1, qb = -.1265934010, qc = -.9030243373, qd = -.4031374569],
[b = -27290.86178, qa = .3563297191, qb = .8341751821, qc = .4195778650, qd = -0.3369439196e-1],
[b = -39895.97736, qa = -.5758752754, qb = .7983140794, qc = -.1758240948, qd = -0.1217314478e-1],
[b = -39895.97736, qa = .5758752754, qb = -.7983140794, qc = .1758240948, qd = 0.1217314478e-1],
[b = -27290.86178, qa = -.3563297191, qb = -.8341751821, qc = -.4195778650, qd = 0.3369439196e-1],
[b = -26003.78615, qa = -0.7746836766e-1, qb = .1265934010, qc = .9030243373, qd = .4031374569],
[b = -26791.96626, qa = -.3384082623, qb = .1163579699, qc = .8287561155, qd = .4302371112],
[b = -22102.25884, qa = -.7018528580, qb = .1525453855, qc = .5362892523, qd = .4433128793],
[b = -6007.960508, qa = .3010769760, qb = .1196072448, qc = -.8107192013, qd = .4876280735],
[b = -23961.92853, qa = -.2585879982, qb = -.7021280140, qc = .4278033463, qd = .5070826324],
[b = -24212.37926, qa = -.2546299302, qb = -.6836963191, qc = .4499174642, qd = .5150701091],
[b = -12366.14419, qa = .5402828747, qb = .3634451559, qc = -.1841090309, qd = .7362784111],
[b = -6104.435348, qa = .2144080500, qb = .2880353207, qc = .1836576407, qd = .9150599506]]
And this is the code in sagemath that I couldn't solve. Same equations as before, only converted them to rational coefficients using eq_i=P(eq_i). It is stuck in the last line of code (I.variety(RR)).
P.<b, qa, qb, qc, qd>=PolynomialRing(QQ,order='degrevlex')
eq1=-18889.48706*qd+467.29186*qb+2982.844413*qd*qc*qb+30136.14351*qc-1115.07186*qc^2*qd-45629.75749*qa*qd*qb-23697.88597*qd^2*qc+4316.66628*qa*qc*qb-15135.14056*qb^2*qc-21851.63993*qa*qd*qc+7902.042467*qb^2*qd-5483.40637*qd^2*qb-11776.45729*qc^2*qb+40621.75090*qa+11348.58548*qd^3-18144.72833*qb^3-19544.23125*qc^3+2*b*qa+32521.65211*qa*qc^2+25623.87525*qa*qd^2+26225.65173*qa*qb^2
eq2=-29579.52853*qd+73144.02842*qb+8748.09605*qd*qc*qb+2240.035087*qc+26343.71460*qc^2*qd+2344.316752*qa*qd*qb-25331.91138*qd^2*qc+1444.808993*qa*qc*qb+6290.87549*qb^2*qc+2982.844337*qa*qd*qc+49189.98407*qb^2*qd-29432.25353*qd^2*qb-17559.89085*qc^2*qb-7338.23254*qa+2*b*qb+21944.51817*qd^3-11930.76271*qb^3+2394.88100*qc^3-3970.93290*qa*qc^2+2322.11803*qa*qd^2-23212.08740*qa*qb^2
eq3=-3375.795773*qd+2240.03510*qb+7057.67167*qd*qc*qb+56197.14569*qc+52577.03189*qc^2*qd+2982.84431*qa*qd*qb-17977.24342*qd^2*qc-136.341409*qa*qc*qb-23855.89112*qb^2*qc-15689.91200*qa*qd*qc+15299.86799*qb^2*qd-25331.91138*qd^2*qb+11501.30926*qc^2*qb+19564.44679*qa-963.74805*qd^3+658.069730*qb^3-24654.25363*qc^3-16345.90692*qa*qc^2-13126.18932*qa*qd^2-4563.44385*qa*qb^2+2*b*qc
eq4=37246.67872*qd-29579.52855*qb-46347.15644*qd*qc*qb-3375.795773*qc-11079.46666*qc^2*qd+12449.76046*qa*qd*qb-24742.88407*qd^2*qc+2982.844222*qa*qc*qb+15299.86800*qb^2*qc-15680.68187*qa*qd*qc-28830.47715*qb^2*qd+20203.79697*qd^2*qb+26343.71462*qc^2*qb-14402.89763*qa-14953.58829*qd^3+31606.58056*qb^3+24809.55728*qc^3-5601.66129*qa*qc^2+16099.39874*qa*qd^2+3415.45305*qa*qb^2+2*b*qd
eq5=qa^2+qb^2+qc^2+qd^2-1
eq1=P(eq1)
eq2=P(eq2)
eq3=P(eq3)
eq4=P(eq4)
eq5=P(eq5)
I=Ideal(eq1, eq2, eq3, eq4, eq5)
I.groebner_basis('libsingular:std')
I.variety(RR)
Anyone knows how to make it work?
Thanksdavid_cThu, 28 Dec 2017 20:25:53 -0600https://ask.sagemath.org/question/40346/Multivariable equation in multiplicative group Z_phttps://ask.sagemath.org/question/39004/multivariable-equation-in-multiplicative-group-z_p/ I am able to, in wolfram alpha, plug in the equation
> 11=x*(y^119)^149mod151
where all numbers are in Z_151
and wolfram is able to give me a set of non-zero solutions (x,y) that I think satisfy (11*y^119, y)
I have tried using symbolic equations and the sage quickstart for number theory to replicate this functionality, but I am getting stuck on some integer conversion TypeErrors in sage.
I have tried to set it up like:
> x,y = var('x,y');
> qe=(mod(x*(y^119)^149,151)==mod(11,151))
Can someone help me set up this equation, and then solve for all possible non-zero solutions?
THanks!dcoleFri, 29 Sep 2017 08:19:36 -0500https://ask.sagemath.org/question/39004/Solving Logic Problemshttps://ask.sagemath.org/question/33935/solving-logic-problems/ A few years ago I asked [this](http://ask.sagemath.org/question/10068/solving-logic-problems/) question. I have another question along the same lines. Sorry about the <-> notation, I don't know how else to indicate bijection:
children = { Abe, Dan, Mary, Sue }
ages = { 3, 5, 6, 9 }
children <-> ages #bijection - one child per one age
Abe > Dan #Abe is older than Dan
Sue < Mary #Sue is younger than Mary
Sue = Dan + 3 #Sue's age is Dan's age plus 3 years
Mary > Abe #Mary is older than Abe
Can sagemath determine that:
Abe = 5
Dan = 3
Mary = 9
Sue = 6coder0xffMon, 27 Jun 2016 11:06:30 -0500https://ask.sagemath.org/question/33935/using 'solve' with trigonometric functionshttps://ask.sagemath.org/question/31191/using-solve-with-trigonometric-functions/
solve(tan(3*x)==1, x, to_poly_solve='force', explicit_solutions=True)
fails to produce answers while
solve(sin(3*x)==1, x, to_poly_solve='force', explicit_solutions=True)
works as expecteddrJSun, 29 Nov 2015 22:37:07 -0600https://ask.sagemath.org/question/31191/Finding solutions as numerical values rather than equationshttps://ask.sagemath.org/question/29393/finding-solutions-as-numerical-values-rather-than-equations/The output of solve() returns equations. What's the easiest way to "unwrap" these to get numerical values? For instance, solve(x^2-4==0,x) returns [x==-2, x==2]. I'd like to define the associated list [-2,2]. DaveGThu, 03 Sep 2015 09:29:52 -0500https://ask.sagemath.org/question/29393/Why does Sage not find any solutions using .solve()?https://ask.sagemath.org/question/24991/why-does-sage-not-find-any-solutions-using-solve/ Hello everyone,
please consider this attempt to solve simultaneous equations:
P,M,R,rho,kappa,T,F,n = var('P, M, R, rho, kappa, T, F, n')
eqns = [
P==M^2*R^-4,
R^3==M*rho^-1,
T^4==M*kappa*F*R^-4,
F==M*rho*T^n,
P==rho*T,
kappa==rho*T^(-7/2),
n==4
]
eqns
assume(P>0,M>0,R>0,rho>0,T>0,F>0,kappa>0)
sols = solve(eqns,(F,R,T))
sols
(returns [])
I would like to understand why Sage can not arrive at a relation for F,M,T (and n) which I was able to do by hand. Is solve inappropriate for isolating one or more variables from a set of equations?
Thank you for your help!
zuiopTue, 25 Nov 2014 05:56:59 -0600https://ask.sagemath.org/question/24991/solving implicit equationhttps://ask.sagemath.org/question/23494/solving-implicit-equation/ Hi experts!
I want to resolve the equation: $A.sin(x)=B.(C-x)$
where A, C and B are constants, $0\leq x\leq \pi $, $A$ and $B$ are fixed, and $0\leq C\leq \pi $.
I want to obtain the analytic solution, $x=f(C)$, (if exist) for different values of $C$ and if only implicit solution exist, obtain the curve and and table with the values of:
$ x$ vs. $C$
How can I do that?
Waiting for your answer.
Thanks a lot!
mresimulatorSat, 19 Jul 2014 08:53:05 -0500https://ask.sagemath.org/question/23494/Solving logic problemshttps://ask.sagemath.org/question/10068/solving-logic-problems/Given a set of rules, for example: 1. Mary is older than Tom, 2. Tom is older than Sue; Can sage solve the question, "is Mary older than Sue?"
More specifically, is Sage able to do what Prolog does - unification of logic problems? Thankscoder0xffSat, 27 Apr 2013 08:48:08 -0500https://ask.sagemath.org/question/10068/Solving simultaneous boolean algebraic equationshttps://ask.sagemath.org/question/9875/solving-simultaneous-boolean-algebraic-equations/Hi,
I have been searching around for a method of solving and simplifying simultaneous boolean algebraic equations. So far I have found programs that allow the simplification of boolean algebraic expressions but non that can perform the task of solving simultaneous equations. Any help would be greatly appreciated.
Thank youJoshMon, 04 Mar 2013 18:38:12 -0600https://ask.sagemath.org/question/9875/Polynomial identityhttps://ask.sagemath.org/question/9006/polynomial-identity/I'm pretty interested in solving the following kind of problem using Sage: ``Let R be a polynomial ring in, say, x,y,z as variables over a field k. I'd like to find field-elements a,b,c such that
a(x^2+y^2)+b(xy+zx)+c(xyz)==0, if they exist (I know they do)''
so that Sage returns (a,b,c)=(0,0,0). That seems to be an easy matter if one can traduce the polynomial identity into a vector space identity. I proved to be unable to do so.
I've to say that my polynomial identities are quite more cumbersome and include up to 7 variables so working them by-hand is almost impossible in a finite ammount of time or patience.AngelSun, 27 May 2012 04:53:59 -0500https://ask.sagemath.org/question/9006/