Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Hi i'm taking an introductory course to matlab at Fau and i'm having a little trouble with my first project. I have no clue what to do actually. I was wondering if someone could help me out. This is the project template:
Develop a computer program in MATLAB that will evaluate the following function for -0.9 = x = 0.9 in steps of 0.1 by:
A) an arithmetic statement .
B) by series allowing for as many as 50 terms. However, end adding terms when the last term only affects the 6th place in the answer.
The function and its series expansion is:
f(x)= (1+x^2)^.5= 1-1/2x^2 + 1/2 x 3/4x^4 - 1/2 x 3/4 x 5/6x^6 +-....
Print out a table (to a file) in the following format; use 6 decimal places for f(x).
X f(x)(by arith stm) f(x)(by series) ]
and there should be one last row that says # of terms used in the series
This program should be written off of these examples...
% Calculation of e^x by a Taylor series using a while loop. The 'input
% statement' is used to establish the exponent, x. A 'while loop' is
% used in determining the series solution. In this example term(n) is
% obtained by multiplying term(n-1) by x and dividing by the index n.
x=input('enter a value for the exponent x
while abs(term) > ex*1.0e-6
if n > 50
% The program calculates of e^x by both an arithmetic statement (ex2)
% and by a Taylor series (ex1), where -0.5< x <0.5. A 'for loop' is
% used to determine the x values. In the series part of the program,
% the 'sum' function is used to sum all the terms calculated in the
% inner 'for loop'. Fifty terms are used in the series.
% Table headings
fprintf(' x ex1 ex2
fprintf('%5.2f %10.5f %10.5f
This probably looks so simple to most of you, But I really have no clue what i'm looking at. If someone could at least tell me how to go about starting to write this program. I would be very appreciative.
P.s. I tried to get the appropriate spacings to translate over to this text box but it just wasn't having it.
0 · ·