Question: 1. Find the errors in the code below, correct and make sure the code runs. 2. When trying to find the acidity of a solution

1. Find the errors in the code below, correct and make sure the code runs.

function secant () f=(x) x^3+x-3; e-le-6; x0=1000; xl=x0-1; [solution, no_iterations] = secant

2. When trying to find the acidity of a solution of magnesium hydroxide in hydrochloric acid, the following equation is obtained: 
A(x) = x³ +3.5x² - 40 where x is the hydronium ion concentration. 
3. Find the hydronium ion concentration for a saturated solution using the roots function on OCTAVE. 
4. The roots of the equation using f zero near 2.
5. Find the minimum values for the set of equations; indicate if the solution has on converged. 

                                            x² + 4y² - 1 = 0 

                                            4x4 + y² - 1 = 0

function secant () f=(x) x^3+x-3; e-le-6; x0=1000; xl=x0-1; [solution, no_iterations] = secant (f, x0, x1); if no iterations> 0 solution is found fprintf('number of function calls: %d ',2 + no_iterations); fprintf('a solution is: f ', solution); else end end function [solution, no_iterations] =secant ( x0, xl) f_x0=f(x0); f_xl=f(x1); iteration_counter = 0; while abs (f_xl)>e && iteration_counter e iteration_counter = -1;

Step by Step Solution

3.34 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 The errors in the code are as follows The function secant is missing input arguments f and e The line x01000 x1x01 should be indented inside the secant function The line solution noiterations secant ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!