Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 137
%fortran PRINT() END
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 947, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 988, in execute_with_code_decorators code = code_decorator(code) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 1924, in fortran raise RuntimeError("failed to compile Fortran code:\n" + log_string) RuntimeError: failed to compile Fortran code: Traceback (most recent call last): File "<string>", line 1, in <module> File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/f2py/f2py2e.py", line 648, in main run_compile() File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/f2py/f2py2e.py", line 633, in run_compile setup(ext_modules=[ext]) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup return old_setup(**new_attr) File "/projects/sage/sage-6.10/local/lib/python/distutils/core.py", line 151, in setup dist.run_commands() File "/projects/sage/sage-6.10/local/lib/python/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/projects/sage/sage-6.10/local/lib/python/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/distutils/command/build.py", line 47, in run old_build.run(self) File "/projects/sage/sage-6.10/local/lib/python/distutils/command/build.py", line 127, in run self.run_command(cmd_name) File "/projects/sage/sage-6.10/local/lib/python/distutils/cmd.py", line 326, in run_command self.distribution.run_command(command) File "/projects/sage/sage-6.10/local/lib/python/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/distutils/command/build_src.py", line 147, in run self.build_sources() File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/distutils/command/build_src.py", line 164, in build_sources self.build_extension_sources(ext) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/distutils/command/build_src.py", line 326, in build_extension_sources sources = self.f2py_sources(sources, ext) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/distutils/command/build_src.py", line 563, in f2py_sources ['-m', ext_name]+f_sources) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/f2py/f2py2e.py", line 408, in run_main postlist = callcrackfortran(files, options) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/f2py/f2py2e.py", line 329, in callcrackfortran postlist = crackfortran.crackfortran(files) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/f2py/crackfortran.py", line 3216, in crackfortran readfortrancode(files, crackline) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/numpy/f2py/crackfortran.py", line 422, in readfortrancode 'this code is in fix form?\n\tline=%s' % repr(l)) Exception: readfortrancode: Found non-(space,digit) char in the first column. Are you sure that this code is in fix form? line='PRINT()'
%gp e = ellinit([1,2,3,4,5]); ellglobalred(e)
[10351, [1, -1, 0, -1], 1, [11, 1; 941, 1], [[1, 5, 0, 1], [1, 5, 0, 1]]]
a = gap(2)
%timeit a+a
625 loops, best of 3: 523 µs per loop
x = libgap(2)
type(x)
<type 'sage.libs.gap.element.GapElement_Integer'>
%timeit x+x
625 loops, best of 3: 895 ns per loop
523 / .895
584.357541899441
a + a
4
a + f
4
type(a+f)
<class 'sage.interfaces.gap.GapElement'>
b = gp(2)
c = maxima(2)
d = singular(2)
e = 2
f = int(2)
type(a) type(b) type(c) type(d) type(e) type(f)
<class 'sage.interfaces.gap.GapElement'> <class 'sage.interfaces.gp.GpElement'> <class 'sage.interfaces.maxima.MaximaElement'> <class 'sage.interfaces.singular.SingularElement'> <type 'sage.rings.integer.Integer'> <type 'int'>
a + c
4
gap.version()
'4.7.8'
gap ︠a5da4d26-65d2-4f1e-8528-53697f153af5s︠ 4.multifactorial??
File: /projects/sage/sage-6.10/src/sage/rings/integer.pyx Source: def multifactorial(self, int k): r""" Computes the k-th factorial `n!^{(k)}` of self. For k=1 this is the standard factorial, and for k greater than one it is the product of every k-th terms down from self to k. The recursive definition is used to extend this function to the negative integers. EXAMPLES:: sage: 5.multifactorial(1) 120 sage: 5.multifactorial(2) 15 sage: 23.multifactorial(2) 316234143225 sage: prod([1..23, step=2]) 316234143225 sage: (-29).multifactorial(7) 1/2640 """ if k <= 0: raise ValueError, "multifactorial only defined for positive values of k" if not mpz_fits_sint_p(self.value): raise ValueError, "multifactorial not implemented for n >= 2^32.\nThis is probably OK, since the answer would have billions of digits." cdef int n = mpz_get_si(self.value) # base case if 0 < n < k: return one # easy to calculate elif n % k == 0: factorial = Integer(n/k).factorial() if k == 2: return factorial << (n/k) else: return factorial * Integer(k)**(n/k) # negative base case elif -k < n < 0: return one / (self+k) # reflection case elif n < -k: if (n/k) % 2: sign = -one else: sign = one return sign / Integer(-k-n).multifactorial(k) # compute the actual product, optimizing the number of large # multiplications cdef int i,j # we need (at most) log_2(#factors) concurrent sub-products cdef int prod_count = <int>ceil_c(log_c(n/k+1)/log_c(2)) cdef mpz_t* sub_prods = <mpz_t*>check_allocarray(prod_count, sizeof(mpz_t)) for i from 0 <= i < prod_count: mpz_init(sub_prods[i]) sig_on() cdef residue = n % k cdef int tip = 0 for i from 1 <= i <= n//k: mpz_set_ui(sub_prods[tip], k*i + residue) # for the i-th terms we use the bits of i to calculate how many # times we need to multiply "up" the stack of sub-products for j from 0 <= j < 32: if i & (1 << j): break tip -= 1 mpz_mul(sub_prods[tip], sub_prods[tip], sub_prods[tip+1]) tip += 1 cdef int last = tip-1 for tip from last > tip >= 0: mpz_mul(sub_prods[tip], sub_prods[tip], sub_prods[tip+1]) sig_off() cdef Integer z = PY_NEW(Integer) mpz_swap(z.value, sub_prods[0]) for i from 0 <= i < prod_count: mpz_clear(sub_prods[i]) sage_free(sub_prods) return z

SageMath in a Worksheet in SMC

︠08e293ff-845d-4f36-a881-95f7b1c318ads︠ %var x, y complex_plot(sin(x)^2, (x, -2,2), (y, -2, 2))
1+1
2
diff(1 + x + x^2, x)
2*x + 1
@interact def interactive_function(a = slider(0, 10, .05, default=4), b = (-3, 3, .1)): f(x) = b * x^2 + sin(a * x) plot(f, (x, -5, 5)).show()
Interact: please open in CoCalc
%var u, v fx = (3*(1+sin(v)) + 2*(1-cos(v)/2)*cos(u))*cos(v) fy = (4+2*(1-cos(v)/2)*cos(u))*sin(v) fz = -2*(1-cos(v)/2) * sin(u) parametric_plot3d([fx, fy, fz], (u, 0, 2*pi), (v, 0, 2*pi), color="green", opacity=.7, mesh=1, spin=5)
3D rendering not yet implemented
︠37968c0e-5af4-4f78-91da-d661ee044ef8︠