Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to find a zero of this function?
#1
I have many input parameters and a function in the end of the following code. The unknown parameter is the "Fi". I tried to find a zero of the last function, but I could make only an iteration for this problem. Can you please help me to find a better function for determining "Fi"? Thank you :-)
n=7
di=[4,2,1,0.5,0.25,0.125,0.0625]
beta_i=np.array([0.606,0.606,0.575,0.568,0.563,0.541,0.506],np.float32)
fi_i=np.array([0.535,0.546,0.525,0.469,0.513,0.500,0.485],np.float32)
yi=np.array([0.022,0.201,0.096,0.063,0.315,0.249,0.054],np.float32)
K=4.10
aij=0.712
bij=0.651
p01=0
p02=(1-beta_i[1]+bij*beta_i[1]*(1-1/beta_i[0]))*yi[0]
p03=(1-beta_i[2]+bij*beta_i[2]*(1-1/beta_i[1]))*yi[1]
p04=(1-beta_i[3]+bij*beta_i[3]*(1-1/beta_i[2]))*yi[2]
p05=(1-beta_i[4]+bij*beta_i[4]*(1-1/beta_i[3]))*yi[3]
p06=(1-beta_i[5]+bij*beta_i[5]*(1-1/beta_i[4]))*yi[4]
p07=(1-beta_i[6]+bij*beta_i[6]*(1-1/beta_i[5]))*yi[5]
q01=(1-(aij*(beta_i[0]/beta_i[1])))*yi[1]
q02=(1-(aij*(beta_i[1]/beta_i[2])))*yi[2]
q03=(1-(aij*(beta_i[2]/beta_i[3])))*yi[3]
q04=(1-(aij*(beta_i[3]/beta_i[4])))*yi[4]
q05=(1-(aij*(beta_i[4]/beta_i[5])))*yi[5]
q06=(1-(aij*(beta_i[5]/beta_i[6])))*yi[6]
q07=0
P=[p01,p02,p03,p04,p05,p06,p07]
Q=[q01,q02,q03,q04,q05,q06,q07]
sump1=0
sump2=0
sump3=np.sum(P[0:1])
sump4=np.sum(P[0:2])
sump5=np.sum(P[0:3])
sump6=np.sum(P[0:4])
sump7=np.sum(P[0:5])
sumq1=np.sum(Q[1:6])
sumq2=np.sum(Q[2:6])
sumq3=np.sum(Q[3:6])
sumq4=np.sum(Q[4:6])
sumq5=np.sum(Q[5:6])
sumq6=0
sumq7=0
gamma_1=beta_i[0]/(1-sumq1)
gamma_2=beta_i[1]/(1-sumq2)
gamma_3=beta_i[2]/(1-sump3-sumq3)
gamma_4=beta_i[3]/(1-sump4-sumq4)
gamma_5=beta_i[4]/(1-sump5-sumq5)
gamma_6=beta_i[5]/(1-sump6-sumq6)
gamma_7=beta_i[6]/(1-sump7-sumq7)
gamma_i=np.array([gamma_1,gamma_2,gamma_3,gamma_4,gamma_5,gamma_6,gamma_7],np.float32)
def error(Fi):
    return (K-((yi/beta_i)/(1/Fi-1/gamma_i)).sum())
print(error(0.482))
Larz60+ wrote Jan-13-2020, 11:22 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote
#2
(Jan-13-2020, 08:54 AM)kkitti93 Wrote: I have many input parameters and a function in the end of the following code. The unknown parameter is the "Fi". I tried to find a zero of the last function, but I could make only an iteration for this problem. Can you please help me to find a better function for determining "Fi"? Thank you :-)

Can you quantify better, please?
Do you want something faster or do you need it to be simpler code, or do you want more pythonic code?
It's hard to tell.
Also, please describe your math.
Quote
#3
Sure, Im sorry, Im just a beginner, I know my description is not the best, I'll try it again:
I think it will be the best way if I show you the original mathematical problem. Please find the equations here:
https://www.cnczone.com/forums/attachmen...124.attach
The final equation is the 4th one, where the unknown parameter is the Fi (Ø). I can get all of the other parameters experimentally.
So, I would like to calculate this parameter (Ø), but I can only get it by an iterative way with this code. So I try some values for the Fi, and I get the difference between the real value and mine (error). So I am wondering if there is a way to find a function to calculate the precise value of the Fi.

Thank you for your help!
Quote
#4
Much clearer, thank you. This looks like fun. I'll take a crack at it tonight or tomorrow.
Quote
#5
Thank you very much, this is a great help for me!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Create a function to find words of certain length ag4g 2 537 Apr-21-2019, 06:20 PM
Last Post: BillMcEnaney
  How to you find the file where a class or a function was implemented? MisterX 4 1,653 Mar-16-2017, 09:51 AM
Last Post: wavic

Forum Jump:


Users browsing this thread: 1 Guest(s)