Learn how to numerically find roots of complex equations in python.
Script can be found here: https://www.hageslab.com/Resources.ht...
Here we are using "Spyder" IDE with the numpy, scipy, and matplotlib libraries
Script:
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import fsolve
Arbitrary Example
def fxn1(x):
return x**2+3*x - np.exp(x**(1/2))
xlist = np.linspace(0,1,num=1000)
plt.figure(num=1,dpi=120)
plt.plot(xlist,fxn1(xlist),label="Fxn1")
plt.plot(xlist,xlist*0,"--",label="y=0")
plt.legend()
root = fsolve(fxn1,0.5)
def fxn2(Ts, Tinf, Ti, A, Rtot, h, eps, sigma=5.67e-8): # SI units
return (Tinf - Ti)/(A*Rtot) - (h+eps*sigma*(Ts+Tinf)*(Ts**2+Tinf**2))*(Tinf-Ts)
Tlist = np.linspace(283.15,308.15,num=1000)
plt.figure(num=2,dpi=120)
plt.plot(Tlist,fxn2(Tlist,283.15,308.15,1.8,0.25,2,.95),label="Fxn2") # SI units
plt.plot(Tlist,Tlist*0,"--",label="y=0")
plt.legend()
Ts = fsolve(fxn2,290,args=(283.15,308.15,1.8,.25,2,0.95)) # [K]
Ts_C = Tsf-273.15 # [C]
Auf dieser Seite können Sie das Online-Video Root Finding in Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer HagesLab 12 Januar 2021 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 13,909 Mal angesehen und es wurde von 168 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!