Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 UDK - UDC 510.5:004.42 Strokovni članek - Speciality paper (1.04) Uporaba gladilnih funkcij za glajenje podatkov podanih v diskretni obliki Using Spline Functions to Smooth Discrete Data Igor Emri - Robert Cvelbar (Fakulteta za strojništvo, Ljubljana) V prispevku je predstavljen algoritem za izračun gladilnih funkcij, uporabljen v programskem paketu “SPLINE”, razvitem v Centru za eksperimentalno mehaniko na Fakulteti za strojništvo v Ljubljani. Podana je podrobna analiza vpliva števila izbranih podintervalov in števila diskretnih vrednosti na natančnost približka. Uporabnost algoritma je prikazana na eksperimentalnih podatkih za realno in imaginarno komponento modula lezenja poli-izobutilena. Podatki, ki smo jih analizirali, so povzeti iz objave [5]. © 2006 Strojniški vestnik. Vse pravice pridržane. (Ključne besede: funkcije gladilne, glajenje podatkov, algoritmi, paketi programski, SPLINE) In this paper we present an algorithm for calculating spline functions. This algorithm is integrated into the software package “SPLINE”. The influence of the number of preselected sub-intervals and the number of datum points per sub-interval on the accuracy of the approximation was analyzed. The power of the algorithm was demonstrated on the shear storage and the loss-compliance data for an uncrosslinked poly-isobutylene. The experimental data were measured and discussed by [5]. © 2006 Journal of Mechanical Engineering. All rights reserved. (Keywords: spline functions, smoothing splines, algorithms, software packages, SPLINE) 0 UVOD 0 INTRODUCTION Rezultat meritev je po navadi množica točk, ki podaja odvisnost med dvema fizikalnima veličinama, recimo x in y. Zelo pogosto želimo izmerjeno množico točk nadomestiti (približati) z množico diskretnih točk, ki pomenijo “gladko” krivuljo. Ena izmed možnosti, ki jo v praksi pogosto uporabljamo, je približek s polinomom ustreznega reda. Ta postopek bo praviloma dal zadovoljivo rešitev samo v tistih primerih pri katerih je odvisnost med fizikalnima veličinama x in y v resnici potenčnega tipa. V vseh drugih primerih (tj., ko je odvisnost eksponentna ali trigonometrična) je omenjeni postopek po navadi nesprejemljiv. V takih primerih najučinkoviteje opravimo postopek glajenja z uporabo zlepkov polinomov tretjega reda. V prispevku je predstavljen algoritem, ki omogoča interaktivno spreminjanje širine posameznega zlepka, kar omogoča kakovostnejše glajenje eksperimentalnih podatkov z večjim raztrosom. Algoritem je bil uporabljen v programskem paketu ‘SPLINE’, ki smo ga razvili v Centru za eksperimentalno mehaniko na Fakulteti za strojništvo v Ljubljani za potrebe vrednotenja časovno odvisnega obnašanja polimernih in kompozitnih materialov. The results of measurements are usually given as a set of datum points, which defines the relation between the two measured physical quantities, i.e., x and y. Very often we want to replace the set of measured data points with a set of discrete data points representing a smooth curve. One of the possible choices we often use in practice is an approximation with polynomials of the appropriate order. This approach would only result in a satisfying solution when the relationship between the physical quantities x and y is indeed polynomial. In all other cases (i.e., when the relation is exponential or trigonometric) the polynomial approach can be unacceptable. In such cases, the most effective procedure for smoothing the data is the use of so-called “spline” functions. We present an algorithm that was used in the development of the “SPLINE” computer program at the Center for Experimental Mechanics, Faculty of Mechanical Engineering, University of Ljubljana. The algorithm was used to evaluate the time-dependent behavior of polymers and composite materials. 181 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 0.1 Definicija problema 0.1 Problem statement V ravnini x – y naj bo podanih N parov diskretnih vrednosti: In the plane x – y we have a set of N discrete data pairs: F= {xi,yi; i = 1, 2, ...., N;N>3} (1), ki podajajo odvisnost med izmerjenima fizikalnima veličinama x in y. Diskretne vrednosti naj bodo urejene tako, da bo izpolnjen pogoj: which defines the relationship between the two measured physical quantities, x and y. Let the discrete values be ordered such that xi0; j = 1,2,..., K-1 (10). Točke tj bomo imenovali vozlišča. Points tj are denoted as connection points. 1.2 Izpeljava algoritma ([1] do [3]) 1.2 Outline of the algorithm ([1] to [3]) Znotraj vsakega koraka: Within each of the sub-intervals: Ij=[tj,tj +1]; j = 1,2,3,...,K-1 uporabimo polinom tretjega reda: we utilize the third-order polynomial: fj(x) = Ajx3+Bjx2+Cjx + Dj (11), ki naj na meji s sosednjima korakoma, tj., v which at the borders of the sub-interval, i.e., at the j-tem in j+1 vozlišču, izpolnjuje naslednje pogoje: connection points j and j+1, fulfills the conditions: Iz linearnosti drugega odvoda gladilne From the linearity of the second derivative of funkcije (sl. 1) izhaja: the smoothing function, Fig. 1, follows: tj+1-x = Hj+1-f"j(x) x-tj f"j(x)-Hj in od tod: and (15) tj +1 -x x-tj f"j(x) = Hjj+1— + Hj+1—j (16). lj lj Dvakratno integriranje enačbe (16) da: Double integration of Eq. (16) yields: fj ( x ) =-(tj+1 -x)2+ H (x-tj)2 +E1 (17) j j fj ( x ) = H (tj+1 -x)3+ H (x-tj)3 +E1x + E2 (18), kjer integracijski stalnici E1 in E2 določimo iz pogoja where the integration constants E1 and E2 can be (12): obtained from the conditions (12): lj 6 E =t 2 j+1 FjljHj xlj t F lH j+1 j j+1 xlj (19) (20). Uporaba zlepkov za glajenje podatkov - Using Spline Functions to Smooth 183 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 Sl. 1. Drugi odvod približne funkcije znotraj j-tega koraka Fig. 1. Second derivative of the approximation function inside the j-th sub-interval Iz razmerij (18) do (20) bi sedaj lahko izračunali stalnice Aj, Bj, C in D, definirane z enačbo (11). Iz praktičnih razlogov bomo stalnice polinoma ohranili izražene v odvisnosti od Fj, P, H in lj (glej enačbe (12) do (14) in sliko1). Enačbi (17) in (18) sedaj lahko zapišemo kot: The constants of the polynomials within each sub-interval, Aj, Bj, Cj and Dj, Eq. (11), can be calculated from the relations (18) through (20). For practical reasons the constants will be expressed in terms of Fj, Pj, Hj and lj, (see Eqs. (12) to (14) – and Fig. 1). Equations (17) and (18) can now be rearranged as: fj(x)=Hj Iz pogoja (13) izhaja: f'(x) j (tj +1 -x) -H 2l +H j +1 (x-tj)2 lj Fj Fj 2l 6 + l jj 6l Hj +H j j+1 6 tj +1 -x l +l j j+1 +H j +1 x-t (x -tj)3 -lj 6l 6 +F tj+1 x +F j +1 x-t From the condition (13) it follows: H j+1 j j+2 j +1 kjer je j = 1, 2, ..., K-2. Dobili smo sistem K-2 enačb z 2K neznankami, Hk in Fk, kjer je k = 1, 2, ..., K. Za enolično rešitev problema potrebujemo še dodatnih K+2 enačb. Določitev/^ Naslednjih K dodatnih enačb lahko dobimo na dva načina: a) V primeru, ko je število izbranih vozlišč enako številu podanih diskretnih točk, K = N in x = tj, se bodo vozlišča ujemala s podanimi diskretnimi vrednostmi. V tem primeru je: j+2 j +1 (21) (22). (23), where j = 1, 2, ..., K–2. We obtained the system of K–2 equations with 2K unknowns, i.e., Hk and Fk, where k = 1, 2, ..., K. Hence, in order to solve the problem, we need additional K+2 equations. Determination of Fi There are two ways of obtaining the next K additional equations: a) When the number of connection points is the same as the number of given data points, K = N and x = tj, then the connection points coincide with the given set of discrete values. Hence: (24). V tem primeru gre izračunana krivulja natanko In this case the calculated curve goes exactly skozi vse diskretne vrednosti, kar pomeni, da dobimo through all the discrete values, meaning that we interpolacijsko krivuljo množice točk F, podane z obtain an interpolation curve for the set of discrete izrazom (1). Ta postopek pomeni poseben primer datum points F, Eq. (1). This case is a special case of metode, opisane v nadaljevanju. the method described below. 184 Emri I. - Cvelbar R. Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 b) Drugi, splošnejši postopek imamo, ko je število izbranih vozlišč manjše od števila podanih diskretnih vrednosti, K < N. V tem primeru določimo funkcijske vrednosti v vozliščih {Fj; j = 1, 2, ..., K}z metodo najmanjših kvadratov. Vozlišča {tj; j = 1, 2, ..., K} moramo izbrati tako, da bo vsak od korakov {lj; j = 1, 2, ..., K} vseboval vsaj en xi. V nadaljevanju bomo analizirali samo metodo b), ki je splošnejša. Vsota kvadratov odstopkov med vrednostmi, izračunanimi iz gladilne funkcije, fj(x), in izmerjenimi diskretnimi vrednostmi yi znotraj j-tega koraka je: Pri tem je v števec zadnje točke v koraku v. Seštevanje prek vseh K–1 korakov da skupno napako približka: Z minimiziranjem skupne napake dobimo: j b) We have a more general case when the number of selected connection points is smaller tan the number of given discrete datum points, i.e., K < N. In this case the values at the connection points {F; j = 1, 2, ..., K} are determined with the least-squares method. The set of connection points {t; j = 1, 2, ..., K} should be selected such that each of the j sub-intervals {lj; j = 1, 2, ..., K} includes at least one xi. Here we will discuss only case b), as it is more general. The sum of the squares of the deviations between the values computed from the spline function, fj(x), and the measured discrete values yi within the j-th sub-interval is: [fj ( xi ) -yi]2 (25). Here vj is the index of the last data point within the sub-interval v. Summation over all K–1 sub- j v intervals yields the sum of the approximation errors: E [fj(xi)-yi]2 (26). vj -1+1 Minimizing the sum errors we obtain: dS 2§ i [i() -yi f j (xi ) =0 dF k j=1 i=vj -1 +1 dF E E f () k =T E y^fj F(xi (27) (28). Za vsak Fk, kjer je k = 1, 2, ..., K, dobimo For each Fk, where k = 1, 2, ..., K, an equation enačbo oblike (28), kar pomeni naslednjih K enačb. of the form of Eq. (28) is obtained. This yields the Parcialne odvode dfj(xi)ldFk izračunamo z next K equations. The partial derivatives odvajanjem enačbe (22): % (x )/8Fk can be obtained from the Eq. (22): (tj +1-x) ; za/for k = j %(xi) (x-tj) ; za/for k = j+1 (29). 9Fk lj 0 ; za/for j*k*j + 1 Z upoštevanjem razmerij (29) preide enačba Using the relations (29), Eq. (28) can be (28) v obliko: rearranged as: l l l l i=vk-2+1 k-1 i=vk-1+1 Če sedaj upoštevamo še enačbo (22), dobimo: k i=vk-2+1 k-1 i=vk -1+1 k Utilizing Eq. (22) we obtain: i=vk-2 +1 (tk - xi)3 -l 6lk-1 k1 6 +H x -t3 (i k-1) i=vk -1+1 (t -x)3-lkt -x k+1 i k+1 i 6l 6 +H 6lk-1 k-1 6 (xi-tk)3 -l xi -tk 6l +F +F +F +F (31) k 1 * x -t + k yi ll i=vk-2 +1 k-1 i=vk-1 +1 k Uporaba zlepkov za glajenje podatkov - Using Spline Functions to Smooth 185 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 oziroma or AH +BH + CH +DF +EF +GF =H k+1 k-1 k k+1 k+1 kjer so: A= E i=vk-2+1 where: (tk-xi)3-l tk 6lk-1 k-1 6 V k-1 A= k1 i=vk-2+1 x -t3 (i k-1) 6l + ck= k i=vk -1+1 V k-1 J i=vk-1+1 3 k tk ( 6l \ k (xi -tk)3 -l 6l vk= k 1 J V k l2 i=vk-2 +1 k-1 2 L• = k1 ( x i t k-1 ) + k ( t +1 x i ) i=vk-2+1 k -1 i=vk-1+1 l k g = k xi -tk tk +1 - xi ( )( ) i=vk -1+1 vk -1 x -t K= E yi^r^+ E i=vk-2+1 l -1 i=vk-1+1 (32), (33) (34) (35) (36) (37) (38) (39). Enačbi (23) in (31) pomenita skupaj (2K-2) Eqs. (23) and (31) together represent (2K-2) enačb, kar pomeni, da manjkata še dve enačbi. Zadnji equations. Two more equations are needed. These dve enačbi dobimo iz robnih pogojev. are obtained from the boundary conditions. 1.3 Robni pogoji 1.3 Boundary Conditions Manjkajoči enačbi dobimo iz zahteve o The missing two equations can be obtained from ukrivljenosti krivulje na obeh koncih množice F, tj. the condition that the curvatures on both ends of the set F, H1 in HK, ki ju zapišemo kot linearni funkciji i.e., H1 and HK, can be expressed as linear functions of the ukrivljenosti v sosednjih točkah t2 in tK1: curvatures at the two neighboring points t2 in tK 1. Hence: H1 = l1H2 +l2 HK = l3HK -1 +l4 (40) (41). Z izbiro stalnic 1 do 1 lahko prilagajamo ukrivljenost krivulje na obeh koncih. V primeru {A = 0; i = 1, ..., 4} bosta, recimo, oba konca krivulje ravna. Največkrat seveda nimamo informacij o obnašanju podatkov F, ki jih analiziramo, na robovih. V tem primeru se izkaže kot najprimernejše, da H1 in HK določimo z minimizacijo integrala kvadratov ukrivljenosti krivulje: With the selection of the constants l1 to l4 the curvature of the function at both ends can be adjusted as required. For example, when {li = 0; i = 1, ..., 4} both ends of the curve will be straight. Usually, we do not have information about the behavior of the analyzed data, F, at both ends. In such a case it is most appropriate to determine H1 and HK by minimizing the integral of the squares of the curve’s curvatures: Z upoštevanjem razmerja (16) dobimo: Using relation (16) we obtain: (42). 186 Emri I. - Cvelbar R. Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 K-1 j+1 j=1 t tj +1 -x H +H x-t j +1 dx in po integraciji and after integration 3 j=1 (43) (44). Minimizacijski postopek izvedemo z The minimization of the function U is obtained odvajanjem funkcije U po H1 in HK: through a derivation with respect to H1 and HK: dU l1(H2+2H1) dH1 3 dU lK-1 ( 2HK+HK dH Iz (45) in (46) izhaja: From (45) and (46) it follows that: H= H HK HK =- K -1 V primeru, ko izberemo na abscisi (osi x) en sam korak, bo K = 2 in H = H = 0, kar pomeni, da bo v tem primeru izveden približek podatkov s premico. K temu problemu se bomo ponovno vrnili v razpravi. Izraza (47) in (48) sta manjkajoči dve enačbi. Skupaj z enačbami, ki ju definirata izraza (23) in (31), imamo sedaj sistem 2K linearnih enačb z 2K neznankami: Hk +H k +1 +l +H k+1 k +2 6 +F k +1 (45) (46). (47) (48). 2 When on the abscissa (x-axis) we select only one interval, then K = 2 and H1 = H2 = 0, which means that the data will be approximated by a straight line. We will address this problem again later in the discussion. Expressions (47) and (48) represent the missing two equations. Together with the expressions (23) and (31) we have now a system of 2K linear equations with 2K unknowns: 11 + \ k k+1 J AHt-1 + BH + C k H k+1 + D k F k-1 + E k F k + G k F k+1 H k+2 = 0 , k =1, 2,L, K -2 l k+1 H k =1, 2,L, K H H H =0 2 =0 2 (49) (50) (51) (52). Stalnice A, Bk, Ck, Dk, Ek, Gk in Hk so podane z enačbami (33) do (39). Dobljeni sistem enačb (49) do (52) rešimo numerično z eno izmed znanih metod za reševanje sistemov linearnih enačb. Rešitev sistema linearnih enačb so funkcijske vrednosti interpolacijske krivulje v vozliščih {Fj, tj; j = 1, 2, ..., K}, ter vrednosti pripadajočih drugih odvodov {Hj, tj; j = 1, 2, ..., K}. Poljubno število diskretnih vrednosti interpolacijske krivulje lahko sedaj izračunamo z enačbo (23). V primeru, da nas zanimajo tudi vrednosti prvega in drugega odvoda, lahko te izračunamo z enačbama (21) in (16). The constants Ak, Bk, Ck, Dk, Ek, Gk and Hk are given by Eqs. (33) to (39). The obtained system of Equations (49) to (52) can be solved numerically using one of the existing methods for solving systems of linear equations. The solutions of the system of linear equation are the values of the interpolation curve at the connection points {Fj, tj; j = 1, 2, ..., K}, and the corresponding second derivatives {Hj, tj; j = 1, 2, ..., K}. Any number of discrete data along the interpolation curve can be calculated using Eq. (23). To determine the corresponding values of the first and second derivative, Eqs. (21) and (16) can be used. Uporaba zlepkov za glajenje podatkov - Using Spline Functions to Smooth 187 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 2 RAZPRAVA 2 DISCUSSION Uporabnost izpeljanega algoritma za glajenje diskretno podanih krivulj bomo prikazali na treh primerih. V prvih dveh primerih smo diskretne vrednosti ustvarjali iz analitično podanih krivulj. Uporabili smo preprosto trigonometrično funkcijo y = 50 + 40sinx in ustvarili dve množici„eksperimentalnih“ podatkov. Prva množica: The power of the proposed algorithm will be demonstrated on three different sets of discrete data. In the first two cases we will use the synthetic discrete data generated from the analytical function y = 50 + 40sinx. The first set of “experimental” data: {A}={0) komponento dinamične funkcije lezenja, ki smo jih poprej uporabili v okviru študija obrnjenega problema pri karakterizaciji materialnih funkcij viskoelastičnih materialov ([4] do [7]). Ta analiza je zahtevala predhodno „glajenje“’ izmerjenih materialnih funkcij, kar je vodilo do nastanka tega prispevka. Eksperimentalni podatki obeh materialnih funkcij so prikazani na sliki 3. 2.1 Minimalno število korakov Za določitev minimalnega števila korakov, oziroma minimalnega števila vozlišč, smo uporabili podatke {A}, ki so brez napake. Diskretne vrednosti na gladilnih krivuljah, izračunanih za različno število korakov, smo primerjali z analitičnimi vrednostmi. Kakovost približka je bila ocenjena s povprečno relativno napako A/: with the additional terms (–4.5+9RND), where RND represents a random generator of numbers between 0 and 1, incorporates a generated random 10% error. The two sets of data are shown in Fig. 2 as a solid line and diamonds, respectively. These two sets of data will be used to analyze the influence of the selected number of sub-intervals on the precision of smoothing discrete data. In the third example we will use “true” experimental data on the real J’(w) and the imaginary J’’(w) component of the creep-compliance function of poly-isobutylene. These data were used previously for studying inverse problems in the characterization of viscoelastic materials ([4] to [7]). In this analysis we had to smooth the data, which resulted in the paper presented here. Experimental data for both material functions are shown in Fig. 3. 2.1. Minimum number of sub-intervals To determine the minimum required number of sub-intervals we used the first set of discrete data, {A}, which are within the resolving power of a computer without an error. Discrete values of the smoothing curve calculated for a different number of sub-intervals were compared with the corresponding analytical values. The accuracy of the approximation was evaluated with the average relative error, N: N [( - f 1 ^ \/ \y i,apr y i,teor J N i=1 y iteor (55). Z N smo označili število diskretnih Here N denotes the number of discrete data podatkov, uporabljenih v izračunu približne used in the calculation of the approximation curve, krivulje, z yi, diskretne vrednosti na približni y denotes the discrete values on the approximation krivulji in z y apr pripadajoče funkcijske vrednosti curve, and yi denotes the corresponding function- brez napake. i,eor values without an error. 188 Emri I. - Cvelbar R. Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 100 80 o__o / X — A - teoretično / theoretical O B - z napako / with error 7 \ 60 40 - 20 \ / o<> 0 2 4 6 8 10 X Sl. 2. Ustvarjeni“eksperimentalni“ podatki brez {A} in z naključno 10% napako {B} Fig. 2. Generated “experimental” data without, {A}, and with a random 10% error, {B} 61 O 10 log (o[l/s]) Sl. 3. Izmerjene diskretne vrednosti skupnih krivulj za realno, J’(a,), in imaginarno, J’’(a>) komponento funkcije lezenja poli-izobutilena Fig. 3. Measured discrete values of master curves for real, J’(a>), and imaginary, J’’(a>), component of the creep compliance of poly-isobutylene Rezultat te analize je prikazan kot krivulja A v diagramu na sliki 4. Krivulja B je za podatke {B}, ki jih bomo analizirali pozneje. Zaradi boljše preglednosti je v notranjosti diagrama prikazan povečani del območja med 0 in 10% napake. Primeri gladilnih krivulj izračunanih za različno število korakov, so prikazani na sliki 5. Zaradi preglednosti je prikazanih samo pet približnih krivulj, izračunanih za 1, 2, 3, 5 in 15 korakov. The result of this analysis is shown as curve A in Fig. 4. Curve B shows the results for the set of data {B}, which will be discussed later. For reasons of clarity the enlarged segment of the curve between 0 and 10% of error is shown as an enclosure. Examples of smoothing curves calculated for a different number of sub-intervals are shown in Fig. 5. For reasons of clarity we show only five approximation curves calculated for 1, 2, 3, 5 and 15 sub-intervals. Uporaba zlepkov za glajenje podatkov - Using Spline Functions to Smooth 189 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 V primeru, ko izberemo en sam korak, bo približna krivulja premica. Ta lastnost krivulj zlepkov izhaja iz enačb (47) in (48). Ukrivljenosti na obeh koncih koraka sta namreč enaki nič, H = H = 0, kar pomeni, da je približna krivulja premica. Če izberemo dva koraka, bosta ukrivljenosti gladilne krivulje na obeh koncih za polovico manjši od ukrivljenosti na stičišču obeh korakov, v skladu z enačbama (51) in (52). Gladilna krivulja bo v tem primeru parabolične oblike. Sprejemljivo približno (gladilno) krivuljo dobimo šele pri petih korakih oziroma šestih vozliščih. Napaka približka je v tem primeru okrog 3,5%. S povečevanjem števila vozlišč se napaka približka hitro zmanjšuje, kakor to nazorno prikazuje krivulja A na sliki 4. Če izberemo 15 korakov, je relativna napaka že manjša od 0,2%. Z nadaljnjim povečevanjem števila vozlišč pridemo v mejni primer, ko je število vozlišč enako številu diskretnih podatkov. V tem primeru dobimo interpolacijsko krivuljo, ki povezuje vse točke. Ker so diskretni podatki {A} brez eksperimentalne napake, bo gladilna krivulja v bistvu enaka pripadajoči teoretični. In the case when we choose only one sub-interval the approximation curve will be a straight line. This property of the spline curves results from the conditions (47) and (48). The curvatures at both ends of the sub-interval are equal to zero, i.e., H1 = H2 = 0, which means that the approximation curve is a straight line. If we select two sub-intervals, the curvatures of the smoothing curve at both ends are half of the curvature in the connecting point of the two sub-intervals, in accordance with Equations (51) and (52). In this case, the shape of the smoothing curve will be parabolic. An acceptable approximation (smoothing) curve is obtained only after five sub-intervals, i.e., six connecting points. In this case the error of the approximation is about 4.5%. The error of the approximation will decrease with the increased number of sub-interval, as shown with the curve A in Fig. 4. If we choose 15 sub-intervals the relative error will be less than 0.2%. With a further increase in the number of sub-intervals we approach the limiting case when the number of connecting points is equal to the number of datum points. In such a case we obtain an interpolation curve, which connects all the datum points. Since the discrete data {A} are without experimental error, the smoothing curve will be essentially identical to the underlying theoretical curve. 2.2 Optimalno število korakov 2.2 Optimum number of sub-intervals Množica izmerjenih podatkov, ki jih želimo v praksi približati, vsebuje zmeraj določeno napako. V 80 g— Measured data, which we want to approximate, always contain some experimental error. In such cases 70 60 50 40 30 20 10 0 33 37 41 1 5 9 13 17 21 25 29 Št. korakov / No. of subintervals Sl. 4. Napaka približka v odvisnosti od števila korakov, A - za približek krivulje brez naključne napake, B - približek krivulje z ±10% naključno napako Fig. 4. Error of the approximation as a function of the number of sub-intervals, A - for the approximation of the theoretical curve, B - for the approximation of the curve with the added ±10% random error 190 Emri I. - Cvelbar R. Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 100 80 60 40 20 0 0 2 4 6 8 10 Sl. 5. Približne krivulje z različnim številom korakov Fig. 5. Approximation curves with a different number of sub-intervals teh primerih uporabimo gladilne funkcije za določitev gladkih približnih krivulj. Število korakov mora biti torej manjše od števila diskretnih podatkov. Sedaj stojimo pred pomembnim vprašanjem: Kolikšno je optimalno število korakov? Da bi dobili odgovor na to vprašanje, smo uporabili množico podatkov {B}, enačba (54), ki vsebujejo naključno 10-odstotno napako. Diskretne vrednosti so v obliki kvadratkov prikazane na sliki 2. Podobno kakor v prejšnjem primeru, smo tudi tokrat napako glajenja ocenjevali v skladu z enačbo (55), tj. vrednosti dobljene z glajenjem smo primerjali s teoretičnimi funkcijskimi vrednostni, ki ne vsebujejo napake. Rezultat te analize je prikazan na sliki 4 kot krivulja B. Iz diagrama je razvidno, da je napaka približka v primeru, ko je število korakov enako ali manjše od 5, praktično enaka kakor v primeru, če podatki ne vsebujejo eksperimentalne“ napake. S povečevanjem števila korakov se bo napaka najprej zmanjšala, nato pa se bo ponovno začela zvečevati. V trenutku, ko je število vozlišč enako številu diskretnih podatkov (krivulja gre v tem primeru natančno skozi vse diskretne vrednosti), bo napaka približka enaka povprečni eksperimentalni napaki, ki jo vsebuje množica diskretnih vrednosti {B}, v tem primeru približno 6 odstotkov. S slike 4 je razvidno, da bomo dobili najboljši rezultat glajenja podatkov {B}, če izberemo 7 korakov. Na sliki 6 je ta primer približka prikazan v obliki trikotnikov, povezanih s polno črto. V istem diagramu je s polno črto prikazan tudi približek s 40 we use spline functions to obtain smooth continuous curves. Therefore, the number of selected sub-intervals should be smaller than the number of datum points. This raises an important question: What is the optimum number of sub-intervals? To answer this question we have used the set of data {B}, Eq. (54), with a 10% random error. The data are shown as diamonds in Fig. 2. As in the previous case the quality of the smoothing was evaluated according to Eq. (55), i.e., discrete values predicted with the spline function were compared to the underlying theoretical values. The result of this analysis is presented in Fig. 4 as curve B. From the diagram it is clear that the error of splining the data with a 10% random error is about the same as for the data with no “experimental” error, if the selected number of sub-intervals is equal to or less than five. If we increase the number of sub-intervals the error of smoothing will first decrease and then start to increase again. We reach the limiting case when the number of connecting points is the same as the number of datum points. In this case the smoothing curve goes through all the datum pints, and the error of the approximation becomes equal to the average relative error of the set of data, {B}, which in this case is approximately 6%. As seen from Fig. 4 we will get the best smoothing of the set of data {B} if we choose six sub-intervals. The result of this smoothing is shown in Fig. 6 as a line with triangles. In the same figure the approximation with 40 sub-intervals, i.e., 41 connecting points, is also shown as a solid line. In this case the Uporaba zlepkov za glajenje podatkov - Using Spline Functions to Smooth 191 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 [ -—A - teoretično / theoretical 100 o B - z napako / with error B*A^vsfišt. korakov / No. of intervals=7 _v*Jt\ j/»V ------št. korakov / No. of intervals=40 #&*X 80 - <$ \ f \ 60 - 40 20 0 ^---------'---------1------------------1---------'---------1---------'---------1------------------ 0 2 4 6 8 10 X Sl. 6. Približek funkcije, podane z 10-odstotno napako Fig. 6. Approximation of function given with a 10% error koraki oziroma 41 vozlišči. V tem primeru gladilna smoothing curve connects the discrete values, which krivulja povezuje diskretne vrednosti, kar pomeni, essentially means that there is no smoothing. da v resnici glajenja ni. The average relative error of smoothing Znotraj posameznega koraka je povprečna depends on the number of datum points within each relativna napake približka odvisna od števila sub-interval. Figure 7 shows such an analysis for diskretnih vrednosti v tem koraku. Diagram na sliki 7 the case of smoothing the set of data {B} with 10 prikazuje takšno analizo za primer glajenja podatkov sub-intervals. The error of smoothing decreases with {B} z 10 koraki. Velikost napake glajenja se zmanjšuje the number of datum points per sub-interval, and it s povečanim številom podatkov znotraj koraka in se stabilizes at about 30 datum points per sub-interval, stabilizira pri približno 30 podatkih na korak, kar se which is in agreement with what we know from the ujema s tistim, kar vemo iz statistike. Nadaljnje statistics. Further increasing the number of datum povečevanje števila točk na korak bistveno ne bo points per sub-interval will not lead to substantially prispevalo h kakovosti glajenja. improved smoothing. 2.3 Glajenje viskoelastičnih materialnih odvisnosti Kot zadnji primer si oglejmo sedaj še uporabo predstavljenega algoritma na eksperimentalnih podatkih za realno, J’(m), in imaginarno, J’’(a>), komponento funkcije lezenja za nezamrežen poliizobutilen. Te eksperimentalne podatke smo pred tem analizirali v okviru študija obrnjenega problema pri analizi viskoelastičnih materialnih funkcij [6]. Podatki so bili povzeti iz [8], kjer so v preglednični obliki podani odseki krivulj za različne temperaturne razmere. Na podlagi časovno-temperaturnega superpozicijskega načela smo konstruirali skupni krivulji za temperaturo T = 20 °C, po postopku, ki je opisan v [6]. Skupni krivulji sta predstavljeni v obliki polnih krogcev in kvadratkov na sliki 3. Krivulji, ki ju dobimo z interpolacijo z uporabo gladilne funkcije, sta predstavljeni v obliki polne črte 2.3 Smoothing of the viscoelastic material functions The final demonstration of the power of the presented algorithm will be executed on the experimental data on the real, J’(«), and the imaginary, J’’(m), components of the creep-compliance function of an uncrosslinked poly-isobutylene. We have used these data before [6] for studying the inverse problem of viscoelastic materials functions. The experimental data were taken from [8], where they are given in a tabular form as segments of the creep curve measured at different temperatures. Using the time-temperature superposition principle we have constructed the master curves for the reference temperature T = 20°C, as described in [6], which are shown as filled circles and squares in Fig. 3. The two curves obtained after the smoothing with spline functions are shown in Fig. 8 as solid lines. 192 Emri I. - Cvelbar R. Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 2,5 1,5 0,5 - 0 0 10 50 60 20 30 40 Št. podatkov znotraj koraka No. of data in sub-interval Sl. 7. Napaka približka v odvisnosti od števila podatkov znotraj koraka Fig. 7. Error of the approximation as a function of the number of datum points per sub-interval na sliki 8. Glajenje je bilo izvedeno z 10 koraki. Z gladilno funkcijo lahko preberemo poljubno število diskretnih vrednosti, kar je pomembno za nadaljnjo numerično analizo izmerjenih podatkov, posebno v primeru reševanja obrnjenih problemov. V tem primeru smo izračunali 10 diskretnih vrednosti na dekado vzdolž logaritemske frekvenčne koordinate. 3 SKLEP Na temelju izvedene analize lahko ugotovimo, da ni enoličnega odgovora na vprašanje: “Katero -5 -5,5 -6- -6,5 - -7,5 -8 -8,5 -9 -9,5 -10 The smoothing procedure was executed with 10 sub-intervals. Using spline functions one can calculate as many discrete datum points as necessary, which is very important for any further numerical analysis of the experimental data, in particular for solving the inverse problems. In this case we have calculated 10 values per-decade along the logarithmic frequency axis. 3 CONCLUSION From the presented analysis we can conclude that there is no unique answer to the question: “What -2 0 2 4 6 8 10 log (w[1/s]) Sl. 8. Realna, J’(w) in imaginarna, J’’(w) komponenta funkcije lezenja po postopku glajenja z gladilno funkcijo Fig. 8. The real, J’(w), and the imaginary, J’’(w), component of the creep compliance function after smoothing with the spline functions 2 1 Uporaba zlepkov za glajenje podatkov - Using Spline Functions to Smooth 193 Strojniški vestnik - Journal of Mechanical Engineering 52(2006)3, 181-194 število korakov moramo izbrati za optimalno glajenje diskretnih podatkov?” Izbira števila korakov je in zmeraj bo “stvar osebne odločitve uporabnika”. To si velja še posebej zapomniti v primerih, ko uporabljamo tržne programe, pri katerih nimamo vpogleda v algoritem uporabljen za glajenja diskretnih podatkov. V določenih primerih lahko tak postopek glajenja vodi tudi do neustrezne razlage meritev [9]. number of subintervals should be selected for optimum smoothing of discrete data?” Selection of the number of sub-intervals is, and will always be, a “personal decision by the user”. This should be remembered when we are using commercial software packages where we have no information on the algorithm used for the process of smoothing discrete data. In some cases, such an approach may lead to an inappropriate interpretation of measurements [9]. 4 LITERATURA 4 REFERENCES [1] de Boor C. (1978) A practical guide to splines, Springer Verlag. [2] Press, W.H., Flannery, B.P., Teukolsky, S.A., Vetterling, W.T. (1986) Numerical recepies, Cambridge University Press, pp. 86-89. [3] J.H. Ahlberg, E.N. Nielsen, J.T. Walsh (1967) The theory of splines and their application, Academic Press. [4] Emri I., Tschoegl, N.W. (1993) Generating line spectra from experimental responses. 1. Relaxation modulus and creep compliance, Rheol. Acta, 32, 311 –321, 1993. [5] Tschoegl, N.W., Emri I. (1993) Generating line spectra from experimental responses. 2. Storage and loss functions, Rheol. Acta, 32, 322 – 327, 1993. [6] Emri I., Tschoegl, N.W. (1994) Generating line spectra from experimental responses. 4. Application to experimental – data, Rheol. Acta, 33, 60 – 70, 1994. [7] Emri I., Tschoegl, N.W. (1997) Generating line spectra from experimental responses. 5. Time – dependent viscosity’, Rheol. Acta, 36, 303 – 306, 1997. [8] Ferry J.D., Grandine L.D., Fitzgerald R.E (1953) Dynamic mechanical properties of Polyisobutylene, J. Applied Phys, 24, 650-655, 1953. [9] Emri I., Pindera J.T. (1993) On the use of spline functions in evaluation of experimental data, 1993 SEM Spring Conf. on Experimental Mechanics, Dearborn, Michigan, USA, Jun. 7 – 9, 1993, 1196 – 1205. Naslov avtorjev: prof.dr. Igor Emri mag. Robert Cvelbar Univerza v Ljubljani Fakulteta za strojništvo Aškerčeva 6 1000 Ljubljana ie@fs.uni-lj.si robert.cvelbar@fs.uni-lj.si Authors‘ address: Prof.Dr. Igor Emri Mag. Robert Cvelbar University of Ljubljana Faculty of Mechanical Eng. Aškerčeva 6 1000 Ljubljana, Slovenia ie@fs.uni-lj.si robert.cvelbar@fs.uni-lj.si Prejeto: Received: 14.6.2005 Sprejeto: Accepted: 16.11.2005 Odprto za diskusijo: 1 leto Open for discussion: 1 year 194 Emri I. - Cvelbar R.