Re: [sage-devel] wasm
> > Since I am not a programmer and nobody in my team is a mathematician (so my > > developers don't know Sage), I kindly ask on this list for any hints how we > > could proceed? > Sage mainly uses other open source C libraries to carry out these > factorizations, so you would need to be able to port these to wasm as well. To be clear, porting parts of Sage or the underlying C libraries to WASM/pyodide is a formidable task even for a mathematical programmer. That is why I suggested SymPy instead since it already works in WASM/pyodide. SymPy does not provide factorisation over as many different rings as Sage does but is easy to install and use in WASM via pyodide: https://pyodide.org/en/stable/ You can just micropip.install('sympy') and add a short snippet of Python code to use SymPy from JS: https://pyodide.org/en/stable/usage/loading-packages.html The next release of SymPy (1.13) can make use of python-flint for factorisation of some polynomials using the underlying Flint C library. Also python-flint has been ported to pyodide so it should be possible to use SymPy backed by Flint in WASM: https://pyodide.org/en/latest/usage/packages-in-pyodide.html In future if Sage becomes more usable from WASM/pyodide then I assume that you would be able to use it in the same way via pyodide. As I understand it though it is not possible right now to install enough pieces of Sage in pyodide to be able to factorise a polynomial. I imagine that making that work using Sage would require some significant porting work that is likely out of scope for a team of non-mathematicians who do not know Sage or its dependencies. -- Oscar -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAHVvXxROpXVCCi_k4a%3D6gamq%2B%3DsN1jc1%3DMCfk7NVxYyLVQyybg%40mail.gmail.com.
Re: [sage-devel] wasm
On Tue, Apr 30, 2024 at 3:29 AM 'Doris Behrendt' via sage-devel < sage-devel@googlegroups.com> wrote: > Hi all, > > My team is about to develop a webapp where we want to factor polynomials > with coefficients in ZZ. > We want to offer a dropdown menu where the user can select the base ring > and then the factorisation changes interactively. We use React and > JavaScript and also Web Assembly, e.g. for our Web-OpenSSL here: > https://www.cryptool.org/en/cto/openssl/ > > Sage offers the command change_ring, we did not find a JavaScript Library > that has this functionality. So I thought, perhaps we could look for > solutions where Sage is used together with web assembly. > What base rings do you intend to support? The hard part is the factoring itself, not the change_ring (which basically only requires that you have a reasonable internal representation for that base ring). Reasonable base rings that I can think of: * Finite fields GF(p) with p prime * Finite fields GF(q) with q a prime power * Complex numbers * Real numbers * p-adic numbers for prime p * Number fields * the integers themselves * Z/N for N not prime (there are tricky issues here, since factorization is no longer unique) Sage mainly uses other open source C libraries to carry out these factorizations, so you would need to be able to port these to wasm as well. The underlying C libraries used vary by base field, and include pari, FLINT, NTL and maybe others. You can figure out what is used by each base ring using the get_systems function (note the warning displayed; I haven't recompiled my sage): sage: from sage.misc.citation import get_systems sage: R. = ZZ[] sage: f = (x^4 + 2)*(x^3 - 3) sage: get_systems("factor(f)") :1: UserWarning: get_systems() requires Cython profiling to be enabled, otherwise the results will be very unreliable. Rebuild Sage with the environment variable 'SAGE_PROFILE=yes' to enable profiling. get_systems("factor(f)") ['FLINT'] Finally, you should think about what scope you want to support in terms of degree (and, to a lesser extent, size of coefficients), as well as whether you want to allow non-monic polynomials. Good luck! David After some research I have the impression that there are some proofs of > concept, but there is nothing actively developed? > > Since I am not a programmer and nobody in my team is a mathematician (so > my developers don't know Sage), I kindly ask on this list for any hints how > we could proceed? > > Thanks in advance > Doris > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-devel/08830539-4D13-4E63-80E0-4F1F788B1657%40me.com > . > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAChs6_mC%3Db1sx-ZFgUEZN6Tkkc2Shh08eT98e%2B747%2BY%3D0P8Pew%40mail.gmail.com.
Re: [sage-devel] wasm
Hi Doris, I believe some parts of Sage can be used in WASM (via pyodide) but others cannot so I am not sure if it is possible to get the functionality that you want from Sage in WASM. It is however possible to use SymPy in WASM (via pyodide) as demonstrated here using JupyterLite: https://live.sympy.org/ You should be able to test the following commands in SymPy Live which I assume is the functionality that you are looking for: factor(x**2 + 1, domain=QQ) factor(x**2 + 1, domain=ZZ_I) factor(x**2 + 1, domain=GF(2)) -- Oscar On Tue, 30 Apr 2024 at 08:29, 'Doris Behrendt' via sage-devel wrote: > > Hi all, > > My team is about to develop a webapp where we want to factor polynomials with > coefficients in ZZ. > We want to offer a dropdown menu where the user can select the base ring and > then the factorisation changes interactively. We use React and JavaScript and > also Web Assembly, e.g. for our Web-OpenSSL here: > https://www.cryptool.org/en/cto/openssl/ > > Sage offers the command change_ring, we did not find a JavaScript Library > that has this functionality. So I thought, perhaps we could look for > solutions where Sage is used together with web assembly. > > After some research I have the impression that there are some proofs of > concept, but there is nothing actively developed? > > Since I am not a programmer and nobody in my team is a mathematician (so my > developers don't know Sage), I kindly ask on this list for any hints how we > could proceed? > > Thanks in advance > Doris > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-devel+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-devel/08830539-4D13-4E63-80E0-4F1F788B1657%40me.com. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAHVvXxTCFwv9JhQzcz-KzvZA%3Dx%3D%3DbYj%3DkonhcMBi7%2BWm%3DJ8%3D0w%40mail.gmail.com.