subject

In(1 + x) can be approximated using the following Maclaurin series expansion: x2 In(1 + x) = %=1(–1)n-1 * = x - x2/2 + x3/3 - x4/4 for (12x>-1)
Use the pseudocode below to implement the expansion as a MATLAB function. Calculate the true percent relative error for each iteration. The loop should terminate when the true percent relative error of falls below 0.0001. The true value can be found using the MATLAB's log function and the approximation is found using the Taylor series expansion. The input to the function should be the value x. Test your code with x = 0.25.
FUNCTION my_In(x)
tpre = 100
approx = 0
true_value = In(1+x)
n = 1
DO
new_term = (–1)n-1 X
approx = approx + new_term
tore-[true value – approx * 100 tpre = true value
n= n +1
IF tpre < 0.0001 OR n > 1000
EXIT
ENDIF
END
DO
Display approx
Display tpre
END my_In
Hint 1 - Don't use 'EXIT' to break out of your loop in MATLAB (this will exit MATLAB).

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 21:00, tiffg2588
Will this setup result in what kathy wants to print?
Answers: 2
image
Computers and Technology, 24.06.2019 07:50, treytonmesser
Write a defining table and then a program that determines if you can sleep in or not. your program should get all its input from your computer’s clock. on all weekdays (monday through friday) that are not holidays, your program should output “get up! ” on all other days (weekends and holidays), your program should output “sleep in.” the three holidays that your program must check for are january 1 (new year’s day), july 4 (u. s. independence day), and december 25 (christmas). you don’t need to include other holidays in your program because most other holidays do not occur on a fixed day each year.
Answers: 1
image
Computers and Technology, 24.06.2019 16:50, genyjoannerubiera
Ramp charts are generally created in wordlotusexcelpowerpoint
Answers: 1
image
Computers and Technology, 24.06.2019 17:40, HealTheWorld
Write a program that begins by reading in a series of positive integers on a single line of input and then computes and prints the product of those integers. integers are accepted and multiplied until the user enters an integer less than 1. this final number is not part of the product. then, the program prints the product. if the first entered number is negative or 0, the program must print “bad input.” and terminate immediately
Answers: 2
You know the right answer?
In(1 + x) can be approximated using the following Maclaurin series expansion: x2 In(1 + x) = %=1(–1...

Questions in other subjects:

Konu
Biology, 29.11.2020 03:40
Konu
Mathematics, 29.11.2020 03:40
Konu
Chemistry, 29.11.2020 03:40
Konu
Mathematics, 29.11.2020 03:40