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.Wed, 28 Aug 2019 05:25:45 -0500Finitely presented group simplificationhttp://ask.sagemath.org/question/47636/finitely-presented-group-simplification/Hi! I have a bunch of finitely presented groups, with many generators and relations. I know that all of these are in fact cyclic groups, but many times using the "simplified()" function, I get a simpler presentation with 2 generators, rather than only one. The following is one example:
G.<x0,x5> = FreeGroup()
H =G/[(x5^-1*x0)^2*x5^-3, (x0^-1*x5^-1)^2*x0^-2*x5*x0^-1]
H is in fact just Z/27Z. Is there another way to simplify these presentations, in order to get a minimal one?
The problem here is that I do not only need to identify the specific group, but also to recover the image of the previous generators in the simplified one (as done by the simplification_isomorphism() function).danieleCWed, 28 Aug 2019 05:25:45 -0500http://ask.sagemath.org/question/47636/Solving an ODE and simplifying the resulthttp://ask.sagemath.org/question/46517/solving-an-ode-and-simplifying-the-result/ I'm interested in solving the differential equation $$3 h' + 3 h^2 = c_1,$$ where $c_1$ is a positive real number.
var('t')
var('c1', latex_name=r'c_1')
h = function('h')(t)
eq = -3*h^2 + c1 - 3*diff(h, t)
eq_sol = desolve(eq, h, ivar=t, contrib_ode=True)
The above code works, but it's not solved explicitly for $h$, so
h_sol = solve(eq_sol, h)
h_sol = h_sol[0]
h_sol
This gives something like $$h\left(t\right) = \frac{\sqrt{3} \sqrt{c_{1}} {\left(e^{\left(\frac{2}{3} \, \sqrt{3} C \sqrt{c_{1}} + \frac{2}{3} \, \sqrt{3} \sqrt{c_{1}} t\right)} + 1\right)}}{3 \, {\left(e^{\left(\frac{2}{3} \, \sqrt{3} C \sqrt{c_{1}} + \frac{2}{3} \, \sqrt{3} \sqrt{c_{1}} t\right)} - 1\right)}},$$
in sage notation (non-LaTeX) it starts like
h(t) == 1/3*sqrt(3)*sqrt(c1)* ...
**Question 1:** Is there a way to allocate to the solution (i.e. `h_sol`) the RHS of the above? without the `h(t) == ` part.
I had to set by hand (it is ease, but it would be nice to automatize the allocation)
var('C') # the integration constant introduced above
h_sol = 1/3*sqrt(3)*sqrt(c1)* ...
Then, by simply looking at the solution it is clear that it can be simplified. I tried things like
h_sol = h_sol.canonicalize_radical()
h_sol = h_sol.collect_common_factors()
h_sol = h_sol.simplify_rectform(complexity_measure = None)
but none of them returns the expected result, which could be obtained from Mathematica's kernel
mathematica("DSolve[3*h'[t] + 3*h[t]^2 == C[1], h[t], t]//FullSimplify")
$$ \sqrt{\frac{c_1}{3}} \tanh\left( \sqrt{\frac{c_1}{3}} (t - 3 c_2) \right) $$
**Question 2:** How could the expression `h_sol` be manipulated to obtain the hyperbolic tangent?DoxTue, 14 May 2019 02:41:24 -0500http://ask.sagemath.org/question/46517/How to get latex expression in exponential notation?http://ask.sagemath.org/question/35753/how-to-get-latex-expression-in-exponential-notation/I need a latex representation of equations in exponential notation, e.g. units of J/K should be represented as:
J K^{-1}
Is there a way to force sage to return such a result? Here is an example:
var('J K ')
unit1 = J/K
latex(unit1)
returns:
\frac{J}{K}
I tried expand(), but it does not seem to expand fractions to their exponential representation.stanSun, 27 Nov 2016 06:47:22 -0600http://ask.sagemath.org/question/35753/Constant coefficient of Laurent Polynomialshttp://ask.sagemath.org/question/35746/constant-coefficient-of-laurent-polynomials/I am looking for the constant coefficient of a Laurent polynomial, the issue I am having is that sage is not simplifying the polynomial.
An example:
a = var(",".join( "a%i" %i for i in range(0, 6)))
f = x*y + 1.00000000000000*a6*x + 1.00000000000000*a4*y + x*y^-1 + x^-1*y + 1.00000000000000*a3*y^-1 + 1.00000000000000*a1*x^-1 + x^-1*y^-1
Then I ask
f/(x^1*y^0) # (The powers have to be in this way, just from the context of the work I am doing)
and it outputs:
1.00000000000000/x*x*y + 1.00000000000000*a6/x*x + 1.00000000000000*a4/x*y + 1.00000000000000/x*x*y^-1 + 1.00000000000000/x*x^-1*y + 1.00000000000000*a3/x*y^-1 + 1.00000000000000*a1/x*x^-1 + 1.00000000000000/x*x^-1*y^-1
Now when I ask for the constant coefficient of this LP it tells me its 0 when it is a6.
How can I fix this.
Thanks in advanceEd CalSat, 26 Nov 2016 17:35:11 -0600http://ask.sagemath.org/question/35746/Factor out rootshttp://ask.sagemath.org/question/26737/factor-out-roots/
sage: var('a, b, c, d')
sage: trm = 3*(a+b*sqrt(2))+(1+2*sqrt(2))*(c + d*sqrt(2))
sage: trm.expand()
3*sqrt(2)*b + 2*sqrt(2)*c + sqrt(2)*d + 3*a + c + 4*d
What could I do if I wanted a result like:
(3*b + 2*c + *d)*sqrt(2) + 3*a + c + 4*d
And similar, if there were other roots like `sqrt(5)`, `7^(1/3)` etc.
Thank you!OderynWed, 06 May 2015 08:43:40 -0500http://ask.sagemath.org/question/26737/working on part of an expressionhttp://ask.sagemath.org/question/26397/working-on-part-of-an-expression/ I came across a complicated expression containing cos(4*t). I wanted to change it to 1-sin(2*t)^2. The tools are
trig_reduce, trig_expand, and trig_simplify. One of them expresses everything in trig functions of t and the other
two are useless. And all three will work on the entire expression, not just on one part. So this is a very general
question: how can I get sage to do something to just one part of an expression, rather than the whole expression?
(I suppose I could extract the part, work on it, and then substitute the result back in, but that would be difficult!)
And even on a standalone basis, I don't know how to change cos(4*t) to 1-sin(2*t)^2.beesonTue, 31 Mar 2015 10:12:14 -0500http://ask.sagemath.org/question/26397/simplifying expressions in GF(2)http://ask.sagemath.org/question/25838/simplifying-expressions-in-gf2/ Hi guys,
I know that for a variable $x$ in $GF(2)$, $x^2 = x$, and $2x=0$.
How do I simplify a polynomial expression in $GF(2)$ in the Sage interface?
For example, I should obtain
$$(a+b+1)^2=a^2+b^2+1+2a+2b+2ab=a+b+1$$
freako89Sun, 15 Feb 2015 20:45:32 -0600http://ask.sagemath.org/question/25838/Declaring variable to be in a particular field/ring/grouphttp://ask.sagemath.org/question/25037/declaring-variable-to-be-in-a-particular-fieldringgroup/Is it possible to have Sage symbolically simplify expressions involving variables subject to the assumption that the variables take values in a defined domain (field/ring/group/etc)?
The closest I've gotten is to declare a dummy polynomial ring over my domain of interest so that its variable has some notion of the domain, e.g.:
<pre>Z3=Integers(3)
Dummy.<x> = PolynomialRing(Z3)
3*x</pre>
evaluates to "0" as I'd expect, but sage fails to simplify "x^3" to "x", which ISTM should be doable if it really understood that x is a variable in Z/3Z.
Related things I've found in my searches that haven't panned out:<br/>
1. var('x', domain=*foo*) -- apparently *foo* can only be one of real/complex/positive (where I'd like to be able to say 'Z3' in the example above)<br/>
2. assume('x is Z3') - doesn't seem to have any effect.a1846583Fri, 28 Nov 2014 10:44:44 -0600http://ask.sagemath.org/question/25037/Auto-substitute complex term to ease numeric evaluationhttp://ask.sagemath.org/question/10427/auto-substitute-complex-term-to-ease-numeric-evaluation/I have a very large symbolic term (mainly composed of sums, products and divisions) and, using substitutions, I want to reformulate it in a way that avoids repetitions and thus can be evaluated using less arithmetic operations.
For example, if I have a term like
X = (d*(a-b)/(1 + a-b))^2 + d*(a-b)/(1 + a-b) + exp(d*(a-b)/(1 + a-b)) + a-b,
I want a function that returns something like:
S1 = a-b
S2 = d*S1/(1+S1)
X = S2^2 + S2 + exp(S2) + S1
Giving me instructions how to more efficiently calculate X: First calculate S1, then S2 using S1 and finally X using S1 and S2.
My actual problem is much nastier and I do not need optimal or near-optimal results, but any way of automatising such substitutions.WrzlprmftWed, 07 Aug 2013 05:55:00 -0500http://ask.sagemath.org/question/10427/Very basic simplification questionhttp://ask.sagemath.org/question/10135/very-basic-simplification-question/I know what the answer is, however I'm trying to work through the process of this basic question. The equation is below:
(3 + x)/x^2
To simplify can't you simplify it to by simplifying the exponents:
3/x
However if you were to plug a constant into the original variable such as 2, you would get a different result than if you simplified it.
1. x = 2 | (3 + x)/x^2 = 5/4
2. x = 2 | 3/2
It's been a while since I went through algebra, so I'm sure there's an easy answer, I'm just wanting to know where I'm not thinking it through properly.
Thanks!jordanhudgensSat, 18 May 2013 07:27:05 -0500http://ask.sagemath.org/question/10135/simplify equationshttp://ask.sagemath.org/question/9690/simplify-equations/Hello,
i'm trying to simplify equations "eq" (http://pastie.org/5624251) under two assumptions. The result is supposed to be (1+a*x+b*y+c*z) / 2
sage: var('x,y,z,a,b,c')
(x, y, z, a, b, c)
sage: (x*x+y*y+z*z == 1).assume()
sage: (a*a+b*b+c*c == 1).assume()
sage: eq = abs( sqrt((1+c)*(1+z)) / 2 + (1-c)*(1-z)*sqrt((1+c)*(1+z)) / (2*(a-i*b)*(x+i*y)) ) ^ 2
sage: eq.simplify_full()
(I*((-8.0*I*a*b - 8.0*b^2)*c - 8.0*I*a*b - 8.0*b^2)*x*y*z + 4*(c^3 - c^2 - c + 1)*z^3 + 8.0*I*b*c^2*x + 8.0*I*b*x*z^2 + I*((-8.0*I*a*b - 8.0*b^2)*c - 8.0*I*a*b - 8.0*b^2)*x*y + (-(4.0*a^2 - 8.0*I*a*b - 4.0*b^2)*c - 4*a^2 + 8.0*I*a*b + 4.0*b^2)*y^2 + ((4.0*a^2 - 8.0*I*a*b - 4.0*b^2)*c + 4*a^2 - 8*I*a*b - 4.0*b^2)*x^2 - (4*c^3 - ((8*a - 8*I*b)*c^2 - 8*a)*x - ((8*I*a + 8.0*b)*c^2 - 8*I*a - 8.0*b)*y - 4*c^2 - 4*c + 4)*z^2 + 4*c^3 + (-8.0*a*c^2 + 8*a - 8*I*b)*x + ((-8*I*a - 8.0*b)*c^2 + ((8*I*a^2 + 8.0*a*b)*c + 8*I*a^2 + 8.0*a*b)*x + 8*I*a + 8.0*b)*y + (((8*I*a^2 + 8.0*a*b)*c + 8*I*a^2 + 8.0*a*b)*x*y + (-(4.0*a^2 - 8.0*I*a*b - 4.0*b^2)*c - 4*a^2 + 8.0*I*a*b + 4.0*b^2)*y^2 + ((4.0*a^2 - 8.0*I*a*b - 4.0*b^2)*c + 4*a^2 - 8*I*a*b - 4.0*b^2)*x^2 - 4*c^3 + 4*c^2 + 4*c - 4)*z - 4*c^2 - 4*c + 4)/(-32.0*I*a*b*x^2 + 32.0*I*a*b*y^2 - 32.0*I*b^2*x*y + 16*(a^2 - b^2)*x^2 + (32*I*a^2 + 64.0*a*b)*x*y - 16*(a^2 - b^2)*y^2)
What am I doing wrong?rdmadss1Fri, 04 Jan 2013 13:06:15 -0600http://ask.sagemath.org/question/9690/