Ask Your Question

Iguananaut's profile - activity

2019-04-24 09:59:05 -0500 answered a question How to increase maxterms for hypergeometric?

By digging into the code and going a little lower-level I was able to do effectively the same thing while close-enough to the lower-level code that it accepted the maxterms argument (of course, you shouldn't have to do this at all and I would consider it a bug):

sage: from mpmath import hyper
sage: from sage.libs.mpmath import utils as mpmath_utils
sage: mpmath_utils.call(hyper, [4.14 + 15*I, -3.14 + 15*I],[1. - 1.12e7*I], -500000, maxterms=10^6)
-608213.273405350 - 24201.2928264098*I

I make no guarantee as to the accuracy of the result or if it's even expected be convergent for the given $a$'s and $b$'s.

2019-04-24 09:44:18 -0500 commented question How to increase maxterms for hypergeometric?

Indeed, that is not a very helpful message. It seems that the underlying low-level sage.libs.mpmath.ext_impl.MPF_hypsum function does accept a maxterms argument, but there is a disconnect that prevents this from being passed to it from the higher-level generic hypergeometric function. I would consider this a bug.

2019-04-24 09:37:50 -0500 commented question How to increase maxterms for hypergeometric?

(please note, when pasting code it's important to be careful of formatting, as some symbols such as * have special meaning in markdown; always format code examples either by indenting a whole line with 4 spaces or putting bits of code in backtick quotes)

2019-04-24 09:36:48 -0500 edited question How to increase maxterms for hypergeometric?

I'm trying to compute a (bunch of) hypergeometric functions for which I get a NoConvergence error

e.g.

hypergeometric([4.14 + 15*I, -3.14 + 15*I],[1. - 1.12e7*I], -500000)

The suggestion of the error message is to try increasing 'maxterms'. However, I don't seem to find a way to do this as e.g.hypergeometric([4.14 + 15*I, -3.14 + 15*I],[1. - 1.12e7*I], -500000,maxterms=10^6) does not work.

(I could be missing something very basic, I'm rather new to sage)

2019-04-24 08:03:34 -0500 answered a question Single quotes vs double quotes

Nope. Use whatever makes sense in the given context. If editing existing code I try to be consistent at least with the surrounding code (if there are already strings in the function, class, or module I'm editing).

When writing new code I always default to single-quotes (why bother using double-quotes when I can save one of my fingers a stroke (at least on a US keyboard double-quotes require holding shift)) unless I'm writing a string that contains an apostrophe in which case I'll use double-quotes.

If you look at the existing Sage sources this is all over the place and there's no standard. Normally that would bother me but when it comes to single vs. double-quotes I think that's so completely subjective that it's impossible and pointless to enforce a standard.

2019-04-24 07:59:18 -0500 commented question Persistent install problems

I'll add "I've tried building...from source as seems to be the advised way". I'm curious who advised that--I would not advise it to anyone who simply wants to use Sage.

2019-04-24 07:56:57 -0500 commented question Persistent install problems

Forget installing the prerequisites, more importantly did you try installing the pre-built binary pakage for Linux? It should work fine on Ubuntu: http://doc.sagemath.org/html/en/insta...

2019-04-24 07:55:32 -0500 received badge  Associate Editor (source)
2019-04-24 07:55:32 -0500 edited question Persistent install problems

I've tried using the repository of ubuntu 18.04 for an older version and failed, and now I've tried building 8.7 (the latest version) from source as seems to be the advised way. Also failed. As a completely new user I'm in no position to deal with this problem:

Error building Sage.

The following package(s) may have failed to build (not necessarily
during this run of 'make all-build'):

The build directory may contain configuration files and other potentially
helpful information. WARNING: if you now run 'make' again, the build
directory will, by default, be deleted. Set the environment variable
SAGE_KEEP_BUILT_SPKGS to 'yes' to prevent this.

Makefile:31: recipe for target 'all-build' failed
make[1]: *** [all-build] Error 1
make[1]: Leaving directory '/home/robert/Sage/sage-8.7'
Makefile:16: recipe for target 'build' failed
make: *** [build] Error 2
2019-04-23 08:40:25 -0500 commented question SageMath 8.6 Notebook server closes instantly when run under Windows 10

This is likely a duplicate of https://ask.sagemath.org/question/460...

2019-04-23 06:47:23 -0500 answered a question Sage Notebook crashes immediately

To follow up on the discussion in the comments, this occurs if for some reason you don't have permission to use the default TCP port (8888) used by the Jupyter Notebook server. Opening the Sage Shell and manually running sage --notebook=jupyter --port=<portnum> where <portnum> can be some large integer (try something larger than 8888, but less than 32000) and it should work depending on your system's configuration.

The fact that this crashes rather than automatically try a different port is a bug: https://trac.sagemath.org/ticket/27715

2019-04-23 06:31:54 -0500 commented question Sage Notebook crashes immediately

Thank you for the confirmation; I'm glad something worked. It's still strange both that default of 8888 did not work, and that it resulted in a crash, rather than just automatically trying a different port. I will try to reproduce the issue if I can; it is possibly a bug in Jupyter (though still strange).

2019-04-23 06:29:58 -0500 commented answer Intersection of polynomial Ideals over $\mathbb{R}$

What do you mean by "I tried to do the same thing using python"? Sage is just a Python library so I'd be curious what you tried and why it didn't work.

2019-04-19 09:56:41 -0500 commented answer Intersection of polynomial Ideals over $\mathbb{R}$

See updated answer, in case it's of any use.

2019-04-18 12:13:32 -0500 commented answer Get output of a .py file in a browser

Are you running a SageMath kernel in the notebook? Or a plain Python kernel?

2019-04-18 12:08:13 -0500 commented question Why does Sage Math crash instantly? / Running .sage files?

"Feel like I downloaded half the Internet..." That's probably part of your problem right there. Without more details we can't possibly know exactly what you did, how your computer is configured, or what the problem is. But usually throwing more downloads at the problem without understanding what you're doing is only likely to break more things and make the problem exponentially more difficult to untangle (for example you wrote "I reinstalled Python"; but Sage includes its own Python interpreter and should have nothing to do with other Pythons on your system). Did you install Sage using the executable installer? If so there's no need for virtualbox in the first place. And sage-8.6.tar.gz is just the source code...

2019-04-18 11:51:12 -0500 commented question flow control in sage notebooks?

A .sage script is just a script. Just code saved to a file line-by-line for convenience so that you don't have to manually re-enter it manually into an interactive prompt. A notebook is another beast entirely. Sage is just Python so anything you can do in Python you can do in a Sage script. What exactly are you trying to do and why? What does "Pretend to be done with the notebook" mean to you, if not exit?

2019-04-18 11:44:37 -0500 commented question Sage Notebook crashes immediately

Nevertheless you could try running with a different port. Try for example sage --notebook=jupyter --port=9999 or something. If that works I can point you to how to save that in the config file to use by default.

2019-04-18 11:40:09 -0500 commented question Sage Notebook crashes immediately

This could happen (although the error message is sadly useless to a non-expert) if notebook is trying to run its server on a port you don't have permission to open. This is strange though because by default the Jupyter notebook runs on port 8888 which is normally permitted for use, and if something else is already using the port the Notebook will just try different ports until it finds one it can use. Is this a computer you have full control over, or is it provided to you by an employer?

2019-04-18 11:31:40 -0500 edited question Sage Notebook crashes immediately

New installation of Windows binaries, version 8.6 (Windows installer 0.4.2), on 64-bit Windows 8.1 system with 8GB of RAM. Clicking on the "SageMath 8.6 Notebook" desktop icon opens a terminal window and displays the message "Please wait while the Sage Jupyter Notebook server starts", but the window closes within 2 or 3 seconds.

Would appreciate any guidance on troubleshooting - happy to study any relevant documentation if someone can point me in the right direction.

When running sage --notebook=jupyter in the shell I get:

[I 17:51:21.659 NotebookApp] Using MathJax: nbextensions/mathjax/MathJax.js Traceback (most recent call last):

File "/opt/sagemath-8.6/src/bin/sage-notebook", line 268, in <module> launcher(unknown)

File "/opt/sagemath-8.6/src/bin/sage-notebook", line 100, in __init__ main(argv)

File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/jupyter_core/application.py", line 266, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)

File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/traitlets/config/application.py", line 657, in launch_instance app.initialize(argv)

File "<decorator-gen-7>", line 2, in initialize
File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error return method(app, args, *kwargs)

File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/notebook/notebookapp.py", line 1629, in initialize self.init_webapp()

File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/notebook/notebookapp.py", line 1408, in init_webapp self.http_server.listen(port, self.ip)

File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/tornado/tcpserver.py", line 142, in listen sockets = bind_sockets(port, address=address)

File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/tornado/netutil.py", line 197, in bind_sockets sock.bind(sockaddr)
File "/opt/sagemath-8.6/local/lib/python2.7/socket.py", line 230, in meth return getattr(self._sock,name)(*args)

socket.error: [Errno 1] Operation not permitted
2019-04-18 11:30:30 -0500 commented question Sage Notebook crashes immediately

Note, you can edit your question to add these details--you don't have to break it up across comments. I will do so now.

2019-04-18 11:26:07 -0500 answered a question Intersection of polynomial Ideals over $\mathbb{R}$

You can check what ring each ideal is in like I5.ring(). In this case I get Symbolic Ring. Presumably it converts to this because Sage treats sqrt(2) as an exact symbolic expression and does not presume to convert it to something less precise even if you use it in an expression with variables like x and y that are in your ring on RR. (In this case I feel like it should be able to do just what you clearly mean, but I'm not expert-enough on this to know if there's really a better way to do this unambiguously). One way (of several) to fix this would be to use the .ideal method on your ring like R.ideal([(x^2+y^2-1),(x*y),(y^3-y)]). This ensures that each of the generators can be converted to an element of your ring. I get:

sage: I5 = R.ideal([x-1/sqrt(2),y-1/sqrt(2)])
sage: I5
Ideal (x - 0.707106781186548, y - 0.707106781186548) of Multivariate Polynomial Ring in x, y over Real Field with 53 bits of precision

And so on.

Unfortunately when I try to take the intersection I get an exception:

TypeError: Cannot call Singular function 'intersect' with ring parameter of type '<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category'>'

If I try things like:

sage: R.<x,y>=PolynomialRing(RR,order='lex',implementation='singular')

I get:

NotImplementedError: polynomials over Real Field with 53 bits of precision are not supported in Singular

which is strange because the Singular docs seem to say so.

I'm not an algebraicist or even a mathematician at all so I'm in over my head, but maybe you can try using a number field ( $\mathbb{Q}$ extended by $\sqrt 2$)? It certainly gives an answer which AFAICT should be just as applicable if $ x $ and $ y $ are real. I'm just not sure if it's the one you're looking for. Perhaps it would help if you gave more details about the specific problem you're trying to solve:

sage: F.<sqrt2> = NumberField(x^2 - 1/2)
sage: F
Number Field in sqrt2 with defining polynomial x^2 - 1/2
sage: R.<x,y> = PolynomialRing(F, order='lex')
sage: R
Multivariate Polynomial Ring in x, y over Number Field in sqrt2 with defining polynomial x^2 - 1/2
sage: I = R.ideal([(x^2+y^2-1),(x*y),(y^3-y)])
sage: I5 = R.ideal([x-1/sqrt2,y-1/sqrt2])
sage: I6 = R.ideal([x+1/sqrt2,y-1/sqrt2])
sage: I7 = R.ideal([x+1/sqrt2,y+1/sqrt2])
sage: I8 = R.ideal([x-1/sqrt2,y+1/sqrt2])
sage: I.intersection(I5, I6, I7, I8)
Ideal (2*y^5 - 3*y^3 + y, 2*x*y^3 - x*y, x^2 + y^2 - 1) of Multivariate Polynomial Ring in x, y over Number Field in sqrt2 with defining polynomial x^2 - 2

Hopefully someone with more expertise in this problem area can give a better answer.

2019-04-18 10:56:28 -0500 commented question Intersection of polynomial Ideals over $\mathbb{R}$

I fixed the block quoting. Not sure why you were having trouble.

2019-04-18 10:55:32 -0500 edited question Intersection of polynomial Ideals over $\mathbb{R}$

I am trying to compute the intersection of Ideals over $\mathbb{R}[x,y]$, but I get problems from the coefficient $\frac{1}{\sqrt{2}}$. This is my code:

R.<x,y>=PolynomialRing(RR,order='lex')

I=Ideal([(x^2+y^2-1),(x*y),(y^3-y)])

I5=Ideal([x-1/sqrt(2),y-1/sqrt(2)])

I6=Ideal([x+1/sqrt(2),y-1/sqrt(2)])

I7=Ideal([x+1/sqrt(2),y+1/sqrt(2)])

I8=Ideal([x-1/sqrt(2),y+1/sqrt(2)])

J=I.intersection(I5,I6,I7,I8)

and this is the error I get:

TypeError: Intersection is only available for ideals of the same ring.

So when I ask if

I5 in R

the answer is False. I also tried with QQbar but same result, can someone explain this? Thanks!

EDIT: I also tried with $\frac{\sqrt{2}}{2}$ instead of $\frac{1}{\sqrt{2}}$ and I get the same error.

2019-04-17 01:19:30 -0500 received badge  Nice Answer (source)
2019-04-15 08:42:59 -0500 commented question flow control in sage notebooks?

You mentioned "sage files" so it's not clear: Do you mean like .sage scripts? Or a Jupyter notebook (that you're executing with "Run All Cells" or something)? In the latter case (which is nothing specific to Sage) there are several ways you could "pause" execution: Have a cell deliberate raise an exception. Put in a time.sleep() (if you just want a temporary delay), put in a call to input(), etc.

2019-04-15 08:26:56 -0500 commented answer multiprocessing.Pool does not work

@danielvolinski It's not broken in windows, but I would recommend running it without maxtasksperchild.

2019-04-15 08:24:51 -0500 commented answer Issue Printing Tables in Jupyter Notebook

The "some hash value" is simply the base-64 encoding of the table. I know images are passed to the notebook in base64 encoding, and for some reason it's (incorrectly?) doing that with the table as well. You can see that by running import base64; print(base64.b64decode("""PGRpdiBjbG..."""))

2019-04-15 07:38:33 -0500 answered a question Why do I get the OSError: [Errno2] when I try to run a .sage file

Sage for Windows runs in a UNIX emulation environment (Cygwin) and by default mounts your Windows home directory (in your case C:\Users\scheu) to /home/sage. So it will be easier to just write sage ~/OneDrive/Desktop/sagetex.sage. There are some known bugs in Python on Cywin where if you pass something that is not recognizable as a UNIX-style absolute path (i.e. starting with / then it will treat it as a relative path and append it to your current directory (which in your case is already /home/sage.

2019-04-15 07:34:43 -0500 commented question How to propose a major change of SageMath?

For that matter I would also like to see matplotlib added as a backend for 3D graphics. Feel free to add more 3D graphics backends--most of the existing ones are rather crufty and outdated and not modern.

2019-04-15 07:32:46 -0500 commented answer loaded file not found

I will add, as a general principle of Windows usage, please do not store personal files under C:\Program Files.

2019-04-15 07:30:42 -0500 answered a question 3d graphics not displayed

The default "jmol" viewer has basically never worked on Windows: see https://github.com/sagemath/sage-wind...

In a future release we hope to make threejs the default but there are still some unresolved issues with threejs: https://trac.sagemath.org/ticket/26410

2019-04-11 07:48:50 -0500 commented question Sage Notebook crashes immediately

What happens if you open the shell and run sage --notebook=jupyter manually? The window should likely stay up and maybe you'll be able to see something more useful.

2019-04-03 05:45:29 -0500 commented question "print" statement vs function for Sage-py3

Personally, I think we should change to using the print function by default on Python 2 as well, but it's hard to make that change without at least slightly breaking users' code. Perhaps we could start issuing a warning and tell users that they should add from __future__ import print_function to their sage startup profiles.

2019-03-26 08:32:17 -0500 received badge  Nice Answer (source)
2019-03-26 08:09:27 -0500 received badge  Necromancer (source)
2019-03-26 07:20:17 -0500 answered a question Sage and pygraphviz help

The interesting part of the error, when running sage -pip install pygraphviz, which the OP omitted, was

running install
Trying dpkg
Failed to find dpkg
Trying pkg-config
Package libcgraph was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcgraph.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcgraph' found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-install-Kp25dp/pygraphviz/setup.py", line 93, in <module>
    tests_require=['nose>=1.3.7', 'doctest-ignore-unicode>=0.1.2', 'mock>=2.0.0'],
  File "/opt/sagemath-8.6/local/lib/python2.7/site-packages/setuptools/__init__.py", line 131, in setup
    return distutils.core.setup(**attrs)
  File "/opt/sagemath-8.6/local/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/opt/sagemath-8.6/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/opt/sagemath-8.6/local/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup_commands.py", line 44, in modified_run
    self.include_path, self.library_path = get_graphviz_dirs()
  File "setup_extra.py", line 162, in get_graphviz_dirs
    include_dirs, library_dirs = _try_configure(include_dirs, library_dirs, _pkg_config)
  File "setup_extra.py", line 117, in _try_configure
    i, l = try_function()
  File "setup_extra.py", line 72, in _pkg_config
    output = S.check_output(['pkg-config', '--libs-only-L', 'libcgraph'])
  File "/opt/sagemath-8.6/local/lib/python2.7/subprocess.py", line 223, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['pkg-config', '--libs-only-L', 'libcgraph']' returned non-zero exit status 1

This is not such a surprise: per the docs PyGraphviz requires graphviz and some of its dependencies to be installed in order to work. It won't be possible to install any arbitrary package from pip if it has external non-Python dependencies that are not included in the Sage distribution. I've actually thought in the past it might be nice if graphviz were an optional package in Sage, but it appears it is not.

I tried installing the Cygwin package for graphviz and there were a couple problems:

  1. The installation was huge, as it as many large dependencies, most of all libcairo which also requires libX11. A lot of this is probably for optional features that graphviz doesn't necessarily need to be compiled with, but the package for Cygwin brings in the kitchen sink.

  2. After doing so, pygraphviz still does not install. It uses pkg-config to locate an installation of libcgraph, but for some reason the libcgraph package for Cygwin does not include a .pc file for it. This should probably be fixed in the package.

I will update this answer later with a better solution once I find it. The most likely solution for now might be to either hand-craft a .pc file for libcgraph, or to install it from source :/

2019-03-26 07:05:00 -0500 commented question Sage and pygraphviz help

FWIW posting a screenshot is not that helpful anyways. If there is a "full error" that you're omitting it's better to just copy/paste the full text of the error. It's okay if it's long.

2019-02-18 05:14:40 -0500 commented question plot3d gives me a blank canvas, no plot

@Emmanuel Charpentier, the purpose of this site is for users to ask questions. I don't think berating them for doing so and telling them to (effectively) RTFD is helpful. I have edited your earlier answer to cut down somewhat on the hostility.

2019-02-18 05:12:40 -0500 commented answer plot3d gives me a blank canvas, no plot

Respectfully, this is not true (and I am saying so only so that no othe readers get confused). While I have not looked at your specific worksheet, 3D plotting works quite well in Sage Worksheets on CoCalc (better actually than on Jupyter Notebooks, generally), including on a free plan, on Chrome, on Linux. Have you tried starting with a more simple example to get that working first? If it still doesn't work--which for you it apparently isn't--there could still be some issue with your configuration to be sure. But in general there is no issue about "computing power" or anything like that.

2019-02-18 05:05:46 -0500 commented question plot3d gives me a blank canvas, no plot

Dear stockh0lm

perusing the worksheet you referred us to demonstratse that you have not taken the time to understand what you are trying to do.

For example, your first two code lines

e_0 = var('e_0', latex_name=r'\varepsilon_0')
e_0 = 8.854 * 10^-12

are contradictory:

  • The first line creates an object representing a symbolic variable, whose name is e_0 and affects it to the Python variable e_0

  • The second line affects the numerical value 8.854*10^-12 to the same Python variable e_0, thus losing any access to your symbolic variable.

2019-02-18 05:04:30 -0500 commented answer Pretty print output in Jupyter notebook

No need necessarily for a non-standard library. On Python 2 you can do:

>>> u'SoluciĆ³n'.encode('ascii', 'xmlcharrefreplace')
'Soluci&#243;n'

Of course in this case you just get a hex escape instead of the more readable entity name, which is not ideal. I think there are ways to get entity name conversions as well. Regardless this shouldn't usually even be necessary, but as you wrote unicode will be handled better in Python 3 across the board.

2019-02-18 04:57:56 -0500 commented answer long traceback when calling solve()

Thank you for reporting the issue!