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.Fri, 18 Jun 2021 19:50:09 +0200How to zoom in on saved plot?https://ask.sagemath.org/question/57620/how-to-zoom-in-on-saved-plot/Hello all!
I'm trying to make some animations for a class I'm teaching, but, while I've been able to have them animate the way I want, when I save the animation the objects are really small compared to the size of the file. For example, this is what one frame of the output looks like: imgur.com/a/BURrSXI; but I'd rather have it look like this: imgur.com/a/l3TVDGK. Is there any way I can control the output of Sage so that the objects take up more of the animation/image? Thank you!
Edit:
If it helps, I am making my animations with parametric_plot3d and Sphere's. I have a graphics object G that I am adding all of my spheres and parametric plots to. Then, I'm saving that graphics object via the .save method.
num_frames_graph = 100
frames_list_graph = [0]*10
frames_list_graph.extend(list(range(0,num_frames_graph)))
frames_list_graph.extend([num_frames_graph for i in range(0,15)])
frames_list_graph.extend(frames_list_graph[::-1])
graph_frames = [graph_projection(RDF(time / num_frames_graph)) for time in frames_list_graph]
os.system("mkdir graphFrames")
for i,frame in enumerate(graph_frames):
frame.save(filename="graphFrames/graph%04d.png"%i,
figsize=[12,8],
dpi = 1000,
xmin = -2.1,
xmax = 2.1,
ymin = -2.1,
ymax = 2.1,
zmin=-2.1,
zmax=2.1,
transparent=True,
aspect_ratio=1
)
os.system('cd graphFrames; convert -delay %s -loop %s *.png "graph.gif"'%(float(100/60),int(0)))
Is the general method of how I'm constructing my animationsddxtanxFri, 18 Jun 2021 19:50:09 +0200https://ask.sagemath.org/question/57620/Is there a hotkey/shortcut for showing the previous outputs in the interactive shell?https://ask.sagemath.org/question/54195/is-there-a-hotkeyshortcut-for-showing-the-previous-outputs-in-the-interactive-shell/ I know that if I press the up arrow key, I can cycle through the previous inputs. Is there a similar hotkey/shortcut for cycling through the previous outputs?Dr. BananaTue, 10 Nov 2020 14:41:32 +0100https://ask.sagemath.org/question/54195/How do I use sage objects within markdown cellshttps://ask.sagemath.org/question/52990/how-do-i-use-sage-objects-within-markdown-cells/I would like to use some result created in a previous cell, whithin an explanation in text on a markdown cell in the same notebook, in jupyter.alvaroThu, 13 Aug 2020 22:05:38 +0200https://ask.sagemath.org/question/52990/Output of a sequence in Display and as a txt-Filehttps://ask.sagemath.org/question/48691/output-of-a-sequence-in-display-and-as-a-txt-file/Hello. This
X = 19 # Start
N = 7 # Width
def f(x, n):
yield x
for k in range(0, n):
if x % 2 == 0:
x = x / 2
else:
x = 3*x + 1
yield x
print(", ".join(map(str, f(X, N))))
gives me a sequence comma-separated in the display.
How can I have that line-separated (like at default) as a good-named txt-File, like `collatz19.txt` ?geroyxSun, 10 Nov 2019 16:44:39 +0100https://ask.sagemath.org/question/48691/How to recreate traceback?https://ask.sagemath.org/question/46565/how-to-recreate-traceback/Hello, Sage Community.
When we write something like `sin(t)` without previously defining the variable `t`, we get a traceback like
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-138-17829414d33a> in <module>()
----> 1 sin(t)
NameError: name 't' is not defined
I would like to reproduce this text automatically. I have tried the following:
try:
sin(t)
except:
_typ_, _val_, _tb_ = sys.exc_info()
traceback.print_exception(_typ_, _val_, _tb_)
However, this produces a less rich output:
Traceback (most recent call last):
File "<ipython-input-139-55b9ce98509c>", line 2, in <module>
sin(t)
NameError: name 't' is not defined
How could I reproduce the rich output?
Thanks in advance for your answers!dsejasFri, 17 May 2019 21:58:18 +0200https://ask.sagemath.org/question/46565/Wrong solution/output for differential equationhttps://ask.sagemath.org/question/45046/wrong-solutionoutput-for-differential-equation/As the user rburing advised in the thread
https://ask.sagemath.org/question/44995/combine-plots-with-built-in-maxima-trajectory-in-sage-available/
I'm opening this one now.
When running the following code, one obtains a wrong output:
y=function('y')(x)
desolve(diff(y)==4*y/x+x*sqrt(y),y,ics=[1,1]).factor()
The output is `1/4*x^4*(log(x) - 2)^2` instead of `1/4*x^4*(log(x) + 2)^2`. Mathematica however outputs both (by running `DSolve[{D[y[x], x] == 4*y[x]/x + x*Sqrt[y[x]], y[1] == 1}, y[x], x]`).ThrashMon, 14 Jan 2019 17:54:14 +0100https://ask.sagemath.org/question/45046/remember and collect values/outputhttps://ask.sagemath.org/question/39749/remember-and-collect-valuesoutput/Hello, I am working with a function that involves random values. Thus, every time I run my code I get different values(in my case it is a set of values). When I get my output I want Sage to remember it and collect it every time I run my code. At the end I'd like to get a list of sets that has been accumulated every time I ran my code. Is there a way to do it?
I tried to research this topic and haven't found anything except saving a list to .txt file.XeniaThu, 23 Nov 2017 21:07:44 +0100https://ask.sagemath.org/question/39749/Why does underscore for last output not work in worksheets uploaded from local SageMath to Cocalc?https://ask.sagemath.org/question/38820/why-does-underscore-for-last-output-not-work-in-worksheets-uploaded-from-local-sagemath-to-cocalc/My commands are like this:
vector([x1,y1,z1])
r1 = _
And I get this message:
Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
NameError: name '_' is not defined
However, copying and pasting commands into a new worksheet make that feature work again. Why?
I have links to illustrate it, but my karma is insufficient to post them here.
Leo Luiz CastroFri, 15 Sep 2017 14:24:23 +0200https://ask.sagemath.org/question/38820/How to save table output in an exportable mannerhttps://ask.sagemath.org/question/38252/how-to-save-table-output-in-an-exportable-manner/Hello! I am a sage novice trying to export a table output to some image format (so that it might be shared). I tried using the .save() function as so:
my_table1 = table(my inputs)
result = my_table1.transpose()
result.save('here')
My table outputs properly after I run the program (not featured), but for some reason I receive the following error when I try and save the table:
"Error! /home/sage/Documents/here.sobj is not UTF-8 encoded
Saving disabled.
See Console for more details."
Any help in exporting this table is greatly appreciated. Additionally, if you require any more information please do not hesitate to ask!
EDIT: I am working in Jupyter for Sage on a browser via localhost/8000; not sure if that matters.ethanzellFri, 14 Jul 2017 06:53:29 +0200https://ask.sagemath.org/question/38252/Export Answer To Text Filehttps://ask.sagemath.org/question/37745/export-answer-to-text-file/Hello,
I have read the available suggestions and they did not work.
I would like to output the number generated by 2^1000 to a text file so that I can import to my C++ program.
Please help me along. happys5Wed, 31 May 2017 02:18:16 +0200https://ask.sagemath.org/question/37745/Why the value returned by read_data,open... are unavailable in Jupyter notebookhttps://ask.sagemath.org/question/37387/why-the-value-returned-by-read_dataopen-are-unavailable-in-jupyter-notebook/I run the following commands in code cell of jupyternotebook.
indata = tmp_filename()
f = open(indata, "w")
f.write("17\n42\n")
f.close()
l = read_data(indata, ZZ); l
And I get the following error message:
TypeError: 'NoneType' object is not iterable
But the result is output in terminal.
[I 21:15:07.797 NotebookApp] Saving file at /Untitled.ipynb
[17, 42]
How to solve this problem?
By the way: some functions such as "print", "tmp_filename" also can not output in Jupter notebook.
These functions work well in old sage math notebook.dannyMon, 24 Apr 2017 15:35:45 +0200https://ask.sagemath.org/question/37387/Converting sin(x)^n to sin^n(x)https://ask.sagemath.org/question/35153/converting-sinxn-to-sinnx/Hello all!
I am trying to figure out how to change the sage output when it has certain trig functions to a power. For example, if I do the following;
f(x) = sin(x)
g(x) = f(x)^5
I get out
g(x) = sin(x)^5
This can be a bit ambiguous, as someone not paying attention might read that as sin(x^5). Instead I would like to make it output;
g(x) = sin^5(x)
I have tried using wildcards as was suggested to me in another post here: https://ask.sagemath.org/question/34767/replacing-mathematical-functions-of-expressions-with-different-mathematical-functions-of-the-same-expression/ But it doesn't seem to like that (probably because it thinks I'm interrupting a math call function and it's getting syntax errors, which I expected when I tried it originally).
Is there any nice way of reformatting the output? I suspect wildcards would probably be capable if I were more adept at them? I would like it specifically for the basic trig functions. I don't mind if I need to write a "simplify" function to run on an expression to convert it (even if it converts everything to a string), but I can't seem to get anything to work correctly.
Thanks.Jason021Sat, 15 Oct 2016 19:33:36 +0200https://ask.sagemath.org/question/35153/output not showing on notebookhttps://ask.sagemath.org/question/33985/output-not-showing-on-notebook/I right clicked on output text and selected mathjax for rendering...
..since then the output is not showing.
Can anybody help? I cannot click on thee output again to select default html with javascript option, as the output is not showing. I looked everywhere to see if this option can be changed, but couldn't find it. flypFri, 01 Jul 2016 01:48:23 +0200https://ask.sagemath.org/question/33985/when typeset is checked on the notebook app, output is not showinghttps://ask.sagemath.org/question/33984/when-typeset-is-checked-on-the-notebook-app-output-is-not-showing/I did something that caused the sage notebook not show output, when the typeset is checked.
I right clicked on the output (while it was showing originally) and opted for Mathjax display. Since then, the output is not showing. Now I cannot figure out how to change my setting back to normal. Please help.
Hope I don't need to re install the software again.flypFri, 01 Jul 2016 01:03:24 +0200https://ask.sagemath.org/question/33984/How do I back substitute in output.https://ask.sagemath.org/question/32422/how-do-i-back-substitute-in-output/ I define three points (xia,yia,zia,xib...), the vectors xab,yab,zab,xcb.. , the distances rab2 and rcb2, the dot product, the angle a-b-c and then the energy of bending the angle - e. I take the derivative of e with respect to xia and I get a long output in terms of xia-xib, xic-xib and so on. I want to condense the output by using all the previous defines. I normally would do this by hand doing string replacements in emacs. Tedious and error prone. Is there a command or script that will do the back substitution. Simplify dies with out of memory errors and is not really what I am trying to do. I had the same problem in Mathmatica and never found a good solution.KevinGilbertWed, 03 Feb 2016 00:46:32 +0100https://ask.sagemath.org/question/32422/saving sage output which contain graphshttps://ask.sagemath.org/question/32300/saving-sage-output-which-contain-graphs/I have a sage program, which contains texts as well as some graphs. How to save this output in some file with some format. If I save it in txt file graphs are not coming in the output.
Thanks for your valuable timing.
GA316Wed, 20 Jan 2016 15:08:08 +0100https://ask.sagemath.org/question/32300/Output result in several columnshttps://ask.sagemath.org/question/31464/output-result-in-several-columns/Dear Sage users,
I have a simple function **f(k,x)=Sin(kx**).
In Sage notebook, I would like to get an output of **f(k,x)** for x in [0..2*pi,step=0.01] and then
for k in [1..10,step=4] (a nested loop). I prefer to get output in an txt-file in several columns as in the following (just numbers):
**x** **f(k<sub>1</sub>,x)** **f(k<sub>2</sub>,x)** **f(k<sub>3</sub>,x)**
<p> 0 0 0 0
<p> 0.01 0.01 0.05 0.0899<p>
... ... ... ...
<p>
I have tried several codes but without success. I think that the problem of my code is not the Sage but my poor knowledge of Python.<p>
Could somebody tell me how to get output in more correct form?<p>
Firs line of my output is normal, But the next three columns are separated in a not preferred manner:
x=var('x')
html('<!--notruncate-->')
f=file("sage_sinkx.txt","w")
for x in [0..2*pi,step=0.01]:
rows=n(x,digits=4),[n(sin(k*x), digits=3) for k in [1..10,step=4]]
s=table(rows)
f.write(str(s)+ "\n")
print s
f.close()
Let me know please if anybody could help.<p>
Thank to all.ChuvacThu, 10 Dec 2015 17:42:04 +0100https://ask.sagemath.org/question/31464/Saving my sage session into a .txt file from Interactive Shellhttps://ask.sagemath.org/question/31110/saving-my-sage-session-into-a-txt-file-from-interactive-shell/ Hello guys, I have the following question:
Lets say i run a sage session and at the end i got this written in my Interactive Shell after the session
sage: Zmod(7)
Ring of integers modulo 7
sage: R.<x> = Zmod(7)[]
sage: R
Univariate Polynomial Ring in x over Ring of integers modulo 7
sage: RR = R.quotient(x^7 - 1)
sage: RR
Univariate Quotient Polynomial Ring in xbar over Ring of integers modulo 7 with modulus x^7 + 6
sage: f = RR(x^6-x^4+x^3+x^2-1)
sage: f
xbar^6 + 6*xbar^4 + xbar^3 + xbar^2 + 6
And now i want to save all of the above into a txt-file.
Is that possible and when yes how?bruno171092Fri, 27 Nov 2015 22:02:48 +0100https://ask.sagemath.org/question/31110/Multiple outputs with Sage Notebookhttps://ask.sagemath.org/question/30967/multiple-outputs-with-sage-notebook/ Hello Guys,
i have the following question. I use Sage on Windows so I use the Sage Notebook in my browser.
I wanted to know if there is a possibility to get more than one output from that without going to a new "compute cell" for everything i want to be computed... For example: When i have
sage: Zmod(7) +++
sage: R.<x> = Zmod(7)[]
sage: R +++
sage: RR = R.quotient(x^7 - 1)
sage: RR +++
sage: f = RR(x^6-x^4+x^3+x^2-1)
sage: f +++
sage: g = f^(-1)
sage: g +++
sage: g.parent() +++
sage: g*f +++
sage: f*g +++
i only get output from the last command (as result 1)
But i want to get output from every line i marked above with +++.
Is there annother possiblilty than using a new compute cell after every line i want to have output from?
bruno171092Sun, 22 Nov 2015 20:02:21 +0100https://ask.sagemath.org/question/30967/How to print a text file containing multiple tuples from a functionhttps://ask.sagemath.org/question/26710/how-to-print-a-text-file-containing-multiple-tuples-from-a-function/ I am trying to use Sagemath Cloud to create a text file with multiple columns of data. Each column is the input or output value of the variables of a system of functions being evaluated with for loops. I am very new to Python, and when I try to do this, I either get an error message or I get a text file with only one line, and that line is constantly overwritten by a new value of the function. On my own laptop with its standalone version of Sage, I can easily generate what I want simply by telling Sage to print the values of the variables of the function for each iteration of the for loops. The standalone version even creates an output text file that I can save. How do I do this with the cloud version?C. ThompsonMon, 04 May 2015 01:42:46 +0200https://ask.sagemath.org/question/26710/"Too many output messages"https://ask.sagemath.org/question/24566/too-many-output-messages/ Hi,
I am running a program on Sage worksheet, on cloud interface.
It has too many outputs but ı need to see them.
However, Sage says
"Too many output messages (at most 256 per cell): attempting to terminate..."
What does this mean? Can't I see all of them? Or write them in an outer file or sth?algebraicallyclosedWed, 22 Oct 2014 13:43:07 +0200https://ask.sagemath.org/question/24566/Compact output of solution of DEhttps://ask.sagemath.org/question/26316/compact-output-of-solution-of-de/ When I'm trying to solve DE:
t = var('t')
y = function('y', t)
de = t*(y^2)*diff(y,t) + y^3 == 1
sol = desolve(de,[y,t], [1,2])
the output is pretty ugly:
-1/3*log(y(t)^2 + y(t) + 1) - 1/3*log(y(t) - 1) == -1/3*log(7) + log(t)
When I'm solving this in matlab:
clear;
syms y(t)
y(t) = dsolve(t*(y^2)*diff(y,t) + y^3 == 1, y(1) ==2)
The output looks much better:
y(t) = (exp(log(7) - 3*log(t)) + 1)^(1/3)
Can I see output in sage looking similiar to this from matlab? Simplify(sol) dosen't work. Maybe I've made mistake somewhere, but I can't determine without knowing the form y(t) from sage.
And btw, typing:
t*(y^2)*y'+ y^3 = 1, y(1) = 2
into wolframalpha.com results yet another solution. I'm lost...PhotonTue, 24 Mar 2015 21:51:52 +0100https://ask.sagemath.org/question/26316/Questions about the parameters in the output of solvehttps://ask.sagemath.org/question/26205/questions-about-the-parameters-in-the-output-of-solve/I am writing a program that, among other things, has to solve many systems of polynomial equations (of degree <= 3) determined by the data entered by the user. Each system of equations consists of 3 equations in 3 variables. Sometimes the equations in a given system are redundant, and therefore the output of solve contains parameters (free variables). Is there any way to know which variables in the output of solve are the parameters (without having to look at the actual output in Sage)?
Here is a simple example.
x,y=var('x,y',domain=RR);
eqn1=x+y==1;eqn2=2*x+2*y==2;
soln=solve([eqn1,eqn2],x,y,solution_dict=True);
soln
The output is
[{x: -r6 + 1, y: r6}]
How do I know which variable is the free variable in this case (without looking at the output)? Is it true that the free variable(s) in the output of solve will always be the "last variable(s)" (in the alphabetical order), `y` in this case? Is there a `is_free_variable` function (similar to the `is_integer` function)? In my program, I need to be able to identify the free variables in the solution of solve, `y` in this case, without looking at the output, and substitute those variables by a few numerical values.
I understand that the `solve` function in Sage uses the corresponding Maxima function. It seems that Sage does not recognize the Maxima function `%rnum_list` (which gives the list of parameters introduced in the solutions by `solve` and `algsys`). Is there a Sage function that does the same as `%rnum_list`?
Thanks,
Aldo
aldoMon, 16 Mar 2015 17:06:26 +0100https://ask.sagemath.org/question/26205/truncated output problemhttps://ask.sagemath.org/question/9110/truncated-output-problem/I am running a program; the output gets truncated and gets sent to full_output.txt in another tab on my browser. However, I have run the program with different parameters which leads to different output; however, the tab with full_ouput.txt does NOT get updated.SCMon, 25 Jun 2012 10:15:42 +0200https://ask.sagemath.org/question/9110/Sharing Sage on the Webhttps://ask.sagemath.org/question/25106/sharing-sage-on-the-web/I have a Sage program that takes an integer as input and outputs lots of pretty pictures. I would like to share this program in such a way that someone with no knowledge of Sage could still provide the integer and enjoy the pictures.
For example, I imagine having a website with a form where the user provides an integer, the program executes in the cloud, and the pictures are displayed in the browser. This may not be possible or even advisable, but it's the sort of thing I mean.
What kinds of options do I have to easily share Sage output on the web?Austin MohrThu, 04 Dec 2014 01:12:18 +0100https://ask.sagemath.org/question/25106/"showing" both input and outputhttps://ask.sagemath.org/question/24039/showing-both-input-and-output/Is there a way to get Sage to show the "pretty" versions of both the input and the output of a calculation, instead of just the output? (sort of like the TI-89 and such)
For example, when I enter as input "integrate(x^2, x, 0, 3)" it correctly returns 9. But can I get it to return something like (the typeset version of) \int_0^3 x^2 dx = 9 ? It's obvious enough in this example what I'm asking for but some queries get complicated and seeing them as they would be printed helps make sure I'm asking Sage for what I mean to ask for.mathochistSat, 06 Sep 2014 22:41:45 +0200https://ask.sagemath.org/question/24039/convert outputhttps://ask.sagemath.org/question/23650/convert-output/ Hello, if a function gives an output like this
> 2.00000000000000 - 2.77555756156289e-17*I
how could one convert it to be simply
> 2
BestsTomyThu, 31 Jul 2014 21:30:30 +0200https://ask.sagemath.org/question/23650/Export notebook cell output as LaTeX?https://ask.sagemath.org/question/10927/export-notebook-cell-output-as-latex/If I want to import Sage output from a notebook cell into a LaTeX document, I can uncheck the "Typeset" box at the top, and then run "latex(y)" on the output y.
But is there a better way, that doesn't require fiddling with the "Typeset" box every time I want raw LaTeX as output?AlasdairFri, 24 Jan 2014 08:41:15 +0100https://ask.sagemath.org/question/10927/How to delete output file for rewriting?https://ask.sagemath.org/question/10892/how-to-delete-output-file-for-rewriting/I am using the Python's wave library to create some simple .wav files. It is impossible to overwrite these files, so I need a way to delete them before I run the code to create them. Right now, I am having to rename the file every time. There must be a simple way to delete the files in Terminal but I can't seem to find them. I am creating the files via the Notebook GUI. Any clues where the files could be saved or know of any other way to delete them?corleymjSun, 12 Jan 2014 23:52:09 +0100https://ask.sagemath.org/question/10892/prime_factors(2^100000000000000) outputhttps://ask.sagemath.org/question/10831/prime_factors2100000000000000-output/After trying prime_factors(2^100000000000000) I received all this
------------------------------------------------------------------------
[...bunch of paths in my pc...]
------------------------------------------------------------------------
Attaching gdb to process id 5477.
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>.
Stack backtrace
---------------
Cython backtrace
----------------
Exception: <class 'gdb.error'> No registers.
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No stack.
Traceback (most recent call last):
File "<string>", line 118, in <module>
File "<string>", line 90, in invoke
File "<string>", line 94, in newest_first_order
error: No registers.
warning: Inferior ID 1 has no threads.
Saved trace to /home/esteban/.sage/crash_logs/sage_crash_zXpf5F.log
------------------------------------------------------------------------
Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off(). You might
want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate.
------------------------------------------------------------------------
What is that? Should I do something? Did it (unsuccesfully) try to autoreport bug?estebanSat, 14 Dec 2013 02:00:56 +0100https://ask.sagemath.org/question/10831/