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, 06 Sep 2021 00:05:30 +0200non coprime moduli are not supported by CRT for IntegerMod_inthttps://ask.sagemath.org/question/58840/non-coprime-moduli-are-not-supported-by-crt-for-integermod_int/ We have
sage: crt([6,0],[10,4])
16
However:
sage: mod(6,10).crt(mod(0,4))
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/rings/finite_rings/integer_mod.pyx in sage.rings.finite_rings.integer_mod.IntegerMod_int.__crt (build/cythonized/sage/rings/finite_rings/integer_mod.c:26973)()
2464 try:
-> 2465 x = (other.ivalue - self.ivalue % other.__modulus.int32) * mod_inverse_int(self.__modulus.int32, other.__modulus.int32)
2466 lift.set_from_int( x * self.__modulus.int32 + self.ivalue )
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/rings/finite_rings/integer_mod.pyx in sage.rings.finite_rings.integer_mod.mod_inverse_int (build/cythonized/sage/rings/finite_rings/integer_mod.c:31277)()
3045 next_t = last_t - q * t
-> 3046 raise ZeroDivisionError(f"inverse of Mod({x}, {n}) does not exist")
3047
ZeroDivisionError: inverse of Mod(10, 4) does not exist
During handling of the above exception, another exception occurred:
ZeroDivisionError Traceback (most recent call last)
<ipython-input-102-08ac2f32f772> in <module>
----> 1 mod(Integer(6),Integer(10)).crt(mod(Integer(0),Integer(4)))
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/rings/finite_rings/integer_mod.pyx in sage.rings.finite_rings.integer_mod.IntegerMod_abstract.crt (build/cythonized/sage/rings/finite_rings/integer_mod.c:19297)()
1643 new_modulus = self.__modulus.int64 * other.__modulus.int64
1644 if new_modulus < INTEGER_MOD_INT32_LIMIT:
-> 1645 return self.__crt(other)
1646
1647 elif new_modulus < INTEGER_MOD_INT64_LIMIT:
/usr/local/SageMath.94/local/lib/python3.9/site-packages/sage/rings/finite_rings/integer_mod.pyx in sage.rings.finite_rings.integer_mod.IntegerMod_int.__crt (build/cythonized/sage/rings/finite_rings/integer_mod.c:27037)()
2467 return lift
2468 except ZeroDivisionError:
-> 2469 raise ZeroDivisionError("moduli must be coprime")
2470
2471
ZeroDivisionError: moduli must be coprime
What's the deal here? Why unlike the first `crt`, the second `crt` (from `sage.rings.finite_rings.integer_mod_ring`) insists on moduli being coprime? Could this restriction be eliminated?Max AlekseyevMon, 06 Sep 2021 00:05:30 +0200https://ask.sagemath.org/question/58840/How 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 10:19:57 +0100https://ask.sagemath.org/question/50197/Random orientation of a graphhttps://ask.sagemath.org/question/42274/random-orientation-of-a-graph/ Is there a command to randomly orient a graph? (no additional edges) not the to_directed commandstandardtrickynessMon, 07 May 2018 02:36:46 +0200https://ask.sagemath.org/question/42274/canonicalize_radical for matrices.https://ask.sagemath.org/question/34302/canonicalize_radical-for-matrices/The following all works
sage: a = sqrt(2)*sqrt(3)*sqrt(6)
sage: v = vector([a])
sage: M = Matrix([v, v])
sage: a.canonicalize_radical()
6
sage: v.canonicalize_radical()
(6)
However the following doesn't work:
sage: M = Matrix([v, v])
sage: M.canonicalize_radical()
EDIT: Could somebody please tell me the right place to ask for "vectorization of canonicalize_radical for matrices" as a new feature of sage?Saul SchleimerTue, 02 Aug 2016 20:46:22 +0200https://ask.sagemath.org/question/34302/Can SAGE compute with ordinals?https://ask.sagemath.org/question/25035/can-sage-compute-with-ordinals/Computing with ordinal expressions like $(\omega^{\omega^2+1}+\omega)^{\omega+2}$ is not very different from handling polynomials, at least if we restrict to ordinals below $\epsilon_0$ written in Cantor Normal Form.
I did not see ordinals mentioned in the manual. Does SAGE know how to do such computations?
I'm interested in basic operations like addition, multiplication, exponentiation, comparison, and it is painful (and risky) to do them by hand.
phsFri, 28 Nov 2014 16:26:23 +0100https://ask.sagemath.org/question/25035/Question about unit conversion and feature request.https://ask.sagemath.org/question/10726/question-about-unit-conversion-and-feature-request/I frequently need to convert units and I find sage very useful in doing that. However, sage does not support conversion to natural units which is frequently used in particle physics. So I have to keep multiplying expressions by $\hbar$ and $c$ in each notebook. Is there a more efficient way to convert quantities from SI to natural units. Does anyone have a idea so that sage can automatically identify the length, mass and time dimension and multiply by appropriate power of $\hbar$ and $c$. Also how difficult would it be to include this feature in sage?
Let me give a brief explanation of what natural units are. All the quantities in natural units are generally expressed a power of energy and $c$ and $\hbar$ are set to one. So one over length is equal to energy etc. ShashankMon, 11 Nov 2013 12:32:52 +0100https://ask.sagemath.org/question/10726/Normalize vector to euclidean unit lengthhttps://ask.sagemath.org/question/9410/normalize-vector-to-euclidean-unit-length/I know I can compute a vector of unit length in a given direction using something like
v = some_vector_computation()
v = v/v.norm()
some_other_computation(v)
On the other hand, the most intuitive way to write this in a single line won't work:
some_other_computation(some_vector_computation().normalize())
This is because of the way `normalize` is defined, which is well documented and has been discussed in [this question](http://ask.sagemath.org/question/726/vectornormalize-function).
So I wonder, is there some other way to write the above in a single line? I'm not interested in solutions which call `some_vector_computation` twice, or have to name the vector, or use some lambda function, or similar hacks. I very much have a method in mind, but anything with similar complexibility and readability would be fine.
I know I could probably add my own method to the vector class at runtime, but modifying sage classes in this way doesn't exactly feel right. And I fear that using a non-standard method might make my code much harder to read, as others would expect being able to reproduce it, but won't be able to if they missed my custom method.
If there is no such method, do you agree that there should be, and that I should file a feature request on the Sage Trac?MvGWed, 10 Oct 2012 09:20:15 +0200https://ask.sagemath.org/question/9410/Filing feature requestshttps://ask.sagemath.org/question/8090/filing-feature-requests/Where can one file a feature request?
And shouldn't that place be linked with a big red flashing banner from the Sage homepage?chaeslocWed, 27 Apr 2011 11:48:16 +0200https://ask.sagemath.org/question/8090/message to another user on AskSagehttps://ask.sagemath.org/question/7965/message-to-another-user-on-asksage/How can I send a message t another user on AskSage?czsanTue, 22 Feb 2011 09:13:50 +0100https://ask.sagemath.org/question/7965/