kill(all)$

maxima :concentration respons for distilation column ,interpolation outputref, 'version 1.0'
peter.vlasschaert@gmail.com,30/01/2021

ref :
===
---------------------------------------------------------------------------------------------------
maxima :concentration respons for distilation column ,lsoda 'version 1.0'
peter.vlasschaert@gmail.com,30/01/2021
---------------------------------------------------------------------------------------------------

load packages ,option:
==================

load(lrats)$
load(interpol)$
load(draw)$
ratprint:false$

fpprintprec : 3;

info: Menu → Numeric → Set displayed  precision → 3

analysis of data:
=============

1e)  step :data : output ( = concentration respons)
--------------------------------------------------------------------

m:matrix(
		[0.0,	0.5,	0.5,	0.5,	0.5],
		[0.1,	0.3972897941574036,	0.4911728803746155,	0.5111485516240798,	0.5865998020021514],
		[0.2,	0.3176306652618792,	0.4723356941459664,	0.5334362067705662,	0.653065883893571],
		[0.3,	0.2571456868863949,	0.4496560170335132,	0.5574672842226712,	0.7053253457179758],
		[0.4,	0.2124563178202132,	0.4262538169016527,	0.5792081454103729,	0.746844594987745],
		[0.5,	0.1801577828287726,	0.4041396675000161,	0.5971752227731854,	0.7799004567142652],
		[0.6000000000000001,	0.157097661952792,	0.3845751124803315,	0.611173682762622,	0.8061482427868479],
		[0.7000000000000001,	0.1406836315171823,	0.3681271940499865,	0.6216320819732809,	0.8268845897681323],
		[0.8,	0.1289664659914552,	0.3548131547926487,	0.6292193898009721,	0.8431664877982217],
		[0.9,	0.1205560293107949,	0.3443213767233031,	0.6346176814732328,	0.8558717960210386],
		[1.0,	0.114482061333312,	0.3362040518083931,	0.6384179533562236,	0.8657286425800831]
	);

rem :0.6000000000000001  → 0.6

[m[2,2],m[2][2]];/* both notation : element position in matrix */

p1:table_form(m)$

→  Tableform: ( from matrix :m)

titleList:["time","x1","x2","x3","x4"]$

m1:matrix(titleList,args(m)[1]);

p2:args(m);

m2:[titleList];

for i:1 thru length(p2) do(
m2:endcons(p2[i],m2)
)$

→   Final table

m3:table_form(m2)$

2e) step : xy data ( x= time , y = xi), i=1,2,3,4
-------------------------------------------------------------

curve ( x=time  & y = x1)

a)  dimension : matrix

matsize(A):=[length(A),length(transpose(A))];

b)  xy data

xydata(kk,mx):=makelist([mx[ll][1],mx[ll][kk]],ll,1,matsize(mx)[1])$

xydata(2,m);

kl:length(%);

3e)  step : interpolation methods.
------------------------------------------------

→ method : lagrange interpolation

p3:lagrange(xydata(2,m));

p3a:expand(p3);/*lagrange interpolation polynomial */

p3a1:hipow(p3a,listofvars(p3a)[1]);/*highest power of the polynomial */

p3a2:lopow(p3a,listofvars(p3a)[1]);/*lowest power of the polynomial */

p3b: print("number points =",kl,"degree polynomial p3a in x = ",p3a1)$

f1(x):=lagrange(xydata(2,m));

check :data ?
--------------------

p4a:subst([x=0.1],f1(x));

data : f1(x)

p4a1:makelist(subst([x=l],f1(x)),l,0,1,0.1);

data: xydata(2,m)

p4a2:makelist(xydata(2,m)[ll][2],ll,1,length(xydata(2,m)));

p4b:is(xydata(2,m)[2][2]=p4a);

all data 

p4b1:map("=",p4a1,p4a2);

plot2d :f1(x) & data

wxplot2d([f1(x),[discrete,xydata(2,m)]],
[x,0,1],
[style,lines,points],
[legend,"f1(x)","xydata(2,m)"],
[xlabel,"time"],[ylabel,"x1"],
[title,"method:lagrange interpolation"]);

→ method : linear method

p5:linearinterpol(xydata(2,m));

f2(x):=''p5;

use : p4a2

 =>  x  values

p5a:p4a2;

 =>  x values  into  f2(x)

p5a1:map(f2,p4a2);

wxdraw2d(color=red,
key = "linear interpolation",
explicit(f2(x),x,0,xydata(2,m)[length(xydata(2,m))][1]),
point_size = 2,
color = blue,
key = "xydata(2,m)",                
points(xydata(2,m))
)$

→ method : Cubic-Spline method

p6:cspline(xydata(2,m));
f3(x):=''p6;

wxdraw2d(color=red,
key = "Cubic-Spline interpolation",
explicit(f3(x),x,0,xydata(2,m)[length(xydata(2,m))][1]),
point_size = 2,
color = blue,
key = "xydata(2,m)",                
points(xydata(2,m))
)$

→ method : Rational Interpolation method

p7:p3a1;

wxdraw2d(color=red,
key = "rational interpolation interpolation",
explicit(ratinterpol(xydata(2,m),p7)
        ,x,0,1),
point_size = 2,
color = blue,
key = "xydata(2,m)",                
points(xydata(2,m))
)$

what when we select polynomial: not 10  only  1 , p7=1, above graph

p8:ratinterpol(xydata(2,m),1);

   =>  rational expression.   ( p/q = num/denom )

p8a:ratsimp(p8)$

 => p7 =1, numerator  = 1,denominator = 9

p8b1:num(p8a);

p8b2:denom(p8a);

wxdraw2d(color=red,
key = "rational interpolation interpolation",
explicit(p8,x,0,xydata(2,m)[length(xydata(2,m))][1]),        
point_size = 2,
color = blue,
key = "xydata(2,m)",                
points(xydata(2,m))
)$