Question: 1.Please write a function that computes the harmonic series. In mathematics, the harmonic series is the divergent infinite series: https://en.wikipedia.org/wiki/Harmonic_series_%28mathematics%29 The first line of the
1.Please write a function that computes the harmonic series.
In mathematics, the harmonic series is the divergent infinite series:
https://en.wikipedia.org/wiki/Harmonic_series_%28mathematics%29
The first line of the file should be
"function numbers = harm( n )"
The file should be called harm.m. Running the function should return a vector with the first n harmonic numbers. ex: harm(4) should return "ans = 1 .5 .333333 .25". You might need to use a for loop for this one.
2. Please write a function that computes the dot product (https://en.wikipedia.org/wiki/Dot_product) between two vectors. The first line of the file should be
"function product = dotproduct(x,y)"
The file should be called dotproduct.m. Running the function should return a scalar that is the dot product between the two vectors x and y. ex: dotproduct([1 2 3 4], [5 6 7 8]) should return "ans = 70".
3. Please write a function that estimates the inner product of two functions. The first line of the file should be
"function product = innerproduct(f,g,x)"
f and g should be functions that have one parameter (such as cos, sin) and x should be a vector. The file should be called innerproduct.m. Running the function should return a scalar that is the dot product between f(x) and g(x). ex: innerproduct('cos', 'sin', [1 2 3 4]) should return "ans = 0.4312".
1M8 BIH NIH H NAI H CTI H
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
