0
0
SciPydata~20 mins

Special functions overview (scipy.special) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Special Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Bessel function calculation
What is the output of this code snippet that calculates the Bessel function of the first kind for x=1.0 and order 0?
SciPy
from scipy.special import jv
result = jv(0, 1.0)
print(round(result, 4))
A0.7652
B0.5403
C0.8415
D1.0000
Attempts:
2 left
💡 Hint
Recall that jv(0, x) is the Bessel function of the first kind of order 0.
data_output
intermediate
2:00remaining
Output array from gamma function
What is the output array when applying the gamma function to the list [1, 2, 3, 4] using scipy.special.gamma?
SciPy
from scipy.special import gamma
import numpy as np
input_array = np.array([1, 2, 3, 4])
output_array = gamma(input_array)
print(np.round(output_array, 2))
A[1. 1. 2. 6.]
B[1. 2. 6. 24.]
C[0. 1. 2. 6.]
D[1. 1. 1. 1.]
Attempts:
2 left
💡 Hint
Remember gamma(n) = (n-1)! for positive integers n.
visualization
advanced
3:00remaining
Plotting the error function erf(x)
Which option produces the correct plot of the error function erf(x) over the range -3 to 3?
SciPy
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import erf
x = np.linspace(-3, 3, 100)
y = erf(x)
plt.plot(x, y)
plt.title('Error function erf(x)')
plt.grid(True)
plt.show()
AA sinusoidal wave oscillating between -1 and 1
BA smooth S-shaped curve crossing zero at x=0, ranging from about -1 to 1
CA straight line increasing from -3 to 3
DA parabola opening upwards with vertex at zero
Attempts:
2 left
💡 Hint
The error function is an S-shaped curve that goes from -1 to 1.
🧠 Conceptual
advanced
1:30remaining
Understanding the output of sph_harm function
What does the scipy.special.sph_harm function compute?
ASpherical volume calculation for given radius
BSpherical Bessel function values for given order and radius
CSpherical coordinates conversion from Cartesian coordinates
DSpherical harmonics values for given order and degree at specified angles
Attempts:
2 left
💡 Hint
Spherical harmonics are functions on the surface of a sphere used in physics and engineering.
🔧 Debug
expert
2:00remaining
Identify the error in this code using scipy.special.lambertw
What error does this code produce and why? from scipy.special import lambertw result = lambertw(-2) print(result)
SciPy
from scipy.special import lambertw
result = lambertw(-2)
print(result)
AValueError: Lambert W function not defined for input less than -1/e
BTypeError: lambertw() missing required positional argument
CNo error, prints a complex number
DSyntaxError: invalid syntax in import statement
Attempts:
2 left
💡 Hint
Lambert W function is only defined for inputs >= -1/e approximately -0.3679.