- 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] 하시면 입체적 표현으로 바뀝니다.

세상의모든계산기 님의 최근 댓글
뉴턴-랩슨 적분 방정식 시각화 v1.0 body { font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; display: flex; flex-direction: column; align-items: center; background: #f8f9fa; padding: 40px 20px; margin: 0; color: #333; } .container { background: white; padding: 40px; border-radius: 20px; box-shadow: 0 15px 35px rgba(0,0,0,0.08); max-width: 900px; width: 100%; } header { border-bottom: 2px solid #f1f3f4; margin-bottom: 30px; padding-bottom: 20px; } h1 { color: #1a73e8; margin: 0 0 10px 0; font-size: 1.8em; } p.subtitle { color: #5f6368; margin: 0; font-size: 1.1em; } .equation-box { background: #f1f3f4; padding: 15px; border-radius: 10px; text-align: center; margin-bottom: 30px; font-size: 1.3em; } canvas { border: 1px solid #e0e0e0; border-radius: 12px; background: #fff; width: 100%; height: auto; display: block; } .controls { margin-top: 30px; display: flex; gap: 15px; align-items: center; justify-content: center; flex-wrap: wrap; } button { padding: 12px 25px; border: none; border-radius: 8px; background: #1a73e8; color: white; cursor: pointer; font-weight: 600; font-size: 1em; transition: all 0.2s; box-shadow: 0 2px 5px rgba(26,115,232,0.3); } button:hover { background: #1557b0; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(26,115,232,0.4); } button:active { transform: translateY(0); } button.secondary { background: #5f6368; box-shadow: 0 2px 5px rgba(0,0,0,0.2); } button.secondary:hover { background: #4a4e52; } .status-badge { background: #e8f0fe; color: #1967d2; padding: 8px 15px; border-radius: 20px; font-weight: bold; font-size: 0.9em; } .explanation { margin-top: 40px; padding: 25px; background: #fff8e1; border-left: 5px solid #ffc107; border-radius: 8px; line-height: 1.8; } .explanation h3 { margin-top: 0; color: #856404; } .math-symbol { font-family: 'Times New Roman', serif; font-style: italic; font-weight: bold; color: #d93025; } .code-snippet { background: #202124; color: #e8eaed; padding: 2px 6px; border-radius: 4px; font-family: monospace; } 📊 Newton-Raphson 적분 방정식 시뮬레이터 미분적분학의 기본 정리(FTC)를 이용한 수치해석 시각화 목표 방정식: ∫₀ᴬ (2√x) dx = 20 을 만족하는 A를 찾아라! 계산 시작 (A 추적) 초기화 현재 반복: 0회 💡 시각적 동작 원리 (Newton-Raphson & FTC) Step 1 (오차 측정): 현재 A까지 쌓인 파란색 면적이 목표치(20)와 얼마나 차이나는지 계산합니다. Step 2 (FTC의 마법): 면적의 변화율(미분)은 그 지점의 그래프 높이 f(A)와 같습니다. Step 3 (보정): 다음 A = 현재 A - (면적 오차 / 현재 높이) 공식을 사용하여 A를 이동시킵니다. 결론: 오차를 현재 높이로 나누면, 오차를 메우기 위해 필요한 가로 길이(ΔA)가 나옵니다. 이 과정을 반복하면 정답에 도달합니다! const canvas = document.getElementById('graphCanvas'); const ctx = canvas.getContext('2d'); const iterText = document.getElementById('iterText'); // 수학 설정 const targetArea = 20; const f = (x) => Math.sqrt(x) * 2; // 피적분 함수 f(x) = 2√x const F = (x) => (4/3) * Math.pow(x, 1.5); // 정적분 결과 F(x) = ∫ 2√x dx = 4/3 * x^(3/2) let A = 1.5; // 초기값 let iteration = 0; let animating = false; // 그래프 드로잉 설정 const scale = 50; const offsetX = 60; const offsetY = 380; function drawGrid() { ctx.strokeStyle = '#f1f3f4'; ctx.lineWidth = 1; ctx.beginPath(); for(let i=0; i 2026 04.11 참값 : A = ±2√5 근사값 : A≈±4.472135954999579392818347 2026 04.10 fx-570 ES 입력 결과 초기값 입력 반복 수식 입력 반복 결과 2026 04.10 파이썬 코드 검증 결과 초기값: 5.0 반복 1회차: 4.5000000000 반복 2회차: 4.4722222222 반복 3회차: 4.4721359558 반복 4회차: 4.4721359550 반복 5회차: 4.4721359550 초기값: 10.0 반복 1회차: 6.0000000000 반복 2회차: 4.6666666667 반복 3회차: 4.4761904762 반복 4회차: 4.4721377913 반복 5회차: 4.4721359550 2026 04.10 감사합니다. 주말 잘 보내세요. 2026 03.06