No video

Root Finding in Python

  Рет қаралды 12,174

HagesLab

HagesLab

Күн бұрын

Learn how to numerically find roots of complex equations in python.
Script can be found here: 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]

Пікірлер: 6
@marocaineaucanada7538
@marocaineaucanada7538 Жыл бұрын
MERCI BEAUCOUP TRES INTERESSANT
@javierruiz3876
@javierruiz3876 2 жыл бұрын
What if I'm getting the error "Result from function call is not a proper array of floats."
@charles3943
@charles3943 2 жыл бұрын
what if the equation doesnt equal to zero? where should we define this specific value? for the heat transfer example...
@mohamedyusufmohamud8193
@mohamedyusufmohamud8193 2 жыл бұрын
should we include sigma variable in our function even though it is a constant but you didn't add it .
@bishalkarki8178
@bishalkarki8178 2 жыл бұрын
You should zoom the content,not clearly visible.
@asifahmadi116
@asifahmadi116 15 күн бұрын
first thanks a lot for the excellent video and good description then I have a question how can you find the roots of this equation: R = ∑_(k=1)^(k=100)▒∑_(j=-100)^(j=100)▒(e^12 〖 (12)〗^k )/k! k/(2π(w^2+1/4)) √(1-〖(w/(LkR^2 ))〗^2 ) ∆w ∆k , ∆k=1,∆w=LkR^2/100
How to: Plot a Function in Python
13:47
HagesLab
Рет қаралды 122 М.
Finding Zeros of Functions In Python (Bisection Method and Scipy)
15:26
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 39 МЛН
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 866 М.
How to: Solve an ODE in Python (Boundary Value Problem)
48:35
The Clever Way to Count Tanks - Numberphile
16:45
Numberphile
Рет қаралды 802 М.
1st Year Calculus, But in PYTHON
32:13
Mr. P Solver
Рет қаралды 123 М.
How To Code A Quantum Computer
20:42
Lukas's Lab
Рет қаралды 546 М.
Unlocking your CPU cores in Python (multiprocessing)
12:16
mCoding
Рет қаралды 299 М.
Modern Python logging
21:32
mCoding
Рет қаралды 170 М.
How to: Numerical Derivative in Python
10:45
HagesLab
Рет қаралды 23 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 39 МЛН