Re: [sage-support] 3d plotting in CoCalc with SageMath 8.0
For sage worksheets, I've created https://github.com/sagemathinc/cocalc/issues/2450 On Sun, Oct 29, 2017 at 1:12 PM William Steinwrote: > On Sun, Oct 29, 2017 at 9:31 AM Simon Willerton < > s.willer...@sheffield.ac.uk> wrote: > >> I have the following code to help my students visualize surfaces >> >> t, theta = var('t, theta', domain='real') >> x(t) = cosh(t) >> z(t) = t >> formula = (x(t)*cos(theta), x(t)*sin(theta), z(t)) >> parameters = ((t, -3, 3), (theta, -pi, pi)) >> surface = ParametrizedSurface3D(formula, parameters) >> show(surface.plot(aspect_ratio=1, color='yellow'), viewer='threejs') >> >> This works fine in SageMathCell (running SageMath 8.0) see >> >> http://simonwillerton.staff.shef.ac.uk/teaching/MAS336/sage_cell_surfaces.html >> The reason I'm using threejs is so that many plots can been seen on a >> single page. Without it (using jmol, I think) this wasn't possible. >> >> The code also works fine in a jupyter notebook running SageMath 8.0 on OS >> X in both firefox and chrome. >> >> However the code does not run in SageMath 8.0 on CoCalc. In a sagews it >> actually gives an error, >> > > It works fine in CoCalc (and uses threejs) if you do not give the viewer= > option. > > and in Jupyter (on firefox or chrome) the image just never appears. >> Changing the kernel to 7.6 on Jupyter on CoCalc allows the image to appear >> correctly. >> >> Should I not be using threejs or is the problem with CoCalc? >> >> Cheers, >> >> Simon >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sage-support" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sage-support+unsubscr...@googlegroups.com. >> To post to this group, send email to sage-support@googlegroups.com. >> Visit this group at https://groups.google.com/group/sage-support. >> For more options, visit https://groups.google.com/d/optout. >> > -- > -- William Stein > -- -- William Stein -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] 3d plotting in CoCalc with SageMath 8.0
On Sun, Oct 29, 2017 at 9:31 AM Simon Willertonwrote: > I have the following code to help my students visualize surfaces > > t, theta = var('t, theta', domain='real') > x(t) = cosh(t) > z(t) = t > formula = (x(t)*cos(theta), x(t)*sin(theta), z(t)) > parameters = ((t, -3, 3), (theta, -pi, pi)) > surface = ParametrizedSurface3D(formula, parameters) > show(surface.plot(aspect_ratio=1, color='yellow'), viewer='threejs') > > This works fine in SageMathCell (running SageMath 8.0) see > > http://simonwillerton.staff.shef.ac.uk/teaching/MAS336/sage_cell_surfaces.html > The reason I'm using threejs is so that many plots can been seen on a > single page. Without it (using jmol, I think) this wasn't possible. > > The code also works fine in a jupyter notebook running SageMath 8.0 on OS > X in both firefox and chrome. > > However the code does not run in SageMath 8.0 on CoCalc. In a sagews it > actually gives an error, > It works fine in CoCalc (and uses threejs) if you do not give the viewer= option. and in Jupyter (on firefox or chrome) the image just never appears. > Changing the kernel to 7.6 on Jupyter on CoCalc allows the image to appear > correctly. > > Should I not be using threejs or is the problem with CoCalc? > > Cheers, > > Simon > > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sage-support+unsubscr...@googlegroups.com. > To post to this group, send email to sage-support@googlegroups.com. > Visit this group at https://groups.google.com/group/sage-support. > For more options, visit https://groups.google.com/d/optout. > -- -- William Stein -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: 3d plotting in CoCalc with SageMath 8.0
Hi, You must add the keyword argument online=True to show(...): show(surface.plot(aspect_ratio=1, color='yellow'), viewer='threejs', online= True) Then it works in a Jupyter notebook running SageMath 8.0 in CoCalc: https://cocalc.com/projects/551a1e1d-9360-47bf-89ba-91603e96c7fe/files/2017-10-29-20.ipynb More generally online=True (which was introduced in SageMath 8.0) is necessary to share threejs plots on the web, e.g. via nbviewer.jupyter.org. Eric. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] 3d plotting in CoCalc with SageMath 8.0
I have the following code to help my students visualize surfaces t, theta = var('t, theta', domain='real') x(t) = cosh(t) z(t) = t formula = (x(t)*cos(theta), x(t)*sin(theta), z(t)) parameters = ((t, -3, 3), (theta, -pi, pi)) surface = ParametrizedSurface3D(formula, parameters) show(surface.plot(aspect_ratio=1, color='yellow'), viewer='threejs') This works fine in SageMathCell (running SageMath 8.0) see http://simonwillerton.staff.shef.ac.uk/teaching/MAS336/sage_cell_surfaces.html The reason I'm using threejs is so that many plots can been seen on a single page. Without it (using jmol, I think) this wasn't possible. The code also works fine in a jupyter notebook running SageMath 8.0 on OS X in both firefox and chrome. However the code does not run in SageMath 8.0 on CoCalc. In a sagews it actually gives an error, and in Jupyter (on firefox or chrome) the image just never appears. Changing the kernel to 7.6 on Jupyter on CoCalc allows the image to appear correctly. Should I not be using threejs or is the problem with CoCalc? Cheers, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: [piecewise] AttributeError: ComplexField_class_with_category object has no attribute complex_field
like basically, why don't the piecewise functions collapse to scalars? This should result in the same output, no? M_vec(x) = vector([M_Tx(x), M_by(x), M_bz(x)]).column() M_vec(x = l1) M_vec_l1 = vector([M_Tx(l1), M_by(x=l1), M_bz(x=l1)]).column() M_vec_l1 gives instead [piecewise(x|-->238.7324 on [0, 200], x|-->0 on (200, 450); x)] [ piecewise(x|-->-4.270333*x on [0, 200], x|-->3.416267*x - 1537.320 on (200, 450); x)] [piecewise(x|-->-0.9833111*x on [0, 200], x|-->1.076289*x - 484.3300 on (200, 450); x)] [ 238.7324] [-854.0667] [-196.6622] -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] [piecewise] AttributeError: ComplexField_class_with_category object has no attribute complex_field
For graphing strain load on a shaft in relation to coordinate x, I have created a set of piecewise functions. Now I wanted to munge them into a single parametrized vector to easily get the length via norm() at a specified point. M_Tx = piecewise([[[0, l1], M_t], [(l1, l1+l2), 0]]) M_by = piecewise([[[0, l1], -A_z * x], [(l1, l1+l2), -B_z * (l1+l2-x)]]) M_bz = piecewise([[[0, l1], A_y * x], [(l1, l1+l2), B_y * (l1+l2-x)]]) N_x = piecewise([[[0, l1], -A_x], [(l1, l1+l2), 0]]) Q_y = piecewise([[[0, l1], -A_y], [(l1, l1+l2), B_y]]) Q_z = piecewise([[[0, l1], -A_z], [(l1, l1+l2), B_z]]) M_vec(x) = vector([M_Tx, M_by, M_bz]).column() show(r"$\vec M=\left(\begin{array}{c} M_{Tx} \\ M_{by} \\ M_{bz} \end{array}\right)=$", M_vec(x = l1).n(digits=4), "kN $=$", round(M_vec(x = l1).norm(), 4), "kN") But, this does not work. Error in lines 27-27 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 996, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in File "sage/structure/element.pyx", line 838, in sage.structure.element. Element.n (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/element.c: 7961) return self.numerical_approx(prec, digits, algorithm) File "sage/symbolic/expression.pyx", line 5718, in sage.symbolic. expression.Expression.numerical_approx (/ext/sage/sage-8.0/src/build/ cythonized/sage/symbolic/expression.cpp:35056) x = x._convert(kwds) File "sage/symbolic/expression.pyx", line 1261, in sage.symbolic. expression.Expression._convert (/ext/sage/sage-8.0/src/build/cythonized/sage /symbolic/expression.cpp:10465) cdef GEx res = self._gobj.evalf(0, kwds) File "sage/libs/pynac/pynac.pyx", line 1343, in sage.libs.pynac.pynac.py_float (/ext/sage/sage-8.0/src/build/cythonized/sage/libs/pynac/pynac.cpp:15280) return p.complex_field()(n) File "sage/structure/category_object.pyx", line 823, in sage.structure. category_object.CategoryObject.__getattr__ (/ext/sage/sage-8.0/src/build/ cythonized/sage/structure/category_object.c:7662) return self.getattr_from_category(name) File "sage/structure/category_object.pyx", line 838, in sage.structure. category_object.CategoryObject.getattr_from_category (/ext/sage/sage-8.0/src /build/cythonized/sage/structure/category_object.c:7826) attr = getattr_from_other_class(self, cls, name) File "sage/structure/misc.pyx", line 294, in sage.structure.misc.getattr_from_other_class (/ext/sage/sage-8.0/src/build/cythonized/sage/structure/misc.c:1866) raise dummy_attribute_error AttributeError: 'ComplexField_class_with_category' object has no attribute 'complex_field' Is it that piecewise functions are not yet fully fledged out, or is my lack of sage routine that is to blame? Any hints most welcome : ) #Best Regards/Marcel -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.