Question

The natural logarithm of a number x>(1)/(2) can be approximated by the series ln(x)~~sum_(n=1)^N ((x-1)^(n))/(nx^(n)) Write a Matlab function myLog that takes as input x and the number N and outputs as y the estimate of ln(x) using Eq. (1) and the corresponding true relative error tre. For the true value of ln(x) use Matlab's build-in function log(x) here and in the following problems. Code the function such that it can handle both scalar and column vector inputs for x, resulting in scalar, respective column vector outputs for y and tre. If any of the values for x are x<=(1)/(2), i.e., Eq. 1 is not applicable, call Matlab's error function and output an appropriate error message. Do not print any results to screen or do any plotting within the function. The natural logarithm of a number >1/2 can be approximated by the series (1) n.xn n=1 Write a Matlab function myLog that takes as input x and the number N and outputs as y the estimate of In using Eq.(1 and the corresponding true relative error t re.For the true value of ln(use Matlab's build-in function logx here and in the following problems. Code the function such that it can handle both scalar and column vector inputs for x,resulting in scalar respective column vector outputs for y and tre.If any.of the values for x are < l/2,i.e.Eq.1 is not applicable.call Matlab's error function and output an appropriate error message.Do not print any results to screen or do any plotting within the function.

          The natural logarithm of a number x>(1)/(2) can be approximated by the series
ln(x)~~sum_(n=1)^N ((x-1)^(n))/(nx^(n))
Write a Matlab function myLog that takes as input x and the number N and outputs as y the estimate of ln(x) using Eq. (1) and the corresponding true relative error tre. For the true value of ln(x) use Matlab's build-in function log(x) here and in the following problems. Code the function such that it can handle both scalar and column vector inputs for x, resulting in scalar, respective column vector outputs for y and tre. If any of the values for x are x<=(1)/(2), i.e., Eq. 1 is not applicable, call Matlab's error function and output an appropriate error message. Do not print any results to screen or do any plotting within the function.
The natural logarithm of a number >1/2 can be approximated by the series
(1)
n.xn n=1
Write a Matlab function myLog that takes as input x and the number N and outputs as y the estimate of In using Eq.(1 and the corresponding true relative error t re.For the true value of ln(use Matlab's build-in function logx here and in the following problems. Code the function such that it can handle both scalar and column vector inputs for x,resulting in scalar respective column vector outputs for y and tre.If any.of the values for x are  < l/2,i.e.Eq.1 is not applicable.call Matlab's error function and output an appropriate error message.Do not print any results to screen or do any plotting within the function.
        
Show more…
the natural logarithm of a number x12 can be approximated by the series lnxsumn1n x 1nnxn write a matlab function mylog that takes as input x and the number n and outputs as y the estimate  30553

Added by Rosario M.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
The natural logarithm of a number x>(1)/(2) can be approximated by the series ln(x)~~sum_(n=1)^N ((x-1)^(n))/(nx^(n)) Write a Matlab function myLog that takes as input x and the number N and outputs as y the estimate of ln(x) using Eq. (1) and the corresponding true relative error tre. For the true value of ln(x) use Matlab's build-in function log(x) here and in the following problems. Code the function such that it can handle both scalar and column vector inputs for x, resulting in scalar, respective column vector outputs for y and tre. If any of the values for x are x<=(1)/(2), i.e., Eq. 1 is not applicable, call Matlab's error function and output an appropriate error message. Do not print any results to screen or do any plotting within the function. The natural logarithm of a number >1/2 can be approximated by the series (1) n.xn n=1 Write a Matlab function myLog that takes as input x and the number N and outputs as y the estimate of In using Eq.(1 and the corresponding true relative error t re.For the true value of ln(use Matlab's build-in function logx here and in the following problems. Code the function such that it can handle both scalar and column vector inputs for x,resulting in scalar respective column vector outputs for y and tre.If any.of the values for x are < l/2,i.e.Eq.1 is not applicable.call Matlab's error function and output an appropriate error message.Do not print any results to screen or do any plotting within the function.
Close icon
Play audio
Feedback
Powered by NumerAI
Jennifer Stoner Danielle Fairburn
Kathleen Carty verified

Sri K and 73 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
25-evaluating-your-own-numerical-method-in-matlab-6-pts-recall-leibniz-infinite-series-exactly-represents-7-4-7-78-2n-let-approximate-i-in-matlab-by-summing-_-just-the-frst-na-terms-of-this-13135

Evaluating your OWN "Numerical Method" in MATLAB Recall Leibniz's infinite series exactly represents ̀ as ... ̀ = 4 - 4/3 + 4/5 - 4/7 + ... = ∑ 4(-1)^(n+1) / (2n-1) Let's approximate ̀ in MATLAB by summing just the first Nmax terms of this series, and see how the error changes as we include more terms (increase the value of Nmax). (a) Create a function in MATLAB, saved as piApprox.m, which evaluates the Leibniz series up through Nmax terms. That is, evaluate the finite series Approx = ∑ 4(-1)^(n+1) / (2n-1) Start the function with the following first line exactly (so the input is Nmax, output is Approx): function Approx = piApprox(Nmax) (b) Create a script in MATLAB, called HW2_pi.m, which calls the function above to evaluate Approx for all the following nine values of Nmax (each power of 10 from 10^0 to 10^8): NmaxVector = [1 10 100 1000 ... 10^8] Then add more commands in your script to complete the following: (i) Calculate the error between the exact value of ̀ (for this, use the built-in variable pi in MATLAB which is good to about 16 decimals), and the finite series approximations for ̀ above. (ii) Plot the base-10 log of the absolute value of the error on the y-axis against the base-10 log of the number of terms used (Nmax) on the x-axis, using both a straight line and circles. Label the x- and y-axis and title the plot appropriately. Save this plot as piPlot.pdf. • Remember MATLAB needs log10 for base-10 log (just "plain" log in MATLAB uses the "natural log") • In case you're wondering, we are using the absolute value of error here because you can't take the log of a negative number. Take a look at your plot — you should see that the error goes down (i.e. log10(|error|) gets more negative) as Nmax gets larger. Doesn't that make sense? I hope so! (c) Based just on the results of your plot, estimate how many terms (Nmax) it would take to get the error in the approximation of ̀ down to 10^-10 (i.e. accurate down to the 10^th decimal)? Write this out in sentence form in the COMMENT SECTION of your homework submission in Carmen (i.e. "To get the error down to 10^(-10) I estimate you need Nmax = ...")

Sri K.

use-matlab-to-make-a-table-of-the-error-of-the-three-point-centered-difference-formula-for-f-0-where-f-x-sinx-cos-x-with-h-1011012-as-in-the-table-in-section-512-draw-a-plot-of-the-results-d-60688

Use MATLAB to make a table of the error of the three-point centered-difference formula for f(0), where f(x) = sin(x) - cos(x), with h = 10^(-1), ..., 10^(-12), as in the table in Section 5.1.2. Draw a plot of the results. Does the minimum error correspond to the theoretical expectation? Formula: Three-point centered-difference formula for second derivative: f(x + h) - 2f(x) + f(x - h) / h^2 = f''(x) + O(h^2) 5.1.2 Rounding error: So far, all of this chapter's formulas break the rule from Chapter 0 that advises against subtracting nearly equal numbers. This is the greatest difficulty with numerical differentiation, but it is essentially impossible to avoid. To understand the problem better, consider the following example: EXAMPLE 5.3: Approximate the derivative of f(x) = e^x at x = 0. The two-point formula (5.4) gives e^(x+h) - e^x / h, and the three-point formula (5.7) yields e^(x+h) - e^(x-h) / 2h. The results of these formulas for x = 0 and a wide range of increment size h, along with errors compared with the correct value e^0 = 1, are given in the following table: Formula (5.9) Error Formula (5.10) Error 10^(-1) 1.05170918075648 0.05170918075648 1.00166750019844 0.00166750019844 10^(-2) 1.00501670841679 -0.00501670841679 1.00001666674999 -0.00001666674999 10^(-3) 1.00050016670838 -0.00050016670838 1.00000016666668 -0.00001666666668 10^(-4) 1.00005000166714 -0.00005000166714 1.00000000166689 -0.00000000166689 10^(-5) 1.00000500000696 -0.00000500000696 1.00000000001210 -0.00000000001210 10^(-6) 1.00000049996218 -0.00000049996218 0.99999999997324 0.00000000002676 10^(-7) 1.00000004943368 -0.00000004943368 0.99999999947364 0.00000000052636 10^(-8) 0.99999999392253 0.00000000607747 0.99999999392253 0.00000000607747 10^(-9) 1.00000008274037 -0.00000008274037 1.00000002722922 -0.00000002722922

Carson M.

the-poisson-distribution-and-binomial-distribution-converges-when-the-number-of-trials-is-large-and-the-probability-of-success-is-small-write-the-matlab-function-poissonpmfm-without-using-ma-87984

The Poisson distribution and binomial distribution converge when the number of trials is large and the probability of success is small. Write the MATLAB function poissonPMF.m (without using MATLAB's built-in statistics functions). Your function should take n, lambda, and a vector x (representing a vector of integers [0, 1, 2, ..., n] where each value in this vector is evaluated) as input parameters and return a vector representing the pmf values for each value in x. Using your binomialPMF.m, comment on the following observations for both binomial and Poisson distributions using the following parameters: - n=10, p=0.5 - n=20, p=0.25 - n=30, p=0.1 - n=50, p=0.01 - n=100, p=0.001 function pmf = binomial_pmf(x, n, p) % BINOMIAL_PMF: Binomial probability mass function. % pmf = BINOMIAL_PMF(x, n, p) returns the binomial probability mass % function with parameters n and p at the values in x. % (typically x is a vector of integers 0, 1, 2, ..., n) % % The size of "pmf" is a vector of the same length as x. % Error-checking if nargin < 3 error('binomial_pmf: Too few inputs', 'Requires 3 input arguments'); end % Initialize the pmf vector to zero pmf = zeros(length(x), 1); for i = 1:length(x) k = x(i); % select the ith value in the x vector %.... you now compute log p(k) as follows - we will compute the value % of pk in the log domain to avoid computing very small or very large % numbers that would cause underflow or overflow. %....you will need to fill in the rest of details below...... %.... first use nchoosek.m to compute the binomial coefficient "n choose k" %.... and take the log of this to begin computing log p(k) %... use "help nchoosek" at the MATLAB prompt to find out what it does logpk = log(nchoosek(n, k)); %....now compute the rest of the expression for log p(k) % where we need to compute log(p^k) and log[(1-p)^(n-k)] logpk = logpk + log(p^k) + log((1 - p)^(n - k)); % finally convert back to get p(k) by computing exp(logpk) pmf(i) = exp(logpk); end

Thuc N.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,007 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,867 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,786 solutions

*

Transcript

-
00:01 Hello everyone in this question we have to find the subspace a comma b of r is homomorphic with 0 .1 so let's see the solution for it.
00:12 First of all we have to find a homomorphism.
00:15 So a function of a comma v goes to 0 .1 and g which is a function of a comma v it goes to 0 .1.
00:28 We have to find subspace a comma b of r and same we have to find for a comma b also is homomorphic with 0 .1 here.
00:39 So let a is less than x and x is less than b here and y is what greater than 0 which will be equal to f of x which is less than 1 here and the map if we see for the map f is a function of a comma v which goes to 0 .1 here so why which is equal to f of x of x which will be equal to x minus a divided by b minus a here.
01:17 This map is one to one continuous as and has inverse here...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Join the community

18,000,000+

Students on Numerade


Trusted by students at 8,000+ universities

Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever