Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
74 views
ubuntu2004
Kernel: SageMath 9.8
n=var('n') def a(n): return x^(n+1)/((n+1)*5^(n+1))
r=abs(a(n+1)/a(n)) rho=limit(r,n=infinity) show(rho) #this is the ratio test basically

15x\displaystyle \frac{1}{5} \, {\left| x \right|}

solve(rho<1,x)
[[-5 < x, x < 0], [x == 0], [0 < x, x < 5]]
forget() assume(x<5) assume(x>-5) S=sum(a(n),n,0,infinity) show(S) #if final project asks to draw a conclusion, thne test the endpoints # ex: test the endpoints 1 and -1

log(15x+1)\displaystyle -\log\left(-\frac{1}{5} \, x + 1\right)

def f(x): return -log(-(1/5)*x+1)
f(-5)
-log(2)
f(5)
+Infinity

Example 2: (n(n-1)*x^(n-2))

n=var('n') def a(n): return (n*(n-1)*x^(n-2))
r=abs(a(n+1)/a(n)) rho=limit(r,n=infinity) show(rho)

x\displaystyle {\left| x \right|}

solve(rho<1,x)
[[-1 < x, x < 1]]
forget() assume(x<1) assume(x>-1) S=sum(a(n),n,0,infinity) show(S)

2x33x2+3x1\displaystyle -\frac{2}{x^{3} - 3 \, x^{2} + 3 \, x - 1}

def f(x): return -((2)/((x^3)-(3*x^2)+3*x-1))
f(-1)
1/4
f(1) #wont work bc division by 0 so do this endpoint by hand
--------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) Cell In [46], line 1 ----> 1 limit(f(Integer(1)),x=Integer(1)) Cell In [39], line 2, in f(x) 1 def f(x): ----> 2 return -((Integer(2))/((x**Integer(3))-(Integer(3)*x**Integer(2))+Integer(3)*x-Integer(1)))
File /ext/sage/9.8/src/sage/rings/integer.pyx:2019, in sage.rings.integer.Integer.__truediv__() 2017 if type(left) is type(right): 2018 if mpz_sgn((<Integer>right).value) == 0: -> 2019 raise ZeroDivisionError("rational division by zero") 2020 x = <Rational> Rational.__new__(Rational) 2021 mpq_div_zz(x.value, (<Integer>left).value, (<Integer>right).value)
ZeroDivisionError: rational division by zero

Approximate Taylor Polynomial

approximate e^x with 1,2, and 3 degree

n=var('n') @interact def _(m=input_box(2,label='Degree',width=10)): print("App1=",N(sum(1/factorial(n),n,0,m),digits=5)) #ex: if sin(x) you would use sin(2) for the approximation
Interactive function <function _ at 0x7f500ef4bf60> with 1 widget m: EvalText(value='2', description='Degree…
n=var('n') @interact def _(j=input_box(3,label='Degree',width=10)): print("App2=",N(sum(1/factorial(n),n,0,j),digits=5))
Interactive function <function _ at 0x7f500eec45e0> with 1 widget j: EvalText(value='3', description='Degree…
n=var('n') @interact def _(k=input_box(4,label='Degree',width=10)): print("App3=",N(sum(1/factorial(n),n,0,k),digits=5))
Interactive function <function _ at 0x7f500ef485e0> with 1 widget k: EvalText(value='4', description='Degree…
n=var('n') plot(sum(x^n/factorial(n),n,0,2),xmin=-10,xmax=10,color='blue',legend_label='degree2')+plot(sum(x^n/factorial(n),n,0,3),xmin=-10,xmax=10,color='red',legend_label='degree3')+plot(sum(x^n/factorial(n),n,0,4),xmin=-10,xmax=10,color='green',legend_label='degree4')+plot(e^x,xmin=-10,xmax=10,ymax=1000,color='black',legend_label='$e^x$')
Image in a Jupyter notebook