Bisection and Newton's Approximation

AI Thread Summary
The discussion focuses on creating functions in Mathematica for the Bisection method and Newton's Approximation to find roots of a specific function, f(x) = sinh(x) - 2^x + x^4 - 2x^3 - 26x^2 + 4x + 48. The user seeks validation of their implementation and is concerned about their programming skills as a beginner. Suggestions include testing the functions with known polynomials, improving code efficiency and readability, and exploring resources for learning Mathematica. The discussion emphasizes the importance of accuracy in a team project to avoid negatively impacting grades. Overall, the user is looking for guidance and reassurance in their coding efforts.
arhzz
Messages
279
Reaction score
56
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
Thread 'Have I solved this structural engineering equation correctly?'
Hi all, I have a structural engineering book from 1979. I am trying to follow it as best as I can. I have come to a formula that calculates the rotations in radians at the rigid joint that requires an iterative procedure. This equation comes in the form of: $$ x_i = \frac {Q_ih_i + Q_{i+1}h_{i+1}}{4K} + \frac {C}{K}x_{i-1} + \frac {C}{K}x_{i+1} $$ Where: ## Q ## is the horizontal storey shear ## h ## is the storey height ## K = (6G_i + C_i + C_{i+1}) ## ## G = \frac {I_g}{h} ## ## C...

Similar threads

Replies
2
Views
2K
Replies
2
Views
2K
Replies
8
Views
2K
Replies
4
Views
4K
Replies
16
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
13
Views
5K
Back
Top