(MWE at the end of the post)
I need to solve a non-linear equation $f(y;x_1,x_2,..,x_5)$ in one variable $y$ and then compute 4 new output expressions, for over 60 different initial parameter inputs of $x_i$. The 4 output variables which are as follows:
$g_m(y,x_1,..,x_5) \; \forall m$
The main equation will solve for the variable $y(i)$:
$f(y(i),x_1(i),x_2(i),...,x_5(i))=0 \; \forall \; i \in \{1,60\}$
Now my
$f(y(i),x_1(i),x_2(i),...,x_5(i))=A1(y,x_1,..,x_5)*y^{k_1} + B1(y,x_1,..,x_5)*y^{k_2}-c1(x_1,..,x_5)$
I define variables
A1=A1(y,x1,..,x5);
B1=B1(y,x1,..,x5);
c1=c1(x1,..,x5);
g1=g1(y,x1,..,x5);
g2=g2(y,x1,..,x5);
g3=g3(y,x1,..,x5);
g4=g4(x1,..,x5);
I have data for $x_1(i),..,x_5(i)$ in a CSV file that I Import and Table straight into the variable names making them into lists.
datatemp = Import["C:\\Documents\\2012U26G0.csv"];
j = Dimensions[datatemp][[1]]
kk=2
x1 = Table[datatemp[[i, 3]], {i, kk, j}]
x2 = Table[datatemp[[i, 4]], {i, kk, j}]
x3 = Table[datatemp[[i, 5]], {i, kk, j}]
x4 = Table[datatemp[[i, 6]], {i, kk, j}]
x5 = Table[datatemp[[i, 7]], {i, kk, j}]
I think this automatically makes my earlier defined formulae for $A1$,$B1$ and $g_m$ into a list of formulae with the only unknown being $y$ and it makes $c1$ into a list of constants since $c1$ was only dependent on $x_i$.
Now, what I would like to be able to do is the following. Give some initial search point for my FindRoot for $i=1$
sol={1,1,1,1,120}
As you will see in a second, I only care about
sol[[5]]
Due to continuity, the roots move monotonically with $i$ so once I find one root, I can get a sense of where to look for the next one so I substitute the previous solution into the search for the next one. Also, in one shot I compute the 4 output variables I need. So when the Table is run, in one shot I have all the output data I want.
outputdata=Table[sol={g1,g2,g3,g4,y} /. FindRoot[ A1[[i]]*(y[[i]])^(k1) + B1[[i]]*(y[[i]])^(k2)==c[[i]] , {y, sol[[5]]+10, sol[[5]], sol[[5]]+20}], {i,1, 60}]
This process worked for a charm for little while but for a certain parameter space (by parameter I don't mean the $x_i$ I used earlier but a host of $\gamma$s and$\beta$s in my equations that I have suppressed so far), it has started giving me errors, 1/0 infinity type stuff, because of some assignment issues. Is there a clean and correct/good way to do this? I wanna be able to import a ton of data, Table my findroot to compute a whole bunch of data and Export it real fast. Please please please help!
MWE
f = y^(3.1276)*(A1) + y^(-0.5875)*(B1) + (c1)^2;
A1 = x1/y + x2*y + 3*x3;
B1 = x1*x3 + 1/(y*x2);
c1 = x1^3 + x2^5 - x3;
g1 = y^(x1) - x3*x2;
g2 = x1/y;
Imported Data Below:
x1 = {89, 88, 87}
x2 = {0.048334203`, 0.048515211`, 0.048707816`}
x3 = {-19486.2273`, -19742.04035`, -20016.22863`}
When I do this, I can see what the curves look like:
Plot[Table[y^(3.1276)*(A1[[i]]) + y^(-0.5875)*(B1[[i]]) + (c1[[i]])^2, {i, 1,
3}], {y, 150, 180}]
This is what I want to do. To be able to Table a whole bunch of output in one shot:
dataoutput=Table[{g1[[i]], g2[[i]], y} /. FindRoot[y^(3.1276)*(A1[[i]]) +
y^(-0.5875)*(B1[[i]]) + (c1[[i]])^2, {y, 165, 150, 170}], {i, 1,
3}]
This is the result that I get, with some errors about accuracygoal and precisiongoal.
{{1623.03, -6.88842*10^19, 167.181}, {1530.37, -5.38632*10^19,
163.049}, {1431., -4.18019*10^19, 158.952}}
My MWE is working, just like my actual problem worked for a certain parameter space but now I am running into trouble. Is there a good way to Import a ton of Data, Table my FindRoot and generate a ton of output using Table and then Export my results? Thanks.