Page 1 of 1

import sympy def S(x): # YOUR CODE HERE raise NotImplementedError() def D(x,n): # YOUR CODE HERE raise N

Posted: Wed Apr 27, 2022 3:31 pm
by answerhappygod
Import Sympy Def S X Your Code Here Raise Notimplementederror Def D X N Your Code Here Raise N 1
Import Sympy Def S X Your Code Here Raise Notimplementederror Def D X N Your Code Here Raise N 1 (19.21 KiB) Viewed 59 times
Import Sympy Def S X Your Code Here Raise Notimplementederror Def D X N Your Code Here Raise N 2
Import Sympy Def S X Your Code Here Raise Notimplementederror Def D X N Your Code Here Raise N 2 (109.79 KiB) Viewed 59 times
import sympy
def S(x):
# YOUR CODE HERE
raise NotImplementedError()
def D(x,n):
# YOUR CODE HERE
raise NotImplementedError()
def T(a):
# YOUR CODE HERE
raise NotImplementedError()
from nose.tools import assert_equal
import sympy
x, y = sympy.symbols('x,y')
assert_equal(S(x),sympy.Poly(-x**8/3 - 2*x**2/3 +
1,domain=sympy.QQ))
from nose.tools import assert_equal
x, y = sympy.symbols('x,y')
assert_equal(D(x,1),sympy.Poly(-8/3*x**7 - 4/3*x, x,
domain=sympy.QQ))
from nose.tools import assert_equal
from nose.tools import assert_equal
x, y = sympy.symbols('x,y')
assert_equal(D(x,9),sympy.Poly(0,x,domain=sympy.QQ))
from nose.tools import assert_equal
x, y = sympy.symbols('x,y')
assert_equal(T(sympy.Rational(1,2)),sympy.Rational(6527,13824))
The sequence of functions Fn(x, y) for (n > 0) is defined by the recurrence formula Fo(x, y) = 1, F1(x, y) = *- y2 = and 2n? Fn+1 (x, y) = 2nxyFn(x, y) – (2n + 1)Fn–1(x, y), = n>1.
(c) Consider the following function of two variables: G(x, y) = 1 + x²y2 Use SymPy for the following: 1. Write a function S with a parameter x to evaluate the function S(x) given by the following integral: S(x) = Ą G(x, y)dy as a symbolic expression in x. 2. Write a function D(x, n) which takes as arguments a symbol x and an integer n to evaluate the n-th derivative of S(x) with respect to x. 3. Finally write a function T(a) with one argument a given by a sympy.Rational to evaluate the integeral st . T(a) = $ S(x)dx. The functions S(x) and $D(x,n) should both return polynomials of the type sympy. Poly , variable x and domain sympy. QQ. The function T(a) should return a sympy.Rational 4. Finally write a function I (without arguments) to evaluate the integeral The functions S(x) and D(x, n) should both return polynomials of the type sympy. Poly , variable x and domain sympy. QQ . Hint: . • Note that the the output of "sympy.integrate" is not a SymPy polynomial. Note that the function "sympy.diff" does not accept a SymPy polynomial as input. • To convert input and output you might find the functions.as_expr and as_poly useful.