Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Error problem

  1. May 2, 2010 #1
    I want to compute x within 0.1% relative error with Simpson method, these are my m-files. Which command i should add for this?

    function simps(a, b, n)
    %simps(a, b, n) approximates the integral of a function f(x) in the
    %interval [a;b] by the composite simpson rule
    %n is the number of subintervals

    h = (b-a)/n;

    sum_even = 0;

    for i = 1:n/2-1
    x(i) = a + 2*i*h;
    sum_even = sum_even + f(x(i));

    sum_odd = 0;

    for i = 1:n/2
    x(i) = a + (2*i-1)*h;
    sum_odd = sum_odd + f(x(i));

    integral = h*(f(a)+ 2*sum_even + 4*sum_odd +f(b))/3

    function y = f(x)
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - Error problem Date
Mathematica Errors when plotting but not when evaluating Mar 13, 2018
Excel Error Bars Nov 26, 2017
Using Maxima to plot error in Fourier series Nov 5, 2017
Matlab 2D plotting error help please Aug 28, 2016
MATLAB Error message problem May 30, 2011