Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IF YOU DON\'T HAVE MATLAB BUT FEEL LIKE WRITING IT BY HAND HOW IT IS SUPPOSED TO

ID: 1842365 • Letter: I

Question

IF YOU DON'T HAVE MATLAB BUT FEEL LIKE WRITING IT BY HAND HOW IT IS SUPPOSED TO BE ENTERED INTO MATLAB THAT WOULD BE OK

The Bakhshali manuscript is a mathematical manuscript written on birch bark which was found near the village of Bakhshali in what is now Pakistan in 1881. The scripts are dated around 400 AD. The manuscript gives various algorithms and techniques for variety of mathematical problems, such as computing the square roots. According to Bakhshali manuscript, the square root of a number s can be approximated as where 2 A and D s- x P OLD 2 xOLD where xOLD is an approximate root. Write a MTLAB script M-file to calculate the square root of any real number using the Bakshali method Test your script with s equal to 64 and 19781.9876. Use TOL 1.0e-15 Hints: Since A depends on P, and P depends on D, define (assign values to) D first, then P, and then

Explanation / Answer

s = input('Enter the number for which square root has to be calculated:');
x_old = input('Enter an approximate value:');
format long
Tol = 1e-15;
sqrt_s_Bakhshali = 0
while abs((sqrt(s)-sqrt_s_Bakhshali))>Tol
D = s - x_old^2;
P = D/(2*x_old);
A = x_old + P;
sqrt_s_Bakhshali = A - P^2/(2*A);
x_old = sqrt_s_Bakhshali
end

sqrt_s_Bakhshali

OUTPUT:

>> Bakhshali
Enter the number for which square root has to be calculated:64
Enter an approximate value:7

sqrt_s_Bakhshali =

0


x_old =

8.000316055625790


x_old =

8


sqrt_s_Bakhshali =

8

>> Bakhshali
Enter the number for which square root has to be calculated:19781.9876
Enter an approximate value:140

sqrt_s_Bakhshali =

0


x_old =

1.406484539632600e+02


x_old =

1.406484539552426e+02


sqrt_s_Bakhshali =

1.406484539552426e+02