You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For part c of problem 1, I am struggling with finding the newton-raphson roots. I suspect that this issue may be a result of my f_T or dfdT functions, but I am not sure. These are my functions:
def f_T(T):
return (sigmoid(T)-0.5)
This is my input to the newtraph function and the resulting error:
vr, out = newtraph(f_T,dfdT,65)
print(vr)
nan
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:5: RuntimeWarning: overflow encountered in exp
"""
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:5: RuntimeWarning: invalid value encountered in double_scalars
"""
Any help would be apppreciated!
The text was updated successfully, but these errors were encountered:
So this is what i had for my dfDT function: def dfdT(x, a0=15.043, a1=0.232): dfdT = (-a1*np.exp(a0-a1*x))/(1+np.exp(a0-(a1*x))**2) return dfdT
But overall, the code is not supposed to work. The way newtraph works is that it picks a point on a curve and draws a line tangent to that point. It then looks for where that line crosses the x-axis and that point is the estimated root. So if you try that at a local max/min, your line would be horizontal and never cross the x-axis. So in general, it is not suppose to work because dfDT = 0.
The Newton-Raphson method fails to converge if the x0 starting point is incorrectly choosen. This is because the Newton-Raphson method does not account for divergence in some cases when the function's x0 is not close enough to the root we are finding. For example in this case, the root is located at approximately T=64.8 using the Newton-Raphson method and through guess and check I determined that the range of accepted values for x0 is 55-75. If x0 is chosen in this range the function will work properly and return the root of our equation. However, if a number outside of this range is chosen using this method, a nan (not a number) error is given due to an attempt by python
to divide by zero. Rather than converging to the correct root outside of the accepted x0 range our Newton-Raphson method diverges thus causing the divide by zero error. I would recommend playing around with the x0 value in the following line of code when using Newton-Raphson:
'hr, out = newtraph(f_T,dfdT,x0)'
For part c of problem 1, I am struggling with finding the newton-raphson roots. I suspect that this issue may be a result of my f_T or dfdT functions, but I am not sure. These are my functions:
def f_T(T):
return (sigmoid(T)-0.5)
def dfdT(T):
return (14.811np.exp(14.811T))/((1+np.exp(14.811*T))**2)
This is my input to the newtraph function and the resulting error:
vr, out = newtraph(f_T,dfdT,65)
print(vr)
nan
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:5: RuntimeWarning: overflow encountered in exp
"""
/opt/conda/lib/python3.7/site-packages/ipykernel_launcher.py:5: RuntimeWarning: invalid value encountered in double_scalars
"""
Any help would be apppreciated!
The text was updated successfully, but these errors were encountered: