Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
12 views
Kernel: Unknown Kernel
import math math.sqrt(-1) math.asin(5)
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-5-0d68b6ad17b4> in <module>() 1 import math ----> 2 math.sqrt(-1) 3 math.asin(5) ValueError: math domain error
from cmath import sqrt sqrt(-1) sqrt(1j)
sqrt(5)
sqrt(1j)
from cmath import *
exp(pi*1j)
log(-5)
cos(1j)
(1.5430806348152437-0j)
a=2 b=3 c=a + b*1j print(c) print(c.real) print(c.imag) print(c.conjugate()) c**(2)
(2+3j) 2.0 3.0 (2-3j)
(-5+12j)
sqrt(4)
(2+0j)
from numpy.lib.scimath import *
print(sqrt(4)) print(sqrt(-4))
2.0 2j
a=1 b=0 c=-4 x1 = (-b + sqrt(b**2 - 4*a*c))/(2*a) x2 = (-b - sqrt(b**2 - 4*a*c))/(2*a) print('The roots of %gx^2 + %gx + %g are ' % (a,b,c) + str(x1) + ' and ' + str(x2) + '.')
The roots of 1x^2 + 0x + -4 are 2.0 and -2.0.
arccos(0.5)
1.0471975511965979
from sympy import symbols, diff, sqrt, integrate, Rational, lambdify, exp, limit a, b, c, t = symbols('a b c t') y = (-b + sqrt(b**2 - 4*a*c))/(2*a) z = t**3 + 2*exp(t)
dyda = diff(y, a) dyda dzdt = diff(z,t) dzdt
3*t**2 + 2*exp(t)
Y = integrate(dzdt,t) Y
t**3 + 2*exp(t)
quad = lambdify([a, b, c], y) quad(1, 2, -3) zfunc = lambdify([t],z) zfunc(3)
67.17107384637534
from sympy import simplify, expand, sin, cos z = (a+b)**5 z2 = expand(z) z2
a**5 + 5*a**4*b + 10*a**3*b**2 + 10*a**2*b**3 + 5*a*b**4 + b**5
f = sin(a)*cos(b)+sin(b)*cos(a) f2 = simplify(f) f2
sin(a + b)
f = sin(t)/t f.series(t,0,15)
1 - t**2/6 + t**4/120 - t**6/5040 + t**8/362880 - t**10/39916800 + t**12/6227020800 - t**14/1307674368000 + O(t**15)