# Gauss-Seidel iteration in Matlab

Hello

I am taking a numerical methods class and I have limited Matlab skills to be able to complete this problem by myself.

The problem is to linearize the Lorenz equations and then to write a Matlab program without using any built in Matlab solvers such as ODE45, etc. to create the Lorenz butterfly using linearized Lorenz equations with Gauss-Seidel iteration.

I have the linearized Lorenz equations, constants, stopping criteria and initial conditions here:

stopping criteria: 1.e-6

initial conditions: x = 2, y = 2, z = 4

sigma = 10, rho = 28, beta = 8/3

delta_t = 1.e-4

linearized lorenz equations:

x^n+1 - x^n = delta_t * sigma*(y^n+1 - x^n+1)

[please rewrite so equation begins x^n+1 = ...]

y^n+1 = (1 + delta_t*x^n+1*(rho - z^n+1)/(1 + delta_t)

z^n+1 = (1 + delta_t * x^n+1 * y^n+1)/(1 + beta * delta_t)

The code MUST only use Gauss-Seidel iteration to run the iterations (no RK2 or other methods). The code may not use any built in Matlab functions or solvers or matrices to store answers. It needs to tell how much CPU time was used (incorporate tic toc?) What was also suggested was to use a file to dump all results to while the iterations run, making the program run faster. With the results of the iterations a 3D plot needs to be plotted to show the Lorenz butterfly (attractor) using delta_t = 1.e-4. Then a second plot needs to be created that shows the x on the vertical axis and t on the horizontal axis plotting both delta_t = 1.e-4 and delta_t = 1.e-5 so you can see how a slight variation in delta_t causes the two lines to depart after a short while

© BrainMass Inc. brainmass.com June 3, 2020, 10:08 pm ad1c9bdddfhttps://brainmass.com/math/linear-algebra/matlab-lorenz-equations-gauss-seidel-iteration-216994

#### Solution Preview

The case with dt = 1e-4 runs 193 seconds

on my PC ( 6 years old, one 2GHz processor, 2GB memory),

so the case with dt= 1e-5 should probably run 10 times as much.

(!!! Do not forget to modify the values of dt1 and dt2 at the start of ...

#### Solution Summary

This provides an example of creating a Matlab code for Gauss-Seidel iteration.