Defining your functions like you did
A1[[9]] = -0.097752 H1S^2.70499 - ... + (-0.763386 + 1702.13/H1S^1.70499)
(877653./H1S^1.70499 - 0.000389055 H1S^2.97166))
one gets :
Set::noval: Symbol A1 in part assignment does not have an immediate value. >>
This issue comes from an the fact that you use an immediate assignment to A1[[9]]
see (Part
) while there haven'tA1
hasn't been defined. You could have assigned to A1A1[[9]]
, use if you had evaluated e.g.
A1 = Table[0, {9}];
then you can do e.g.
A1[[9]] = 1;
A1
{0, 0, 0, 0, 0, 0, 0, 0, 1}
A more appropriate way is to define a function using SetDelayed
to A1[9, H1S_]
i.e. lhs := rhs — delayedlhs := rhs
delayed assignment where rhs is reevaluated every time it is used, i.e defininddefining A1
, B1
, c1
, use e.g. :
A1[9, H1S_] := formula for A1[[9]]
B1[9, H1S_] := formula for B1[[9]]
c1[9, H1S_] := formula for c1[[9]]
then FindRoot
returns the expected result without any (error) messages generated :
FindRoot[ A1[9, H1S]*(92)^(-1.7049946543060777) + B1[9, H1S]*(92)^(2.9716613209727445)
-c1[9, H1S]*80/0.057 + 65.89077138196083` == 0, {H1S, 125, 120, 135}]
{H1S -> 128.903}
You can plot the graph of this function the same way :
Plot[ A1[9, H1S]*(92)^(-1.7049946543060777) + B1[9, H1S]*(92)^(2.9716613209727445)
-c1[9, H1S]*80/0.057 + 65.89077138196083`, {H1S, 125, 135}, AxesOrigin -> {125, 0}]