Computers and Technology

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).

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:30, winstonbendariovvygn
1. which of the following is a search engine? a) mozilla firefox b)internet explorer c)google d)safari 2. which of the following statements is true? a) all search engines will provide the same results when you enter the same query. b) all search engines use the same amount of advertisements. c) some search engines are also browsers. d) search engines often provide different results, even when you enter the same query.
Answers: 2
image
Computers and Technology, 23.06.2019 09:10, djs1671
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
image
Computers and Technology, 24.06.2019 02:00, arubright177
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, livagrace
Emma is using an artificial intelligence system, which contains information on botany, to identify a type of plant from an image. what type of ai is emma using?
Answers: 1
Do you know the correct answer?
In(1 + x) can be approximated using the following Maclaurin series expansion: x2 In(1 + x) = %=1(–1...

Questions in other subjects:

Konu
English, 21.12.2020 14:00