# Software Engineering process

**URL:** <https://forum.anaconda.com/t/software-engineering-process/86246>\
**Category:** Python in Excel\
**Created:** [October 20, 2024, 6:06pm UTC](https://forum.anaconda.com/t/software-engineering-process/86246 "2024-10-20T18:06:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajzamalemilbekovna](https://avatars.discourse-cdn.com/v4/letter/a/db6015/32.png) [@ajzamalemilbekovna](https://forum.anaconda.com/u/ajzamalemilbekovna)\
**Post date:** [October 20, 2024, 6:06pm UTC](https://forum.anaconda.com/t/software-engineering-process/86246/1 "2024-10-20T18:06:18Z")

</div>

import numpy as np  
import matplotlib.pyplot as plt  
import pandas as pd

# Function f(x) = 3x - e^x

def f(x):  
return 3 \* x - np.exp(x)

# Modified Secant method function

def secant\_method\_fixed\_x0(x0, x1, tolerance, max\_iterations):  
iterations\_data =   
for iteration in range(max\_iterations):  
f\_x0 = f(x0)  
f\_x1 = f(x1)  
# Check for division by zero  
if f\_x1 - f\_x0 == 0:  
print(“Error: Division by zero”)  
return None  
# Calculate the new xn  
xn = x1 - (f\_x1 \* (x1 - x0)) / (f\_x1 - f\_x0)  
# Store iteration data  
eps = abs(f(xn)) # Update error to be based on function value  
iterations\_data.append([iteration + 1, x0, x1, f\_x0, f\_x1, eps])  
# Check if the tolerance is met  
if eps \< tolerance:  
break  
# Update x1 for the next iteration, keep x0 fixed  
x1 = xn  
return iterations\_data, xn, iteration + 1

# Input parameters

x0 = -1 # Fixed x0 as per your table  
x1 = -0.5 # Initial guess for x1  
tolerance = 0.01 # Desired tolerance  
max\_iterations = 10 # Maximum number of iterations

# Run the Secant method with fixed x0

result, final\_xn, total\_iterations = secant\_method\_fixed\_x0(x0, x1, tolerance, max\_iterations)

# If we have results, display them in a table and plot the convergence

if result:  
# Convert the result into a DataFrame for pretty display  
columns = [‘n’, ‘x0’, ‘xn’, ‘f(x0)’, ‘f(xn)’, ‘eps’]  
df = pd.DataFrame(result, columns=columns)  
# Display the result in tabular form  
print(df)  
print(f"\nSolution found: xn = {final\_xn}, after {total\_iterations} iterations")  
# Plot the convergence of eps (error)  
plt.plot(df[‘n’], df[‘eps’], marker=‘o’, color=‘b’, label=‘eps’)  
plt.xlabel(‘Iteration’)  
plt.ylabel(‘eps (error)’)  
plt.title(‘Error Dynamics in Secant Method’)  
plt.grid(True)  
plt.legend()  
plt.show()  
else:  
print(“No solution found due to error.”)

---

<div class="post-metadata">

**Author:** ![OwenPrice](https://dub1.discourse-cdn.com/anaconda/user_avatar/forum.anaconda.com/owenprice/32/5105_2.png) [@OwenPrice](https://forum.anaconda.com/u/OwenPrice)\
**Post date:** [October 21, 2024, 2:12pm UTC](https://forum.anaconda.com/t/software-engineering-process/86246/2 "2024-10-21T14:12:10Z")

</div>

Hi and welcome to the forum!

I didn’t see a question in your post. Is this related to Python in Excel?

Please let me know if I can help in some way.

Thanks
