Answered step by step
Verified Expert Solution
Question
1 Approved Answer
pro 1 . When n varies from 3 to 5 0 , TDMA methods are used to determine the displacement of x 1 in equilibrium
pro When n varies from to TDMA methods are used to determine the displacement of x in equilibrium to find n versus x and graph it Using process C
I got the c code for question However, I ran the c code, but an error occurred. I wonder what the problem isPlease refer to the picture below
Link to the answer I received : https:wwwchegg.comhomeworkhelpquestionsandanswerspronvariestdmamethodsuseddeterminedisplacementxequilibriumfindnversusxq
The c code I received:
#include
#include
#include
Function to perform TDMA Thomas Algorithm
void TDMAconst std::vector& a const std::vector& b const std::vector& c std::vector& d std::vector& x
int n bsize;
std::vector cstarn;
std::vector dstarn;
Modify the coefficients
cstar c b;
dstar d b;
for int i ; i n; i
double m bi ai cstari ;
cstari ci m;
dstaridi ai dstari m;
Back substitution
xn dstarn ;
for int i n ; i ; i
xi dstari cstari xi ;
int main
Open a file to write results
std::ofstream outfileresultstxt;
Loop over different sizes of the matrix
for int n ; n ; n
Initialize vectors for the tridiagonal matrix
std::vector an ; Subdiagonal a to an
std::vector bn; Main diagonal b to bn
std::vector cn ; Superdiagonal c to cn
std::vector dn; Righthand side d to dn
Vector to store the solution
std::vector xn;
Apply TDMA to solve the system
TDMAa b c d x;
Output the displacement x
std::cout n n x x std::endl;
outfile n x std::endl;
Close the file
outfile.close;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started