so I am new to Python and using it as a tool for research. So excuse my noob-ness 😀
I wanted to plot a function which is defined by an integral (that cannot be solved analytically) and the independent variable is the lower bound of this integral. Before I get to that step, I wanted to check if the numerical integration works at a single point (i.e. lower limit of the integral is 4, say) just to see if everything is in order. In the code below ‘Int’ is the integrand, which has the functions ‘b’ and ‘f’ in it as well, both functions of ‘r’.
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
import sympy as smp
from scipy.integrate import quad
r = smp.symbols('r', real = True)
s = 1
Mu = 0.5
lamb = 0.6
b = lambda r: ((r - s) * lamb + (s**2)*r)/(s*r)
f = lambda r: (1 - lamb/(s*r))**((s**2 + lamb)/lamb)
Int = 1/(r*((1 - b/r)*((r**2)/(Mu**2)*(1/f) - 1))**smp.Rational(1/2))
quad(Int, 4, smp.oo)
On running the above I get this error: “TypeError: unsupported operand type(s) for /: ‘function’ and ‘Symbol'”. Any beginner-friendly breakdown of this issue will be helpful, thanks 🙂
CatKing is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.