-1

I have written this code and I think is give me not correct answer. Could anyone please help me to discover my mistake? I'm trying to solve polynomial equation to find the constant which is W - Wr = a (W – 1) +b(W – 1)^2 +c(W – 1)^3

My code is

WrRSnFP = 1.89279768  
WrRZnFP = 2.56891730  
WrRAlFP = 3.37600860  

WT90SnFP = 1.8925821
WT90ZnFP = 2.5685184
WT90AlFP = 3.3753692

deviationSnFP = WT90SnFP - WrRSnFP 
deviationZnFP = WT90ZnFP - WrRZnFP 
deviationAlFP = WT90AlFP - WrRAlFP

x1 = WT90SnFP - 1 
x2 = x1**2   
x3 = x1**3      

y1 = WT90ZnFP - 1   
y2 = y1**2   
y3 = y1**3      

z1 = WT90AlFP - 1   
z2 = z1**2   
z3 = z1**3   

deviation = np.array([[x1,y1,z1],[x2,y2,z2],[x3,y3,z3]])

deviationFunctions = np.array([deviationSnFP,deviationZnFP,deviationAlFP])
 constant = np.linalg.solve(deviation, deviationFunctions)

print constant

The result I got is

[ 1.45993095e-04 -2.42110386e-04 1.42562145e-05]

in another program EXCEL the constant was different such as

[ -2.2415485E-04 -1.9763300E-05 3.4041874E-07]

Ismail
  • 39
  • 1
  • 6

1 Answers1

0

I found my mistakes it the order in the matrix

deviation = np.array([[x1,y1,z1],[x2,y2,z2],[x3,y3,z3]])

It should be like this

deviation = np.array([[x1,x2,x3],[y1,y2,y3],[z1,z2,z3]])
deviationFunctions = np.array([deviationSnFP,deviationZnFP,deviationAlFP])
constant = np.linalg.solve(deviation, deviationFunctions)
print constant

I will get the same answer as excel give me.

[ -2.24154846e-04 -1.97632998e-05 3.40418736e-07]

Ismail
  • 39
  • 1
  • 6