diff options
Diffstat (limited to 'Tutorial05-Solution_of_equations')
9 files changed, 73 insertions, 0 deletions
diff --git a/Tutorial05-Solution_of_equations/Problems/README.md b/Tutorial05-Solution_of_equations/Problems/README.md new file mode 100644 index 0000000..f7a9032 --- /dev/null +++ b/Tutorial05-Solution_of_equations/Problems/README.md @@ -0,0 +1 @@ +# Problems for non-linear equations diff --git a/Tutorial05-Solution_of_equations/Problems/Tut5.pdf b/Tutorial05-Solution_of_equations/Problems/Tut5.pdf Binary files differnew file mode 100644 index 0000000..a8c2c51 --- /dev/null +++ b/Tutorial05-Solution_of_equations/Problems/Tut5.pdf diff --git a/Tutorial05-Solution_of_equations/README.md b/Tutorial05-Solution_of_equations/README.md new file mode 100644 index 0000000..56a4129 --- /dev/null +++ b/Tutorial05-Solution_of_equations/README.md @@ -0,0 +1 @@ +# Non-linear equations diff --git a/Tutorial05-Solution_of_equations/Scilab_code/README.md b/Tutorial05-Solution_of_equations/Scilab_code/README.md new file mode 100644 index 0000000..297d7b8 --- /dev/null +++ b/Tutorial05-Solution_of_equations/Scilab_code/README.md @@ -0,0 +1 @@ +# Scilab code for non-linear equations diff --git a/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_linear_equation.sce b/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_linear_equation.sce new file mode 100644 index 0000000..dcd5510 --- /dev/null +++ b/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_linear_equation.sce @@ -0,0 +1,22 @@ +//This scilab script is to compute the solution of a linear equation +clear +clc + +//Example of Ax + b = 0 where unique solution exists +A = [1 2 3;3 2 1;2 4 5]; +b = [7;7;12]; +[x,kerA] = linsolve(A,b); +disp(x,'Solution of Ax + b',kerA,'kernel of A'); + +//Example of Py+q = 0 where solution does not exist +P = [1 2 3;3 2 1;4 4 4] +q = [1;2;1] +[y,kerP] = linsolve(P,q); +disp(y,'Solution of Py + q',kerP,'kernel of P'); + +//Example of Lz+m = 0 where infinite solutions exist +L = [1 2 3;3 2 1;4 4 4] +m = [1;1;2] +[z,kerL] = linsolve(L,m); +disp(z,'Solution of Lz + m',kerL,'kernel of L'); + diff --git a/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_nonlinear_equation.sce b/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_nonlinear_equation.sce new file mode 100644 index 0000000..7f2a9ce --- /dev/null +++ b/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_nonlinear_equation.sce @@ -0,0 +1,21 @@ +//This scilab script is to compute the solution of a nonlinear function with initial +//guess x_0 +clear +clc + + +//The nonlinear equation for which solutions are sought +exec func.sci; + + +//Initial guess for the solution +t0 = 0; + +//Computation of solution using fsolve +y_result = fsolve(t0,func); +//Display the solution in command window +disp(y_result,'Solution of the equation') + + + + diff --git a/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_nonlinear_equation_twovar.sce b/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_nonlinear_equation_twovar.sce new file mode 100644 index 0000000..2b5dce1 --- /dev/null +++ b/Tutorial05-Solution_of_equations/Scilab_code/Tutotial5_nonlinear_equation_twovar.sce @@ -0,0 +1,17 @@ +//This scilab script is to compute the solution of a nonlinear function with initial +//guess x_0 +clear +clc + + +//The nonlinear equation for which solutions are sought +exec functwovar.sci; + + +//Initial guess for the solution +t0 = [0;0]; + +//Computation of solution using fsolve +y_result = fsolve(t0,functwovar); +//Display the solution in command window +disp(y_result,'Solution of the equation') diff --git a/Tutorial05-Solution_of_equations/Scilab_code/func.sci b/Tutorial05-Solution_of_equations/Scilab_code/func.sci new file mode 100644 index 0000000..013277d --- /dev/null +++ b/Tutorial05-Solution_of_equations/Scilab_code/func.sci @@ -0,0 +1,4 @@ +//This is script to define a fuction +function y = func(t) + y = cos(t)*sin(t) - tan(t) + 1 +endfunction diff --git a/Tutorial05-Solution_of_equations/Scilab_code/functwovar.sci b/Tutorial05-Solution_of_equations/Scilab_code/functwovar.sci new file mode 100644 index 0000000..6506ce4 --- /dev/null +++ b/Tutorial05-Solution_of_equations/Scilab_code/functwovar.sci @@ -0,0 +1,6 @@ +//This is script to define a fuction +function y = functwovar(t) + x = t(1); + z = t(2); + y = [x^2+z^2-1;x^2*exp(-2*x) + z] +endfunction |