Question
create an editor in matlab program that prints in a single graph the sin(b) function for (is in the photo) and the approximate sine values ​​b with the taylor series

Create the program in such a way that the graphics are smooth.

Add title, label axes and create legend with meaningful information.

Create the flowchart.
Cree un programa editor que imprima en un solo gráfico la función de seno(B) para -AS Bsn y los valores de seno(B ) aproximad
0 0
Add a comment Improve this question Transcribed image text
Answer #1
  • In this problem, we have to calcluate and plot sin(x) function using taylor series

Program plan:

  • Define a function that calculates taylor's series for an argument x.
  • define a range b = -pi:0.01:pi
  • calculate sin(b) using the taylor series function.
  • calculate sin(b) using matlab built in method.
  • plot the sin(b) obtained from above two methods.

Flow chart for Taylor series function:
start intialize i = 1 taylor_sum = 0 false if i<=1000 true calculate the i th term of taylor series add the i th term to tayl

Flow chart for program:

start b = -pi to pi sin_taylor = TaylorSeries(b) sin_matlab = sin(b) plot(b, sin_taylor) plot(b, sin_matlab) stop

Program with output:

b = -pi:0.01:pi;

sin_taylor = [];

for i = -pi:0.01:pi

st = taylorSeries(i);

sin_taylor = [sin_taylor st];

end

plot(b, sin_taylor)

hold on;

y = sin(b);

plot(b, y)

legend("Taylor Series sin", "Matlab sin()")

xlabel("b")

ylabel("sin(b)")

function sin_taylor = taylorSeries(x)

sin_taylor = 0.0;

for i = 1:10

sin_taylor = sin_taylor +((-1)^(i-1))*((x^(2*i-1))/(factorial(2*i-1)));

end

end

Output:

CE 1 0.8 Taylor Series sin Matlab sin() 0.6 0.4 0.2 sin(b) 0 -0.2 -0.4 -0.6 -0.8 -1 -4 -3 - 1 1 2 3 N 0 b

  • The sine values from taylor series and matlab function certainly overlaps each other, that's why we see a single curve of mixed color\

That concludes our solution, if you need more information, please reach out to me in comments.

Add a comment
Know the answer?
Add Answer to:
create an editor in matlab program that prints in a single graph the sin(b) function for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT