Row vector using Leibniz series

Illustration
Lewis HC - 2023-01-09T11:38:33+00:00
Question: Row vector using Leibniz series

Greetings everyone, I am trying to create a function (without using loops) called LeibnizT that generates a row vector with the first n terms of the Leibniz series, the input argument is just n. My code is attached, thanks!     function y=LeibnizT(n) y=(-1).^n/(2.*n+1) end  

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

Think about it. How does that generate a VECTOR? In what you wrote, is n a SCALAR? (Yes)

 

y=(-1).^n/(2.*n+1)
So how will that create a vector as a result?
 
What tools can you think of that generate a vector, that do not have a for loop or a while loop? Surely you can think of some tools that will return a vector? In fact, that vector needs to be of length n. Take a shot. Show us what you can think of that gets you closer to what you need. If you do, then I'll see if I can give you another nudge in the correct direction, if necessary.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!