How can I get the plot of the function, y = x**(3/5)*(4-x)?
I used this code:
import matplotlib.pyplot as plt
import numpy as np
# def pow35(x):
# if x >= 0:
# return x**0.6
# elif x < 0:
# return -(-x)**0.6
x = np.linspace(-5,5,100)
# y = pow35(x)*(4-x)
y = x**(3/5)*(4-x)
plt.plot(x,y)
plt.show()
but it only plots from 0 to 5, the negative part is ignored.
I also tried to use a customized function like pow35(), but it outputs this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in pow35
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()