Ask Your Question

gg@g's profile - activity

2024-01-27 01:40:37 +0200 received badge  Famous Question (source)
2021-05-18 02:06:24 +0200 received badge  Notable Question (source)
2021-03-23 12:11:11 +0200 received badge  Nice Answer (source)
2021-03-23 12:11:09 +0200 received badge  Good Question (source)
2021-03-23 12:11:06 +0200 received badge  Popular Question (source)
2020-10-14 14:05:17 +0200 asked a question how to join functions with an intermediate fit to obtain smooth derivatives

I want to modify a function which contains a pole for numerical simulations, e.g. limit it to a maximum value around the pole. My idea is to connect two original functions f1 and f2 (e.g. one with pole and one constant) with an intermediate fit function between two x values x1 and x2. The fit function should continue the two original functions between x1 and x2 as well as their first two derivatives, and it should be monotonic in this range.

I found some hints how to fit (x,y) points with a lagrange_polynomial or find_fit to match a given function template, but these approaches do not seem to be extendable to fit the derivatives at the same time, e.g. fit points from (f1,f1', f1'') and (f2,f2',f2''). At least this seems to me what needs to be done. Is this a feasible approach, and how can it be solved?

Constructing a set of splines between x1 and x2 might be an alternative, but the implementation in the simulation system would be more complicated compared to a single polynomial. I guess 3 spline segments might be sufficient to create a "connector template", but a subsequent fit of a single function to this set of splines (to obtain a simpler implementation for the simulation) would probably violate the continuity of the derivatives, and I worry that construction of suitable intermediate points to obtain a monotonic fit function is another complication. Thus, again, this seems to result in a general multi-function fitting problem to which a genius may have found a general approach already?

2020-09-21 19:45:02 +0200 commented answer how to move from notebook() to jupyter

Thanks! I couldn't see the buttons on the left side with a white on black layout. I would have never noticed...

I add that the converted notebooks should be marked "Trusted" after opening them for the first time. Then they mostly work as before with very few adjustments (my stuff is from v6.5 and older). Happy to have this tool :-)

2020-09-21 19:27:07 +0200 received badge  Scholar (source)
2020-09-18 19:06:16 +0200 received badge  Nice Question (source)
2020-09-18 19:05:47 +0200 received badge  Teacher (source)
2020-09-18 19:05:47 +0200 received badge  Self-Learner (source)
2020-09-18 17:49:35 +0200 answered a question how to move from notebook() to jupyter

Thanks for these Tips! Initially it seemed that 9.1 doesn't have the export function because a) I again have to specify --ip 127.0.0.1 to get rid of an error message but then b) there is nothing for the browser. After struggling with v8.9 (compilation failed on my openSuse, but the Ubuntu tarball did it) I realized that the behaviour is just the same.

That said, it seems to be a command line tool with little documentation on the options.

./sage -n export --ip=127.0.0.1 --list

creates a list of notebooks, e.g.

Unique ID       | Notebook Name
-------------------------------------------------------------------------------
_sage_:0        | Welcome to the Sage Tutorial! -- Sage Tutorial v5.11

This works in 8.9 and 9.1 (even if compiled for Python3). From there I'm digging deeper, there seems to be no "batch" conversion. Following https://ask.sagemath.org/question/41680/best-way-to-convert-many-notebooks-from-sagenb-to-jupyter/ I did this for a batch conversion of all notebooks, creating descriptive names:

# go to a new space
mkdir ~/.sage/jupyter_notebooks 
cd ~/.sage/jupyter_notebooks 
# make a list of IDs and worksheet names
/opt/sage-9.1/sage -n export --ip=127.0.0.1 --list > sagenb_list.txt
# prepare the arguments for the conversion
cat sagenb_list.txt | tail -n +3 | awk '{$2="" ; print "--ipynb=\""$0".ipynb\" "$1}' > map_list.txt
# run the conversion (sequentially, use)
cat map_list.txt |xargs -L 1 /opt/sage-9.1/sage -n export

And then started the notebook server with

/opt/sage-9.1/sage -n jupyter --notebook-dir="~/.sage/jupyter_notebooks" --ip=127.0.0.1

to view it in the browser at http://127.0.0.1:8888/tree. From my example above, the name of the exported notebook changed to

_sage_:0 Welcome to the Sage Tutorial! -- Sage Tutorial v5.11.ipynb

Magically I can even open them, but handling seems to be a bit different as well...I'll figure it out. Thanks again! :-)

2020-09-15 21:14:22 +0200 asked a question how to move from notebook() to jupyter

Seems that I missed a lot since I used sage the last time. I had to learn the hard way that notebook() will not work anymore in 9.1. With some hickups I managed to start jupyter using

sage -n jupyter --ip 127.0.0.1

but the main jupyter page leaves me clueless. It shows a listing of my sage root directory. How to configure it to look at ~/.sage (which is outside of this tree)? And, asking in advance, how to use my old notebooks? It seems that the notebook() function has changed to export something (for jupyter?), but instead it just complains about "ValueError: History is empty, cannot export". I moved my old .sage dir, the message is not related to the old content.

I didn not find suitable documentation. Where can I find a guide how to move from sageNB to jupyter and how to use it?

thanks

2020-09-15 19:45:41 +0200 answered a question Sage on Jupyter - socket error

Thanks a lot for the note to start it with sage -n jupyter --ip=127.0.0.1

I got "OSError: [Errno 99] Cannot assign requested address", but the same trick worked!

I compiled sage 9.1 with both python 2 and 3, both produce the same error messages. First I had to stumble into the fact that sagenb has been replaced with jupyter - by accident, the transition does not seem to be well documented. Then I found similar hints about the IP on non-sage places which didn't help me since sage -h or -advanced does not list this --ip option.

2020-04-19 02:08:20 +0200 received badge  Student (source)
2020-04-19 00:44:46 +0200 received badge  Notable Question (source)
2020-04-19 00:44:46 +0200 received badge  Famous Question (source)
2020-04-19 00:44:46 +0200 received badge  Popular Question (source)
2014-10-03 14:04:01 +0200 commented question how to get a log distribution on the x-axis of a semilogx plot?

A combination of adaptive recursion and huge points seems to be slightly faster. However, I wouldn't call this a solution yet. Unless you know how the plot should look like it's hard to tell if points are sufficient or not. Extending the x-range a few more decades is enough to run into new problems. Only increasing adaptive_recursion does not work because it seems to have a limit of 100 (testing with sage 6.3 now). My starting point for now is plot(abs(A(w)),1,1e10,scale='semilogx',adaptive_recursion=100,plot_points=1000)

2014-09-27 16:46:37 +0200 commented question how to get a log distribution on the x-axis of a semilogx plot?

a) wlist=[10^(_/3) for _ in 3*[1..log(1e7,10)]] would create the typical 1/2/5/10 distribution. I don't see a way to pass this to the plot function, though. b) abslist=[abs(A(_)) for _ in wlist] would calculate the results to be plottod with p=list_plot(zip(abslist, wlist)) in linear scale with log distribution of x-points. However, setting this plot to logscale with p.show(scale=('semilogx',10)) doesn't seem to be possible.

2014-09-27 15:34:24 +0200 received badge  Editor (source)
2014-09-27 15:32:32 +0200 asked a question how to get a log distribution on the x-axis of a semilogx plot?

I tried to plot some frequency response. In the most simple case this may look like A(w). I can make plots using different statements like plot_semiogx, or plot(...,scale='semilogx') etc, but the results look odd. Apparently the internally generated points on the x-axis lways have a linear distribution. Only forcing an exaggerated number of points (e.g. plot_points=100000) results in a correct graph. I didn't find a better solution. I think the plot command should distribute the x-points in a log-fashion automatically for semilogx and loglog plots, thus I consider this a bug. I'm using sage 6.2 right now. Any ideas how to workaround/fix this?

w = var('w')
A0=1e7
w0=100
A(w)=A0*(1/(1+i*w/w0))
plot_semilogx(abs(A(w)),1,1e7)