According to the fourth order Runge-Kutta method programming procedure, identify the logic errors presented by the following code. The code does work, but the correct answer is being affected by logic errors, identify which ones they are (More than one answer can be correct).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
According to the fourth order Runge-Kutta method programming procedure, identify the logic
errors presented by the following code. The code does work, but the correct answer is being
affected by logic errors, identify which ones they are (More than one answer can be correct).
function [x, y] = RK4 (f, a, b, yo,h)
1
2
x = a:h:b;
3
4
n = length (x);
y zeros (1,n);
y (1) = y0;
for 1-1:-1
5
6
kih f(y(1),y(i));
9
10
k2h f(x(i) +h/2,y(i)+1/2+k1);
11
12
k3 h f(x(1) +h/2, y(1)+1/2*k2);
13
14
k4h + f(x(1) +h, y(1) +k3);
15
16
y(i+1)= y(1)+(1/6)*k4;
17
18
19
end
Options:
-On line 12 the vector is missing an index and
-It remains to calculate k5 to store the new position in y
-The for must evaluate from i=1 to n+1
-The "for" must start at i=0
-In line 5 the value of h should have been saved instead of yo
-The function must receive 4 inputs and return 2 outputs.
-In line 8 the function must evaluatex and y
-In line 16 k1, k2, k3 are missing to complete the process of RK4.
-0-
end
Transcribed Image Text:According to the fourth order Runge-Kutta method programming procedure, identify the logic errors presented by the following code. The code does work, but the correct answer is being affected by logic errors, identify which ones they are (More than one answer can be correct). function [x, y] = RK4 (f, a, b, yo,h) 1 2 x = a:h:b; 3 4 n = length (x); y zeros (1,n); y (1) = y0; for 1-1:-1 5 6 kih f(y(1),y(i)); 9 10 k2h f(x(i) +h/2,y(i)+1/2+k1); 11 12 k3 h f(x(1) +h/2, y(1)+1/2*k2); 13 14 k4h + f(x(1) +h, y(1) +k3); 15 16 y(i+1)= y(1)+(1/6)*k4; 17 18 19 end Options: -On line 12 the vector is missing an index and -It remains to calculate k5 to store the new position in y -The for must evaluate from i=1 to n+1 -The "for" must start at i=0 -In line 5 the value of h should have been saved instead of yo -The function must receive 4 inputs and return 2 outputs. -In line 8 the function must evaluatex and y -In line 16 k1, k2, k3 are missing to complete the process of RK4. -0- end
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education