Bisection and Newton's Approximation

Click For Summary
SUMMARY

This discussion focuses on writing functions for the Bisection method and Newton's Approximation in Mathematica to find the roots of the function f(x) = sinh(x) - 2^x + x^4 - 2x^3 - 26x^2 + 4x + 48. The user seeks guidance on creating a function ApproxBisect[a0_, b0_, n_] that approximates a root over n steps and outputs the midpoints and function values. Additionally, the user requests feedback on their implementation and suggestions for improving their Mathematica skills, emphasizing the need for efficiency and readability in their code.

PREREQUISITES
  • Basic understanding of root-finding algorithms: Bisection method and Newton's Approximation
  • Familiarity with Mathematica programming language and syntax
  • Knowledge of hyperbolic functions and polynomial equations
  • Experience with function definitions and iterative processes in programming
NEXT STEPS
  • Implement and test the function ApproxBisect[a0_, b0_, n_] in Mathematica
  • Learn about Newton's method for root finding and its implementation in Mathematica
  • Explore Mathematica's built-in functions for numerical analysis and root-finding
  • Study best practices for code efficiency and readability in Mathematica
USEFUL FOR

This discussion is beneficial for students and educators in mathematics or computer science, particularly those involved in numerical methods, as well as beginners in Mathematica looking to enhance their programming skills and understanding of root-finding techniques.

arhzz
Messages
284
Reaction score
58
TL;DR Summary: Writing functions for Bisection and Newtons Approximation in Mathematica

Hello! I need to write 2 functions in mathematica, to find the roots of functions. The functions are the Bisection methods and Newtons Approximation.

(b1) Write your own function ApproxBisect[a0_,b0_,n_], which starting from an initial interval [a0, b0] approximates a root of the function in n steps. As a result, output the list of the n interval midpoints and the corresponding function values.

(b2) Test your function for the function f over a suitably chosen range and an appropriate number of approximation steps.

The function f(x) is this ## f(x) = \sinh(x) - 2^x + x^4 - 2x^3 - 26x^2 + 4x + 48 ##

Now this is my attempt at the solution (since I dont know how to post mathematica code formatted nicely I will put a screenshot)

plss.png

For Newton I tried this

plz2.png


And I printed all the values as a list (I can post a screenshot of the code if necesarry)

Now my main question is this ; Would you say this is correct ? I have never programmed in mathematica before so it is very new to me and I am not the most skilled programmer as it is. And since this is a team project I really dont want to be the reason we get a bad grade or worst case scenario fail the class.


Secondly, as I've stated that I am a beginner in mathematica, all tipps/tricks/suggestions are welcome; (efficiency,readability etc.) Also any good literature (crashcourse would be ideal) in mathematica is also appreciated.

Thanks in advance!
 
Physics news on Phys.org
  • Like
Likes   Reactions: arhzz

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
2
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
5K