Ask Your Question

Tony-64's profile - activity

2018-12-30 17:55:09 -0500 received badge  Student (source)
2018-12-30 13:26:20 -0500 received badge  Editor (source)
2018-12-30 13:22:52 -0500 asked a question Sage 8.5 on MacOS10.14 asking for Xcode command line tools

Has anyone seen a pop-up window asking for the Xcode command line tools to be installed after starting sage-8.5-OSX_10.14.2-x86_64.app? The pop-up says they are required to run gcc. I have just installed this version on a clean machine running MacOS 10.14.2 (no Xcode or older sage version installed). Sage appears to run fine without these tools, so for now I am just ignoring the pop up. Which functionality won't be available without having them installed?

BTW: I have observed the same pop up with sage 8.4 on MacOS 10.14. I haven't seen it with earlier sage versions on MacOS 10.13.

BTW2: The log file doesn't mention gcc missing.

UPDATE: Unfortunately, Sage does not run fine. It starts OK and runs relative simple code aw expected. However, when trying to execute more complicated code, Sage unexpectedly throws runtime errors and floating point exceptions. The only way to get Sage running as expected is to install the Xcode command line tools. (No need to install the full Xcode environment).

Perhaps this should be mentioned somewhere in the docs?

2018-11-02 23:09:17 -0500 received badge  Notable Question (source)
2018-11-02 09:35:14 -0500 answered a question problem running Sage on MacOS 10.14, Mojave

Probably a different issue, but each time I start 8.4 on MacOS 10.14 Mojave, I get a pop-up window indicating that the gcc command requires installation of the developer command line tools. However, about half a minute later Sage does start as usual, opening the Jupyter home screen and everything appears to work fine. So far, I ignored the pop-up and did not install the command line tools...

2017-08-23 13:23:48 -0500 received badge  Popular Question (source)
2017-06-19 16:09:17 -0500 commented answer Supposedly real function returning a complex result

Nice trick! It certainly gives me some food for further thought about how to optimize the rest of the application. Obviously, the function f represents only a small part of the stuff I have to visualize ;-)

Anyway, with respect to the question about region_plot(real(g) < 0) failing with TypeError: unable to coerce to a real number, is this a bug? If yes, how and where should I report it?

2017-06-19 15:53:22 -0500 commented answer Supposedly real function returning a complex result

Thanks for the example. Whereas cg calculates about a factor of 5 faster on my machine, region_plot(cg) takes about the same time toe execute as region_plot(g). Apparently, region_plot() doesn't spend the bulk of its time doing the raw calculations.

2017-06-19 15:33:55 -0500 received badge  Supporter (source)
2017-06-16 17:20:31 -0500 asked a question Supposedly real function returning a complex result

Hi all,

I have this function:

f(x, y) = 100*abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

and need to create a plot showing where its derivative with respect to x is negative:

region_plot(diff(f, x) < 0, (x, 0.7, 1.7), (y, 0, 1))

Unfortunately, region_plot fails with a TypeError: unable to coerce to a real number.

Apparently, rounding errors cause the derivative to have a small complex part. Here is some sample code to demonstrate the effect:

var('x, y')
assume(x, 'real')
assume(y, 'real')
assume(x > 0)
assume(y > 0)

f(x, y) = 100*abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

g(x, y) = diff(f, x)

print f
print
print g
print

xv = 1.37
yv = 0.28

print "rational arguments: f(", QQ(xv), ",", QQ(yv), ") =", N(f(QQ(xv), QQ(yv)))
print "rational arguments: g(", QQ(xv), ",", QQ(yv), ") =", N(g(QQ(xv), QQ(yv)))
print

print "float arguments: f(", xv, ",", yv, ") =", f(xv, yv)
print "float arguments: g(", xv, ",", yv, ") =", g(xv, yv)
print

print "float arguments: real(f(", xv, ",", yv, ")) =", real(f(xv, yv))
print "float arguments: real(g(", xv, ",", yv, ")) =", real(g(xv, yv))
print

and its output:

(x, y) |--> 100*abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

(x, y) |--> 50*(x*((245*(40*x + 20*I*y + I)*x^4/(20*x^2 + I*x*(20*y + 1) - 20)^2 - 980*x^3/(20*x^2 + I*x*(20*y + 1) - 20) + 200*x + I)*x/(245*x^4/(20*x^2 + I*x*(20*y + 1) - 20) - 100*x^2 - I*x + 100)^2 + 1/(245*x^4/(20*x^2 + I*x*(20*y + 1) - 20) - 100*x^2 - I*x + 100))/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100) + x*((245*(40*x - 20*I*y - I)*x^4/(20*x^2 - I*x*(20*y + 1) - 20)^2 - 980*x^3/(20*x^2 - I*x*(20*y + 1) - 20) + 200*x - I)*x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100)^2 + 1/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))/(245*x^4/(20*x^2 + I*x*(20*y + 1) - 20) - 100*x^2 - I*x + 100))/abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

rational arguments: f( 137/100 , 7/25 ) = 2.57021481299952
rational arguments: g( 137/100 , 7/25 ) = -8.24860099120441

float arguments: f( 1.37000000000000 , 0.280000000000000 ) = 2.57021481299952
float arguments: g( 1.37000000000000 , 0.280000000000000 ) = -8.24860099120440 + 1.68733316297436e-15*I

float arguments: real(f( 1.37000000000000 , 0.280000000000000 )) = 2.57021481299952
float arguments: real(g( 1.37000000000000 , 0.280000000000000 )) = -8.24860099120440

Clearly, as long as the arguments x and y are rationals, the derivative of f (g in the sample code) yields a real number. However, when the arguments are given as floating point values, in many cases the result has a small imaginary component. By the way, f itself always yields a real number.

Whereas it is possible to take this component away by taking the real part, this work-around apparently does not help in the region_plot function: region_plot(real(g) < 0, (x, 0.7, 1.7), (y, 0, 1)) fails with the same TypeError: unable to coerce to a real number.

Why doesn’t this work-around work? Is it a Sage bug?

Anyway, the only feasible work-around that I have been able to find so far is to replace the abs function with my_abs(z) = sqrt(real(z)^2 + imag(z)^2). Here is the code

my_abs(z) = sqrt(real(z)^2 + imag(z)^2)

f(x, y) = 100*my_abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

g(x, y) = diff(f, x)

print f
print
print g
print

xv = 1.37
yv = 0.28

print "rational arguments: f(", QQ(xv), ",", QQ(yv), ") =", N(f(QQ(xv), QQ(yv)))
print "rational arguments: g(", QQ(xv), ",", QQ(yv), ") =", N(g(QQ(xv), QQ(yv)))
print

print "float arguments: f(", xv, ",", yv, ") =", f(xv, yv)
print "float arguments: g(", xv, ",", yv, ") =", g(xv, yv)
print

print "float arguments: real(f(", xv, ",", yv, ")) =", real(f(xv, yv))
print "float arguments: real(g(", xv, ",", yv, ")) =", real(g(xv, yv))
print

print "time required to calculate g:"
timeit('g(xv, yv)')
print

and its output:

(x, y) |--> 100*sqrt(10000*(49*x^7/((24010000*x^12/(400*x^4 + 400*x^2*y^2 + 40*x^2*y - 799*x^2 + 400)^2 + 2401000*x^10*y/(160000*x^8 + 320000*x^6*y^2 + 160000*x^4*y^4 + [... output truncated ...]


(x, y) |--> 200*(5000*(49*x^7/((24010000*x^12/(400*x^4 + 400*x^2*y^2 + 40*x^2*y - 799*x^2 + 400)^2 + 2401000*x^10*y/(160000*x^8 + 320000*x^6*y^2 + 160000*x^4*y^4 + [... output truncated ...]

rational arguments: f( 137/100 , 7/25 ) = 2.57021481299952
rational arguments: g( 137/100 , 7/25 ) = -8.24860099120441

float arguments: f( 1.37000000000000 , 0.280000000000000 ) = 2.57021481299952
float arguments: g( 1.37000000000000 , 0.280000000000000 ) = -8.24860099120455

float arguments: real(f( 1.37000000000000 , 0.280000000000000 )) = 2.57021481299952
float arguments: real(g( 1.37000000000000 , 0.280000000000000 )) = -8.24860099120455

time required to calculate g:
5 loops, best of 3: 43.5 ms per loop

However, this work-around unfortunately yields a substantial performance loss (the calculation of g using the built-in abs function takes about 20 ms). Since I have to calculate this function—and several even more complex ones—many times, this performance decrease by 50% does have a sever impact.

An alternative work-around that has been suggested elsewhere in this forum is to make use of the lambda construct, as in region_plot(lambda x, y: g(x, y) < 0, (x, 0.7, 1.7), (y, 0, 1)), where g is the based on the built-in abs function.

However, this latter work-around is much worse than the above mentioned work-around: the region_plot takes much longer than doing a region_plot without the lambda construct (but using the my_abs function); about 210 seconds versus 5 seconds on my machine (2012 iMac)! Moreover, the resulting plot is very coarse and grainy, rather than nicely smooth.

Here is the code to create the plots:

var('x, y')
assume(x, 'real')
assume(y, 'real')
assume(x > 0)
assume(y > 0)

f(x, y) = 100*abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

g(x, y) = diff(f, x)

# g based on the built-in abs function:
P = region_plot(lambda x, y: g(x, y) < 0, (x, 0.7, 1.7), (y, 0, 1), plot_points=100)
P.show()


my_abs(z) = sqrt(real(z)^2 + imag(z)^2)

f(x, y) = 100*my_abs(x/(245*x^4/(20*x^2 - I*x*(20*y + 1) - 20) - 100*x^2 + I*x + 100))

g(x, y) = diff(f, x)

# g based on the my_abs function
P = region_plot(g(x, y) < 0, (x, 0.7, 1.7), (y, 0, 1), plot_points=100)
P.show()

Anyone having suggestions for a better solution?

2017-05-01 12:07:21 -0500 commented answer Sage-7.6.app on macOS 10.12 Sierra not running

Yes, I am certainly willing to help development. Can I run it alongside my current 10.12.3 installation, or do I have to remove that one first? Anything special you'd like me to report on?

BTW: I have manually created the ~/Documents/Sage folder, logged out and backing my account, waited a couple of days :-), fired up the app, clicked start Jupyter, and guess what? After a few seconds a browser tab opens showing Jupyter up and running. Hooray!

2017-04-29 13:17:12 -0500 commented answer Sage-7.6.app on macOS 10.12 Sierra not running

One step further on the iMac. After disabling the anti-virus software and removing anaconda from the path, the 10.12.3 dmg installs fine. The app runs as expected and fires up the old notebook interface. However, the Jupyter interface won't start. There is not even a sign in the sage.log file that it is trying to start Jupyter (unlike on the MBP). Puzzling...

2017-04-25 15:48:38 -0500 commented answer Sage-7.6.app on macOS 10.12 Sierra not running

Yes, I am running anaconda as well, both on the MBP and on the iMac. I don't have acces the iMac right now (travelling), but will check it this weekend to see what's different from the MBP. Trying the 10.11.6 dmg may not yield much if the above issue is an adverse interaction with another Python.

The anti-virus thing caught me unawares. I should have thought of that much earlier...

2017-04-25 08:23:28 -0500 received badge  Self-Learner (source)
2017-04-25 08:23:28 -0500 received badge  Teacher (source)
2017-04-25 08:12:14 -0500 answered a question Sage-7.6.app on macOS 10.12 Sierra not running

It's running on the MBP now. Apparently the F-Secure anti-virus software running on the machine doesn't like Sage and blocks it's execution (even though it doesn't say so in its logs). Removing the previous 10.12.3 installation and reinstalling if from scratch with F-Secure disabled solved the issue. Anyway, the next thing to resolve is how to automatically start the jupyter interface rather than the old notebook, but I guess that's another thread...

BTW, the iMac had the same issue. It starts the app now, but unfortunately doesn't like the 10.12.3 dmg. When starting the app, it opens two terminal windows, one of which shows the error messages copied below. I'll try the 10.11.6 dmg later.

10.12.3 dmg error message on a late 2012 iMac:

iMac-of-Tony:~ tony$ '/Applications/SageMath-7.6.app/Contents/Resources/sage/sage' --notebook=sagenb
Fatal Python error: Py_Initialize: unable to load the file system codec
  File "/Applications/SageMath-7.6.app/Contents/Resources/sage/local/lib/python/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax

Current thread 0x00007ffff04043c0 (most recent call first):
/Applications/SageMath-7.6.app/Contents/Resources/sage/sage: line 130: 11912 Abort trap: 6           "$SAGE_ROOT/relocate-once.py"
Traceback (most recent call last):
  File "/Applications/SageMath-7.6.app/Contents/Resources/sage/src/bin/sage-notebook", line 7, in <module>
    import argparse
  File "/Applications/SageMath-7.6.app/Contents/Resources/sage/local/lib/python/argparse.py", line 85, in <module>
    import collections as _collections
  File "/Applications/SageMath-7.6.app/Contents/Resources/sage/local/lib/python/collections.py", line 21, in <module>
    from operator import itemgetter as _itemgetter, eq as _eq
ImportError: dlopen(/Applications/SageMath-7.6.app/Contents/Resources/sage/local/lib/python2.7/lib-dynload/operator.so, 2): Symbol not found: __PyUnicodeUCS4_AsDefaultEncodedString
  Referenced from: /Applications/SageMath-7.6.app/Contents/Resources/sage/local/lib/python2.7/lib-dynload/operator.so
  Expected in: flat namespace
 in /Applications/SageMath-7.6.app/Contents/Resources/sage/local/lib/python2.7/lib-dynload/operator.so
iMac-of-Tony:~ tony$
2017-04-24 10:07:03 -0500 commented question Sage-7.6.app on macOS 10.12 Sierra not running

Yes, I did move it from the dmg. When I open a terminal session and run /Applications/Sage-7.6.app/sage, eventually the sage: prompt appears and the browser-based notebook interface can be started by means of the notebook() command. It's ugly, but it works. The iMac is late 2012 and the MBP is early 2015, so not that old I would say...

2017-04-22 20:00:52 -0500 asked a question Sage-7.6.app on macOS 10.12 Sierra not running

Does the native app version of Sage need any changes to the system settings on macOS 10.12.3 to run?

After installing from sage-7.6-OSX_10.12.3-x86_64.app.dmg and launching the app from the launchpad, if first just sits there checking 'Sagemath-7.6' for tens of minutes. Then it complains about permissions (unknown publisher). After giving confirmation that it is OK to run the app, nothing happens anymore. The app get 0.0% CPU cycles.

It's probably something obvious, I haven't been able to figure it out yet.

(BTW: Both an iMac running 10.12.4 and an MBP running 10.12.3 show the same behaviour)