TypeError: can only concatenate tuple (not "float") to tuple with functions

Viewed 22

i'm trying to graphic the derivate of f in function of theta for values of b from 0.0 to 1.0 , i've to graph 10 curves for each value of b in only one graph but still keeps poping up the error TypeError: can only concatenate tuple (not "float") to tuple. this is the code

import numpy as np
import matplotlib.pyplot as plt 

theta = np.linspace(0,0.5*np.pi,100)
h= 1e-9

plt.figure()

for b in np.arange(0.1,1.1,0.1):
    
    def f(theta,b):
        return np.cos(theta)+b*(np.sin(theta))**2

    def deriv(f):
        return (f((theta,b)+h)-f(theta))/h

    plt.plot(theta,deriv(theta,b))
    plt.title('Derivada númerica del potencial')
    plt.xlabel(r'$ Ángulo\; \theta $')
    plt.ylabel('Valor de la derivada evaluada en 'r'$\theta$')
    plt.show()

0 Answers
Related