- TI nspire
[TI-nspire] (프로그램) 보간법 (선형, 다항식) Linear & Polynomial Interpolation
Linear & Polynomial Interpolation for TI-Nspire
Ver 1.2
by allcalc.org
-----
Usage
1. Input each x1,y1,x2,y2... var_x and var_y alternately
or matrix (2*n) type DATA at prompt for DATA.x
2. When you finished to insert DATA, type "end" at prompt for DATA.x
3. If there's no error with DATA sets, function i.linear() and i.polynomial() will be created.
4. Use functions to find unkown value "y"
5. Additionally, data.sub(matrix) and data.subx,data.suby(list) will be made too.
Caution
To stop a program that contains a Request command inside an infinite loop:
• Handheld: Hold down the "on" key and press "enter" repeatedly.
• Windows?: Hold down the "F12" key and press "Enter" repeatedly.
• Macintosh?: Hold down the "F5" key and press "Enter" repeatedly.
1. 기능
기본 데이터를 입력하여 선형 보간법에 따른 조각함수(Piecewise Function) i.linear(x) 와 다항식 보간법(라그랑주)에 따른 함수 i.polynomial(x) 를 생성합니다.
생성된 함수를 이용하여 특정 값(x)에서의, 보간법 예상치(y)를 구합니다.
2. 사용법
2-a. 기본 데이터 입력
- 프로그램의 실행 : inter()
- 기본 DATA 입력
방법 1 : 번갈아 입력 : x1, y1, x2, y2, x3, y3... , (입력이 끝나면 e 또는 end 를 입력)
혹은
방법 2 : 2×N 행렬을 한꺼번에 입력 : x값 입력시에 입력 - DATA 입력시
주의사항
* x 는 크기 순서로 입력할 필요 없음 (자동 sort 됨)
* (x,y) 데이터 쌍이 중복 되어도 괜찮으나, 하나의 x값에 둘 이상의 y값이 존재하면 에러 발생
2-b. 결과 함수의 이용
- 2-a의 입력이 끝나면 결과함수로 사용할 변수명을 물어봄
- 결과함수를 이용하여 추정값을 구함
ex) i.linear(3) 【Enter】 : x=3일 때의 추정값을 구함
2-c. 생성된 함수의 확인 http://www.allcalc.org/5752
- 【MENU】 【1】 【2】 (Action - Recall Definition) 명령으로 사용자 함수에 현재 정의되어 있는 내용을 확인할 수 있습니다.
3. 결과


4. 소스코드
Define LibPub inter()=
Prgm
:© Linear and Polynomial Interpolation for TI-nspire
:© Ver 1.2
:© by allcalc (allcalc.org)
:
:© Part A: Input DATA
:
:Local n,data.x,data.y,data
:n:=0
:Loop
: Request "data.x or matrix(2×n) or END",data.x,0
:
:© Exit Loop Condition
: If string(data.x)="end" or string(data.x)="END" or string(data.x)="e" Then
: Exit
: EndIf
:
:© Adding Data
: n+1→n
:© Adding Data with Matrix
: If getType(data.x)="MAT" Then
: n+dim(data.x)[2]-1→n
: If n=dim(data.x)[2] Then
: data.x→data
: Else
: augment(data,data.x)→data
: EndIf
:© Adding Each Data Pair
: Else
: Request "data.y for x="&string(data.x),data.y,0
: If string(data.y)="end" or string(data.y)="END" Then
: Exit
: EndIf
: If n=1 Then
:[[data.x][data.y]]→data
: Else
: augment(data,[[data.x][data.y]])→data
: EndIf
: EndIf
:EndLoop
:
:© Part B : Data Processing
:
:© Part B1 : Data Processing
:Local data.listx,data.listy
:mat▶list(data[1])→data.listx
:mat▶list(data[2])→data.listy
:SortA data.listx,data.listy
:colAugment(list▶mat(data.listx),list▶mat(data.listy))→data
:
:© Part B2 : Section Verification&Consolidation and Slope
:© Verification
:Local i,j,dup
:newList(n)→dup
:For i,1,n-1
: If data[1,i]=data[1,i+1] Then
: 1→dup[i+1]
: If data[2,i]≠data[2,i+1] Then
: Disp "Data Error : ",[["x"]["y"]],"=",subMat(data,1,i,2,i+1)
: Stop
: EndIf
: EndIf
:EndFor
:
:© Consolidation
:© Local data.sub : Make data.sub global var
:subMat(data,1,1,2,1)→data.sub
:For i,2,n
: If dup[i]=0 Then
: augment(data.sub,subMat(data,1,i,2,i))→data.sub
: EndIf
:EndFor
:
:mat▶list(data.sub[1])→data.subx
:mat▶list(data.sub[2])→data.suby
:Disp "data.sub",[["x"]["y"]],"=",data.sub
:
:© Slope for Linear Interpolation
:Local sub.slope,sub.n
:dim(data.sub)[2]→sub.n
:newList(sub.n-1)→sub.slope
:For i,1,sub.n-1
:((data.sub[2,i+1]-data.sub[2,i])/(data.sub[1,i+1]-data.sub[1,i]))→sub.slope[i]
:EndFor
:
:
:© Part C1 : Out Polynomial Function as i.polynomial(x)
:Local poly,f_name
:"i"→f_name
:Request "Input Function name",f_name,0
:If getType(f_name)="NUM" Then
:"i"&string(f_name)→f_name
:Else
: If getType(f_name)≠"STR" Then
: string(f_name)→f_name
: EndIf
:EndIf
:
:"Define "&f_name&".polynomial(var_x)="&string(∑(data.sub[2,i]*∏(when(i≠j,((var_x-data.sub[1,j])/(data.sub[1,i]-data.sub[1,j])),1),j,1,sub.n),i,1,sub.n))→poly
:expr(poly)
:
:© Part C2 : Out Piecewise Linear Interpolation Function as i.linear(x)
:
:Local pf,random.x
:"Define "&f_name&".linear(x)=piecewise("→pf
:For i,1,sub.n-1
: pf&string(sub.slope[i]*(x-data.sub[1,i])+data.sub[2,i])&","&string(data.sub[1,i]≤x≤data.sub[1,i+1])&","→pf
:EndFor
:left(pf,dim(pf)-1)&")"→pf
:expr(pf)
:
:© Part C3 : Display functions usage
:rand()*(data.sub[1,sub.n]-data.sub[1,1])+data.sub[1,1]→random.x
:Disp "Usage : "&f_name&".linear("&string(random.x)&")=",#(f_name&".linear")(random.x)
:Disp f_name&".polynomial("&string(random.x)&")=",#(f_name&".polynomial")(random.x)
:
:Disp "Linear function is =",pf
:Disp "Polynomial function is =",poly
:EndPrgm
댓글10
-
세상의모든계산기
이 프로그램은 선형 보간법과 라그랑주 보간법을 동시에 구하는 프로그램입니다.
간단하게 선형 보간법의 결과만 필요한 경우에는
별도의 프로그램 파일 혹은 라이브러리를 사용하기보다 statistics(통계) 의 Linear Regression 기능을 이용하는 것이 편합니다.(예제 : http://www.allcalc.org/7826 )
- 1
-
세상의모든계산기
예를 들어
http://www.allcalc.org/2387 의 댓글에 있는 예제를 푼다면
【inter()】
【200】【1250】
【300】【1890】
【e】【Enter】
순으로 DATA 입력을 마치고【i.linear(250)】
으로 목표값을 찾습니다.* 이렇게 DATA 가 2쌍 뿐인 경우에는 i.linear() 함수와 i.polynomial() 함수가 동일한 결과값을 출력합니다.
(단, linear() 함수는 조각함수라서 데이터 범위 안쪽의 값만을 구할 수 있습니다.) - 1
- 2
- 3
- 4
-
3
세상의모든계산기
inter() 함수 결과에 생성된 함수를 출력하는 명령(Disp)을 추가했습니다.
한 줄 표기되어서 알아보기 어렵다고 느끼실 때는
- Menu - Action - Recall Definition
- 아니면 한 줄 표기된 결과를 선택해서 입력창에 붙여넣기 하신 다음 [enter] 하시면 입체적 표현으로 바뀝니다.

세상의모든계산기 님의 최근 댓글
쌀집계산기로 연립방정식 계산하기 - 크래머/크레이머/크라메르 공식 적용 https://allcalc.org/56739 3. 'x' 값 구하기 계산기 조작법 목표: x = Dx / D = [(c×e) - (b×f)] / [(a×e) - (b×d)] 계산하기 1단계: 분모 D 계산 (메모리 활용) 1 * 1 M+ : 메모리(M)에 1를 더합니다. (현재 M = 1) -0.1 * -0.2 M- : 메모리(M)에서 0.02를 뺍니다. (현재 M = 0.98 = 0.98) 이로써 메모리(MR)에는 분모 0.98가 저장됩니다. 2단계: 분자 Dx 계산 후 나누기 78000 * 1 : 78000를 계산합니다. = : GT에 더합니다. -0.1 * 200000 : -20000를 계산합니다. ± = : 부호를 뒤집어 GT에 넣습니다. // sign changer 버튼 사용 GT : GT를 불러옵니다. GT는 98000 (분자 Dx) 값입니다. ÷ MR = : 위 결과(98000)를 메모리(MR)에 저장된 분모 D(0.98)로 나누어 최종 x값 100,000를 구합니다. 4. 'y' 값 구하기 계산기 조작법 목표: y = Dy / D = [(a×f) - (c×d)] / [(a×e) - (b×d)] 계산하기 1단계: 분모 D 계산 (메모리 활용) 'x'에서와 분모는 동일하고 메모리(MR)에 0.98가 저장되어 있으므로 패스합니다. 2단계: 분자 Dy 계산 후 나누기 GT ± = : GT를 불러오고 부호를 뒤집어 GT에 더합니다. GT가 0으로 리셋됩니다. 【AC】를 누르면 M은 유지되고 GT만 리셋되는 계산기도 있으니 확인해 보세요. 1 * 200000 : 200000를 계산합니다. = : GT에 더합니다. 78000 * -0.2 : -15600를 계산합니다. ± = : 부호를 뒤집어 GT에 넣습니다. GT : GT를 불러옵니다. 215600 (분자 Dy) 값입니다. ÷ MR = : 위 결과(215600)를 메모리(MR)에 저장된 분모 D(0.98)로 나누어 최종 y값 220,000를 구합니다. x, y 값을 이용해 최종 결과를 구합니다. 2026 01.18 크레이머 = 크레머 = 크라메르 공식 = Cramer's Rule https://allcalc.org/8985 2026 01.18 부호 변경 버튼 https://allcalc.org/52092 2026 01.18 [fx-570 CW] 와의 차이 CW에 【×10x】버튼이 사라진 것은 아닌데, 버튼을 누를 때 [ES][EX] 처럼 특수기호 뭉치가 생성되는 것이 아니고, 【×】【1】【0】【xㅁ】 버튼이 차례로 눌린 효과가 발생됨. ※ 계산 우선순위 차이가 발생할 수 있으므로 주의. 괄호로 해결할 것! 2026 01.18 26년 1월 기준 국가 전문자격 종류 가맹거래사 감정사 감정평가사 검량사 검수사 경매사 경비지도사 경영지도사 공인노무사 공인중개사 관광통역안내사 관세사 국가유산수리기능자(24종목) 국가유산수리기술자 국내여행안내사 기술지도사 농산물품질관리사 물류관리사 박물관 및 미술관 준학예사 변리사 사회복지사 1급 산업보건지도사 산업안전지도사 세무사 소방시설관리사 소방안전교육사 손해평가사 수산물품질관리사 정수시설운영관리사 주택관리사보 청소년상담사 청소년지도사 한국어교육능력검정시험 행정사 호텔경영사 호텔관리사 호텔서비스사 2026 01.17