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

Using Matlab write a program to determine values from the following infinite ser

ID: 3401256 • Letter: U

Question

Using Matlab write a program to determine values from the following infinite series.

There are two inputs, the value of (x), and the number of terms to use in the series (n), and there is one output, the value of the function.

Using x=0.932 n=7 as your inputs to find the value of the this function.

I've tried working the problem but I just can't get it to give me 7 of the correct values. Here is what I have so far:

x=0.932
n=7
exp1=sqrt(x)/42
exp2=x^(n-1)/n
sum=0
for i=exp1:.5:n
    op=exp1+exp2
    sum=sum+op
end

Any help is appreciated with this problem. Thank you.

Explanation / Answer

I am not sure what "for i=exp1:.5:n" is doing in your code.

You want a for loop to count from 1 to n

To do this, use "for i=1:n"

Also, exp2 seems incorrect since you are starting with i=1. The first term is x/2 which corresponds to x^(i)/(i+1)

Below is the corrected code:

function [ y ] = approx_qn( x,n )
sum=sqrt(x)/42;
for i=1:n
    sum=sum+x^i/(i+1);
end
sum
end

This should be saved as a Matlab function file.

To call the function, use command approx_qn(0.932,7)

This gives the answer as 1.418996574739526

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote