Question: in this code the equation is hard coded i want to change this code like user can give any kind of equation like that:- this

 in this code the equation is hard coded i want to

in this code the equation is hard coded i want to change this code like user can give any kind of equation like that:-

change this code like user can give any kind of equation like

this is the regula falsi method

code in written form:

import math N=int(input("Enter the no. Of Iterations :")) TOL=float(input("Enter the Error Tolerance :")) a = float(input("Enter the left endpoint of the interval: ")) b = float(input("Enter the right endpoint of the interval: ")) xn = b x0 = a x1 = b fx0 = 4*x0 + math.sin(x0) - math.exp(x0) fx1 = 4*x1 + math.sin(x1)- math.exp(x1) for k in range(2,N+2): xp = xn xn = float(x1) - (float(fx1)* (float(x1)-float(x0))) / (float(fx1)- float(fx0)) fxn = 4*xn + math.sin(xn)-math.exp(xn); err = abs(xn-xp)/abs(xn)

print("After " + str(k-1) +" iterations, the approximate root = " + str(xn)) print("f(x) = " + str(fxn) + " Error = " + str(err)) if(fxn

b = import math N=int(input("Enter the no. of Iterations :") TOL=float(input("Enter the Error Tolerance :") a = float(input("Enter the left endpoint of the interval: ")) float(input("Enter the right endpoint of the interval: ")) xn = b xo = a x1 = b fxo = 4*x0 + math.sin(x0) - math.exp(x0) fx1 = 4*x1 + math.sin(x1)- math.exp(x1) for k in range(2,N+2): xp = xn float(x1) - (float(fx1)* (float(x1)-float(x0))) / (float(fx1)- float(fxo)) fxn = 4*xn + math.sin(xn)-math.exp(xn); abs(xn-xp)/abs(xn) xn err = + str(xn)) print("After + str(k-1) +" iterations, the approximate root = print("f(x) = + str(fxn) + Error = " + str(err)) if(fxn

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!