Iterative process

Hi,

I need to solve iteratively the following equation: Y=A(t) *B(Y) using the values of the following two sets .

t= [ 0.05,0.1,0.2,0.5,1,2,5,10]

A=[0.9,0.75,0.6,0.2,0.08,0.06,0.051,0.05]

 and

Y=[25,50,75,100,125,150,175,200,225,400,500,700,1000]

B=[3250,2500,2000,1725,1550,1400,1325,1275,1225,950,850,775,775]

so that I can get Y as a function of t. What do you suggest would be the most precise way to do this using maple?

Thanks for your time

 

alec's picture

interpolation

It doesn't look iterative. Anyway, one can interpolate B as a function of Y, then find solutions for given values of A, and interpolate them for corresponding values of t. For example, using splines,

t:= [ 0.05,0.1,0.2,0.5,1,2,5,10];
A:=[0.9,0.75,0.6,0.2,0.08,0.06,0.051,0.05];
Y:=[25,50,75,100,125,150,175,200,225,400,500,700,1000];
B:=[3250,2500,2000,1725,1550,1400,1325,1275,1225,950,850,775,775];
b:=unapply(CurveFitting:-Spline(Y,B,y),y);
R:=[seq(fsolve(y=A[i]*b(y)),i=1..nops(A))];
sol:=unapply(CurveFitting:-Spline(t,R,T),T);

The result doesn't look very nice though, see

plot(sol,0..10);

Alec

Robert Israel's picture

interpolation or fit

If the data are not exact but only approximate, it's probably better to use some sort of least-squares approximation rather than interpolation.
For A(t), it looks to me like a constant plus an exponential might be a good fit.  For B(Y), maybe a linear combination of two powers.
 

> with(Optimization):
  Tdata:= [ 0.05,0.1,0.2,0.5,1,2,5,10];
  Adata:=[0.9,0.75,0.6,0.2,0.08,0.06,0.051,0.05];
  TAdata:= zip(`[]`,Tdata,Adata);
  Ydata:=[25,50,75,100,125,150,175,200,225,400,500,700,1000];
  Bdata:=[3250,2500,2000,1725,1550,1400,1325,1275,1225,950,850,775,775];
  YBdata:= zip(`[]`,Ydata,Bdata);
> LSSolve([seq(a*exp(-b*t[1])+c-t[2], t=TAdata)],a=0..2,b=0..10,c=0..0.05);
  abcsol:= %[2]:
[.153978516741551343e-2, [a = 1.01417137085351183, b = 3.44529358752753190, c = .493817324139047345e-1]]
> LSSolve([seq(d*t[1]^e + f*t[1]^g - t[2], t=YBdata)],initialpoint=[d=61875,e=-1,f=775,g=0]);
  defgsol:= %[2]:
[8673.2079345120, [d = 14439.2026115278204, e = -.459166232139629204, f = .694147751171305478e-6, g = 2.79586264024487852]]
> eq:= y = (a*exp(-b*t) + c)*(d*y^e + e*y^f);
  tsol := solve(eq, t);
= -ln(-(-y+c*d*y^e+c*e*y^f)/a/(d*y^e+e*y^f))/b
> tf:= unapply(subs(abcsol,defgsol,tsol),y);
= y -> -.2902510264*ln(-.9860266505*(-y+713.0328395/y^.459166232139629204-.2267442401e-1*y^.694147751171305478e-6)/(14439.2026115278204/y^.459166232139629204-.459166232139629204*y^.694147751171305478e-6))
> plot(tf(y),y=25 .. 1000);


 

 

 

Robert Israel's picture

y as a function of t

Sorry, I gave you t as a function of y rather than the reverse.

> yf:= t -> fsolve(eval(y = (a*exp(-b*t) + c)*(d*y^e + e*y^f),{op(abcsol),op(defgsol)}),y=0..1000);
> yf(1);

127.4000077

> plot(yf, 0 .. 10, labels = [t,y]);

  

acer's picture

syntax

Could someone please explain the syntax used in stating this problem? Thanks.

[updated] Please ignore the above. I've got it now.

acer

Almost there

Thank u all so much for your suggestions.

Robert, for A(t) i would expect a double exponential : A = a*exp(-t/b)+c*exp(1/(t+d)) and   for B(Y) maybe : B=f*exp(-g*Y)+k

Ive tried to fit the data similarily the way u showed me but i must be doing something wrong. 1)  Could u please help me with that? in your example are the numebrs for d,e,f,g random values?

I have worked out these equations in the past but im not sure how they compare with wht u suggest if they are of any help:

For A=1.027*exp(-t/(.282))+0.051*exp(1/(t+1.766*10^90))   [1]

and B=2.433*10^3*exp(-0.008*Y)+780  [2]       but still my results are a bit off from wht they should be.

2) For A(t) i have almost 100 points in an excel file. Is there a simple way to enter this data in maple or do I have to type them in the Adata/Tdata format as above?

3) If u plot yf as shown below ( X axis log) for t=0.038 there is a small discontinouity. It happens even if i substitute [1], [2] in   Y=A(t) *B(Y) but only in maple. Any ideas why?

> with(Optimization); Tdata := [0.5e-1, .1, .2, .5, 1, 2, 5, 10]; Adata := [.9, .75, .6, .2, 0.8e-1, 0.6e-1, 0.51e-1, 0.5e-1]; TAdata := zip(`[]`, Tdata, Adata); Ydata := [25, 50, 75, 100, 125, 150, 175, 200, 225, 400, 500, 700, 1000]; Bdata := [3250, 2500, 2000, 1725, 1550, 1400, 1325, 1275, 1225, 950, 850, 775, 775]; YBdata := zip(`[]`, Ydata, Bdata);
> LSSolve([seq(a*exp(-b*t[1])+c-t[2], t = TAdata)], a = 0 .. 2, b = 0 .. 10, c = 0 .. 0.05); abcsol := %[2];
> LSSolve([seq(d*t[1]^e+f*t[1]^g-t[2], t = YBdata)], initialpoint = [d = 61875, e = -1, f = 775, g = 0]); defgsol := %[2];
Warning, limiting number of iterations reached
>
> yf := proc (t) options operator, arrow; fsolve(eval(y = (a*exp(-b*t)+c)*(d*y^e+e*y^f), {op(abcsol), op(defgsol)}), y = 0 .. 1000) end proc;
> yf(1);
127.3895493
> plot(yf, 0.01 .. 10, axis[1] = [mode = log], labels = [t, y]);
 

Thanks in advance for your time.

Robert Israel's picture

Discontinuity?

I see no discontinuity near t = 0.038.  Can you upload your plot showing that?

alec's picture

ExcelTools:-Import

ExcelTools:-Import can be used for importing data from Excel.

Alec

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}