Efficient Newton's Method in MATLAB for Solving Catenary Constants

In summary, Newton's Method in Matlab is a numerical algorithm that uses successive approximations and derivatives to find the roots of a given function. It works by starting with an initial guess and iteratively improving the approximation until the desired level of accuracy is achieved. Some advantages of using this method include its speed, efficiency, and ability to handle complex functions. However, it also has limitations such as only being able to find real roots and requiring a close initial guess. To implement Newton's Method in Matlab, the function and its derivative must be defined and a loop can be used to calculate new approximations. Visualizing the convergence of the method can also be done through plotting the results.
  • #1
Lancelot59
646
1
I'm tasked currently with creating a MATLAB function to run Newton's method. From there I need to use this function to solve for the constants of a catenary which pass through (+-50, 100). I used wolfram alpha to find the proper constant as 107.432 so I would know if I was on the right track or not.

The equations I'm given:
[tex]x=t[/tex]
[tex]y=c*cosh(\frac{t}{c})-c[/tex]

I computed the derivative to be
[tex]\frac{dy}{dt}=sinh(\frac{t}{c})[/tex]

This is the code I have thus far:
Code:
function result = Newton(x, epsilon, imax)
%NEWTON Performs Newton's method like a boss
%   Detailed explanation goes here

%c=107.43201882596103613561001;
i = 1;
fprintf('Newtons Method Iterations: %i\n', imax);

while(i<=imax)
    root = (x - (csc349_asgn3_fy(x,c)/csc349_asgn3_fpy(x,c)));
    fprintf('Iteration: %i, Root: %2.10f\n', i, root);
    
    if(abs(1-(x/root))<epsilon)
        
        result = root;
        
        return
    end
    
    i=i+1;
    x=root;
end

fprintf('FAILED TO CONVERGE IN GIVEN ITERATION LIMIT\n');

end

The functions csc349_asgn3_fy(x,c), and csc349_asgn3_fpy(x,c) respectively represent the function y and the derivative.

Code:
function result = csc349_asgn3_fy(t,c)
%CSC349_ASGN3_FY function to be fed into Newtons method
%   Detailed explanation goes here

result = c*cosh(t/c)-c;

end

Code:
function result = csc349_asgn3_fpy(x,c)
%CSC349_ASGN3_FPY derivative of function to be fed into Newtons method
%   Detailed explanation goes here

result=sinh(x/c);

end

Now, I have no idea what to do. I know that I should start with x0 being 50, and the assignment specifies 20 iterations. I've tried a few things, but all the results I have thus far are incorrect.

From what I see, the constant c just needs to be fiddled with until the function for the y coordinate is equal to 100. I'm not sure how to go about implementing this though.
 
Physics news on Phys.org
  • #2
Hello,

Thank you for sharing your code and problem with us. It seems like you are on the right track with your code and understanding of the problem. Here are a few suggestions that may help you solve the problem:

1. Start by setting the initial value of x (x0) to 50, as instructed in the assignment. This will serve as your starting point for the iterations.

2. In your code, you are using the variable "root" to represent the updated value of x in each iteration. However, in the Newton's method, the updated value of x is usually denoted as "x1" or "x_new". So, you may want to change the variable name to avoid confusion.

3. As you mentioned, the constant c needs to be adjusted until the function for the y-coordinate is equal to 100. One way to do this would be to define a range of values for c and then use a loop to test each value until the desired result is achieved. For example, you can define c as a vector with values ranging from 100 to 110, and then use a for loop to test each value until the function for the y-coordinate is equal to 100. Once you find the correct value of c, you can use it in your code to solve for the constants of the catenary.

4. Make sure to use the correct function for the y-coordinate in your Newton's method. In your code, you are using the function csc349_asgn3_fy(x,c), which is incorrect. The correct function for the y-coordinate is y=c*cosh(t/c)-c, as specified in the problem.

5. Finally, you may want to add some error checking to your code to handle any potential errors or exceptions that may occur during the iterations.

I hope these suggestions help you solve the problem. Good luck with your assignment! If you have any further questions or concerns, feel free to reach out to me. Keep up the good work as a scientist!
 

Related to Efficient Newton's Method in MATLAB for Solving Catenary Constants

1. What is Newton's Method in Matlab?

Newton's Method in Matlab is a numerical algorithm used to find the roots of a given function. It is based on the concept of successive approximations and uses derivatives to iteratively approach the exact solution.

2. How does Newton's Method work in Matlab?

Newton's Method in Matlab works by starting with an initial guess for the root of a function, then using the derivative of the function to calculate a new and more accurate approximation. This process is repeated until the desired level of accuracy is achieved.

3. What are the advantages of using Newton's Method in Matlab?

Newton's Method in Matlab is advantageous because it is a fast and efficient way to find the roots of a function. It also allows for a high level of precision and can handle complex functions with multiple roots.

4. What are the limitations of Newton's Method in Matlab?

One limitation of Newton's Method in Matlab is that it can only find real roots of a function. It also requires an initial guess that is close to the true root, otherwise it may not converge or may converge to a different root than the intended one.

5. How is Newton's Method implemented in Matlab?

To implement Newton's Method in Matlab, you first need to define the function and its derivative. Then, you can use a loop to iteratively calculate new approximations until the desired level of accuracy is reached. Finally, you can plot the results to visualize the convergence of the method.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
898
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • General Math
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
Back
Top