ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 08 Sep 2020 07:24:49 -0500- How to find the symbolic maximum of a 3D function?https://ask.sagemath.org/question/53364/how-to-find-the-symbolic-maximum-of-a-3d-function/I have a function of two real variables,
f(x,y) = a * (x * y - y^2) * exp( -b * x^2) * exp(b * x * y )
with the real parameters a and b, and five restrictions:
x>0;
y>0;
a>0;
b>0;
y<=x (y equal to or less than x)
In the 3d_plot, with a=b=1, i see there is only one local maximum, which is also the global maxium.
How can i get the formula, for x and y coordinate of the maximum, as function of the parameters a and b?
I tried assume() for the restrictions, but that does not work and is made for the other way, to tell what is already there, not what should be changed.
To get rid of the negative function values, i used
r(x,y) = max_symbolic(0, f(x,y))
and that works, but that is only a workaround for the not implemented restrictions.RolfFMon, 07 Sep 2020 16:23:58 -0500https://ask.sagemath.org/question/53364/
- How to use surface_to_stlhttps://ask.sagemath.org/question/53370/how-to-use-surface_to_stl/ https://trac.sagemath.org/ticket/7744 describes a function surface_to_stl to export 3D surfaces. It has the following example:
sage: x,y,z = var('x,y,z')
sage: a = implicit_plot3d(x^2+y^2+z^2-9, [x,-5,5], [y,-5,5],[z,-5,5])
sage: a
sage: f=file.open("foo.stl",'w')
sage: f.write(surface_to_stl(a))
sage: f.close()
When I run it, I get Name 'file' is not defined. When I remove 'file', I can print, but get "name 'surface_to_stl' is not defined.
So, what is the correct way to use surface_to_stl and what are the limitations of this function or of the method .save('foo.stl')?IngoTue, 08 Sep 2020 07:24:49 -0500https://ask.sagemath.org/question/53370/
- 3d image plot SAGEMATH 9.0 Notebookhttps://ask.sagemath.org/question/52179/3d-image-plot-sagemath-90-notebook/Hi! I am using SAGEMATH 9.0 Notebook, and when I make 3d images, theye are always viewed from the same angle of vision, but i want another angle view, how can i change it? I am currently using the .show(viewer='canvas3d')creyesm1992Tue, 23 Jun 2020 06:09:08 -0500https://ask.sagemath.org/question/52179/
- How to save 3d plot as rotatable html filehttps://ask.sagemath.org/question/50882/how-to-save-3d-plot-as-rotatable-html-file/ I'm using SAGEMATH in a Jupyter notebook on CoCalc.
I have a rotatable 3d image and I want to save it as such.
If I go to
(Grey) File/Download as html
If I "EXPORT AS HTML" and click this now opens in the browser.
Then I can scroll down to a particular 3d plot and click on the download error to the lower right of the image, and thereby take a nice screenshot with the perspective indicated.
What I want to do is save the html file of just this image, not the whole notebook.
I know this is possible because I did it a year ago- but forgot to take notes on what worked, and have forgotten how!
Some of my plots I did with threejs and some with the default (not sure what that is).
Both work in the same way.
Thanks for any suggestions!
alMon, 20 Apr 2020 20:47:57 -0500https://ask.sagemath.org/question/50882/
- Accessing component of 3D vector?https://ask.sagemath.org/question/46668/accessing-component-of-3d-vector/ So if you make a vector like this:
vector1 = arrow((0,0,0),(1,2,3))
and you want to access a component of the vector, for example the second y component (2), how would you do this?
Something like vector1.y2 (that doesn't work haha) but how would I do this?etillsSat, 25 May 2019 11:46:45 -0500https://ask.sagemath.org/question/46668/
- draw all faces of alcoves (affine root system)https://ask.sagemath.org/question/45354/draw-all-faces-of-alcoves-affine-root-system/I am trying to plot alcoves for in a rank 3 affine root system with some of those alcoves highlighted by having all faces drawn and the others only shown as a wire frame.
The manual on visualising root systems at sagemath.org is quite useful, but I have some effects show that I don't understand.
For some reason while the fundamental alcove will have all faces shown many of the others have not, that is, some faces are missing. Below you find one example code that I have done. For the chosen seq one face is missing, the red one. For other choices of seq one might even see only one face drawn. How do I force to have all faces shown?
L = RootSystem(["A",3,1]).ambient_space()
P = RootSystem(["A",3,1]).weight_space(extended=True)
Lambda = P.fundamental_weights()
W = L.weyl_group()
W0=W.classical()
plot_options = L.plot_parse_options()
seq=[2,3,1,2]
t = 1*Lambda[1]-1*Lambda[2]+1*Lambda[3]
Alcoves=[W.from_reduced_word(w.reduced_word()) for w in W0]
p = L.plot_fundamental_chamber("classical")
p += L.plot_fundamental_weights()
p += L.plot_alcoves(alcoves=Alcoves, wireframe=True)
p += L.plot_alcoves(alcoves=[W.from_reduced_word(seq)])
p += L.plot_alcoves(alcoves=[W.from_reduced_word([])])
p += plot_options.family_of_vectors({t: L(t)})
p.show(frame=False)oloidThu, 07 Feb 2019 09:08:34 -0600https://ask.sagemath.org/question/45354/
- 3D Graph with Domain contourshttps://ask.sagemath.org/question/43985/3d-graph-with-domain-contours/Hi
I would like to visualize in 3D the function below:
f_{X,Y}(x,y) = \begin{array}{ll} x^2, & \mbox{if $1 \leq x \leq 2$ and $0 \leq y \leq x$}, \\ 0, & \mbox{otherwise}. \end{array} .
I execute this code below, but it is not displaying good (what is wrong with the code ?), and how to display the axes labels ?
var("x y z")
region = implicit_plot3d(z, (x, -3, 3), (y, -3, 3), (z, -3, 3) , plot_points=100, region=lambda x,y,z: x^2 and 1<x and x<2 and y<x and y>0,axes=True)
region.show()ortolljFri, 19 Oct 2018 05:40:34 -0500https://ask.sagemath.org/question/43985/
- Please untether us from the laptop.https://ask.sagemath.org/question/43489/please-untether-us-from-the-laptop/First of all, I love SageMath (came from Mathematica).
Advocate all institutions change over.
For broader adoption of Sagemath it would be great if it worked flawlessly on tablet browsers (make Sage mobile).
Any possibility SageMath user interface can have full compatibility on tablets?
Currently, right-clicking is not supported on 3D objects (long press).
Tested on Windows 10, Android and iOS using Chrome, Edge and Safari.
Bonus,if manipulation of 3D objects could be smoother and less battery consuming.
The simplest 3D objects consume the CPU. Considering Android will probably never have a native SageMath, making the web experience as best as possible would really be great.
shinsterMon, 27 Aug 2018 11:58:09 -0500https://ask.sagemath.org/question/43489/
- How do you get a 2d version of a 3d plot?https://ask.sagemath.org/question/40917/how-do-you-get-a-2d-version-of-a-3d-plot/ I am working on Cocalc. I would like to get a nice pdf of the view I want after rotating and zooming.
Yes, taking a screenshot works, but is there a better method? Thanks !alThu, 01 Feb 2018 08:16:06 -0600https://ask.sagemath.org/question/40917/
- How to scale threejs graphs?https://ask.sagemath.org/question/24228/how-to-scale-threejs-graphs/ Hi,
jmol works nicely in scaling 3d graphs in sagecell, however threejs does not. Even manual scaling using aspect_ratio does not seem to work; aspect_ratio is apparently ignored.
Example:
%var x,y
g=plot3d(x^3*y^3, (x,-2,2),(y,-2,2),aspect_ratio=[1.0,1.0,.001])
threejs(g)
Is there another way to scale graphs with threejs?
Best
IngoIngo DahnSun, 21 Sep 2014 06:23:12 -0500https://ask.sagemath.org/question/24228/
- How does one use the qhull optional package?https://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/Has anyone used the qhull optional package? I'm not so sure on how to use it. Is there a tutorial on this?torrhoTue, 18 Jun 2013 14:22:00 -0500https://ask.sagemath.org/question/10254/
- plotting 3d polytope in R^4https://ask.sagemath.org/question/35704/plotting-3d-polytope-in-r4/ I'm trying to plot the following polytope on the cloud:
P=Polyhedron(vertices=[[0, 1, 0, 4] , [0, 1, 1, 3] , [3, 1, 1, 0] , [3, 1, 0, 1] , [0, 3, 0, 2] , [0, 3, 1, 1] , [1, 0, 0, 4] , [1, 0, 1, 3] , [3, 0, 1, 1] , [3, 0, 0, 2] , [1, 3, 1, 0] , [1, 3, 0, 1]])
P.plot()
This is a polytope living in R^4, but in fact the sum of the coordinates of each vertex is 5, so it is a 3D polytope. In some cases, sage gives me a nice 3D view of how the polytope looks like, but in this case it gives me something that doesn't even looks convex, so it is not the right projection. I would like to know what is going on and try to solve this issue, so I appreciate ideas on how to correct this, and where to look at on the code. EmersonLWed, 23 Nov 2016 14:27:10 -0600https://ask.sagemath.org/question/35704/
- Get objects from a Graphics3dGrouphttps://ask.sagemath.org/question/26360/get-objects-from-a-graphics3dgroup/Dear all,
I would like to trasnform a 3d object into a set of faces (or triangles). For that, I take a 3d object and convert it to a STL file following [this procedure](http://trac.sagemath.org/ticket/7744).
The short questions is: how to get the 3d objects from a Graphics3dGroup?
The long question : I don't understand the nature of the 3d graphics.
For instance:
G1 = polygon3d([(0,0,0),(1,0,0),(2,1,1)])
print(type(G1))
G2 = polygon3d([(0,0,0),(1,0,0),(2,1,1)]) + polygon3d([(1,2,3),(1,0,0),(2,1,1)])
print(type(G2))
G3 = sphere((0,0,0),1)
print(type(G3))
1. In the first case it seems to be a set of faces and it's possible to convert it to a STL file.
2. In the second case it is a group of 3d object and -as a group- it has no face.
3. The sphere is a `TransformGroup` and has no face.
How to get the faces of the last two situations?
Thanks for yours answers.
Arnaud
Arnaud1418Fri, 27 Mar 2015 09:31:57 -0500https://ask.sagemath.org/question/26360/
- Transferring 3D plotshttps://ask.sagemath.org/question/26075/transferring-3d-plots/I want to export 3D plots from Sage in some 3D format or other (NOt just a single png frame)
This script produces a jMol file for me. (I am on cloud.sagemath)
> from sage.interfaces.jmoldata import JmolData 3 sage: JData = JmolData() 4
> u,v = var('u v') 5 f_x = u 6 f_y =
> cos(1*v) 7 f_z = sin(3*v) 8
> img=parametric_plot3d([f_x, f_y, f_z],
> (u, 0, 0.6), (v, 0, 6*pi),
> color='blue', mesh=1, frame=False) 9
> img.save('myfile.png') 10
> img.export_jmol('thisjmol') 11 img 12
The file produced is about 20K or so but if I try to open it via JMol standalone viewer I just get black.
Mind you if I try the example jmols I also get black.
My end point is to get the 3D view into a 3D package such as Blender but to start with I need to get my 3D image out of sage.
Any idea of where I am going wrong?
nerak99Sun, 08 Mar 2015 12:56:45 -0500https://ask.sagemath.org/question/26075/
- plot Polyhedron from cloudhttps://ask.sagemath.org/question/24686/plot-polyhedron-from-cloud/ I'm trying to plot some 3d stuff from the cloud.
I tried:
icosahedron()
and worked perfectly, but then I tried
v=[(0,0,0),(0,1,0),(0,2,1),(1,0,0),(1,2,3),(2,1,1)]
Polyhedron(vertices=v).plot()
and I only get a single bullet, no error message, no image, no nothing... What is going on?EmersonLWed, 29 Oct 2014 11:57:17 -0500https://ask.sagemath.org/question/24686/
- fields plot 3dhttps://ask.sagemath.org/question/10787/fields-plot-3d/In sagemath CLOUD i can't plot vector fields in 3d :
x,y,z = var ('x y z')
plot_vector_field3d((x*cos(z),-y*cos(z),sin(z)), (x,0,pi), (y,0,pi), (z,0,pi),center_arrows=True,aspect_ratio=(1,2,1))
error reported:
Error in lines 2-2 Traceback (most recent call last): File "/mnt/home/WmaalNmo/.sagemathcloud/sage_server.py", line 668, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/mnt/home/WmaalNmo/.sagemathcloud/sage_salvus.py", line 2723, in displayhook show(obj) File "/mnt/home/WmaalNmo/.sagemathcloud/sage_salvus.py", line 2082, in show graphics.show_3d_plot_using_threejs(obj, **kwds) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 119, in show_3d_plot_using_threejs t.add(g, **kwds) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 81, in add self._call('add_3dgraphics_obj(obj)', obj={'obj':graphics3d_to_jsonable(graphics3d), 'wireframe':jsonable(kwds.get('wireframe'))}) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 387, in graphics3d_to_jsonable handler(p)(p) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 359, in convert_combination handler(x)(x) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 365, in convert_inner handler(p.all[0])(p) File "/mnt/home/WmaalNmo/.sagemathcloud/graphics.py", line 346, in convert_line "points" : p.points, AttributeError: 'TransformGroup' object has no attribute 'points'
thank you for your help.
FĂ©lix.
fgiffuniFri, 29 Nov 2013 03:01:48 -0600https://ask.sagemath.org/question/10787/
- R graphics/plots in sagenbhttps://ask.sagemath.org/question/8320/r-graphicsplots-in-sagenb/Are graphics in R on sagenb supported? I only get placeholder icons for output.riotQontrolWed, 14 Sep 2011 15:43:13 -0500https://ask.sagemath.org/question/8320/
- Jmol 3D viewer problem in Linuxhttps://ask.sagemath.org/question/10398/jmol-3d-viewer-problem-in-linux/Hi all.
I noticed some problems with 3D plots in the Sage notebook under Linux (Mint 15 KDE guest in VirtualBox).
When I try to use the Advanced Controls of Jmol 3D viewer, the system always freezes.
In particular, when I try to access the "Color and Mesh" tab, Firefox gives an error concerning a plugin called "IcedTea-Web".
I don't find similar problems running directly Sage in VirtualBox under Windows 7 64 bit.
Do you have any idea about the problem?
Thanks.
AntlabTue, 30 Jul 2013 04:16:07 -0500https://ask.sagemath.org/question/10398/
- Plot in 3D without interpolationhttps://ask.sagemath.org/question/9187/plot-in-3d-without-interpolation/Can I use list_plot3d without interpolation, or is there some equivalent? I just want to plot the output of a numerical integration (specifically, the Lorenz attractor) and the interpolation is **not** helpful.jaiaSun, 29 Jul 2012 21:02:06 -0500https://ask.sagemath.org/question/9187/
- Basic vector functions in Sagehttps://ask.sagemath.org/question/8924/basic-vector-functions-in-sage/Isn't there any inbuilt 3D vector functions in Sage?
For instance like a function to get the dot product, cross product or angle between two vectors? Or functions to get the distance from a point to a line? Find the intersections between two lines? Having such functions would be a great help and would greatly increase the speed of my workflow in school.paldepindWed, 25 Apr 2012 00:43:34 -0500https://ask.sagemath.org/question/8924/
- Interact 3d plot(Polyhedron)https://ask.sagemath.org/question/8834/interact-3d-plotpolyhedron/Hi there, I got confused about the interact:
def par(t):
tmp = [[200-t,-1,0,0],[300-t,0,-1,0],[400-t,-1,-1,-1],[600-t,0,-1,-3],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
G = Polyhedron(ieqs = tmp)
show(G.render_solid(rgbcolor='blue',alpha=.2)+G.render_wireframe(rgbcolor='black'))
@interact
def _(x=(0,10)):
par(x)
It is quite weird since in the examples of http://wiki.sagemath.org/interact/graphics, it seems that the interactive parameters could only be something controlling a plot. However in my case, the interactive parameter(x) is not used for controlling plot but for obtaining an [[],[]]. so it fails to interact. Any idea of that?
ZhengWed, 28 Mar 2012 19:23:22 -0500https://ask.sagemath.org/question/8834/
- line3d fonsize option?https://ask.sagemath.org/question/8607/line3d-fonsize-option/Hi!
I need to hide exact values in 3d plot. In case of 2d I can use fontsize option like:
line([(0,0),(1,1)]).show(fontsize=0)
But show + line3d ignores fontsize option.EugeneWed, 04 Jan 2012 09:15:09 -0600https://ask.sagemath.org/question/8607/