Tutorial: Nonlinear solver
Tutorial: Nonlinear Solver- student
Problem
Solve for x, in f(x)= 8-4.5*(x-sin(x))
Matlab Functions
Exercise - MATLAB
Download the tutorial source file and fill in the blanks. Run the code and validate your answer
MATLAB tutorial source file : TU_nonlinear_student.mlx
Exercise - C Programming
Create a new project “ TU_Nonlinear” with Visual Studio, under the directory
\NP\tutorial\
Download the tutorial source file from
C-program tutorial source file : TU_nonlinear_student.cpp
3. Add it as the source file.
4. Add the header files in your project: myNP_tutorial.h
and myNP_tutorial.c
can be downloaded from the link. The same header created in Tutorial-Sine Taylor: Part 2
should be saved in
\NP
\include` folder
Exercise 1
Bisection Method
Assuming (func(a) * func(b) <0 )
First, Write down a pseudocode for the bisection
Based on the pseudocode, fill in the blanks in the source code.
Move your functions from main source file to your header files
function definitions:
myNP.h
function declaration:
myNP.c
Exercise 2
Modify your Bisection function, with considering the following conditions
if(func(a) * func(b) > 0), No solution exists
if(func(a) * func(b) 0), Either (1) aXtrue or (2) b=Xtrue
if(k==Nmax) Solution did not converged within given it teration
Exercise 3
Newton Raphson Method
First, Write down a pseudocode for the method
Based on the pseudocode, fill in the blanks in the source code.
3. You need to define the function f(x)
and the derivative function dfdx(x)
as
For dfdx(x), get the derivative formula analytically.
4. Move your functions from main source file to your header files
function definitions:
myNP.h
function declaration:
myNP.c
Exercise 4
Modify Newton Raphson Method with function callback
Modify the newton raphson function that calls functions as inpur argment as
Last updated