Challenge - 5 Problems
Special Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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))
Attempts:
2 left
💡 Hint
Recall that jv(0, x) is the Bessel function of the first kind of order 0.
✗ Incorrect
The Bessel function jv(0, 1.0) returns approximately 0.7651977, rounded to 0.7652.
❓ data_output
intermediate2: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))
Attempts:
2 left
💡 Hint
Remember gamma(n) = (n-1)! for positive integers n.
✗ Incorrect
Gamma(1)=1, Gamma(2)=1, Gamma(3)=2, Gamma(4)=6, so the output array is [1, 1, 2, 6].
❓ visualization
advanced3: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()
Attempts:
2 left
💡 Hint
The error function is an S-shaped curve that goes from -1 to 1.
✗ Incorrect
The erf function smoothly transitions from -1 at negative infinity to 1 at positive infinity, crossing zero at x=0.
🧠 Conceptual
advanced1:30remaining
Understanding the output of sph_harm function
What does the scipy.special.sph_harm function compute?
Attempts:
2 left
💡 Hint
Spherical harmonics are functions on the surface of a sphere used in physics and engineering.
✗ Incorrect
sph_harm computes the complex spherical harmonic Y^m_n(theta, phi) for given order m, degree n, and angles theta, phi.
🔧 Debug
expert2: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)
Attempts:
2 left
💡 Hint
Lambert W function is only defined for inputs >= -1/e approximately -0.3679.
✗ Incorrect
lambertw(-2) returns a complex number; the function is defined for complex inputs and does not raise an error.