Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.9K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Calculation of an integral with a variable lower limit using the trapezoidal method

Posted 1 year ago
POSTED BY: Yaroslav B
4 Replies
Posted 1 year ago

I'm sorry, but I've been poking through this for like an hour and I have no idea what your code is doing. Can you minimize this example? Or can you at least pinpoint where you're actually applying the "trapezoidal method" for an integral and what variable is your "lower limit"?

Are the other plots correct? If not, is it the same problem?

Your final plot is based on spisoksigmaPSKRR[[1]][[iendRR]] and spisoksigmaPSKRP[[1]][[iendRP]] where iendRR and iendRR are both 41. I'd recommend you pull out that slice of data, figure out by what factor it deviates from the expected, and then see where in your code that factor might have been changed/misapplied/whatever.

Alternatively, maybe just explain what these functions are and let us help you start from the beginning. That's probably easier than reverse-engineering this wall of code.

FWIW, this site isn't intended as a place for free debugging services. I probably won't spend any more time on this if you can't isolate the problem to a specific programming question. Maybe someone else has the time to spend on this.

POSTED BY: Eric Rimbey
Posted 1 year ago
POSTED BY: Eric Rimbey
Posted 1 year ago
POSTED BY: Eric Rimbey

...an integral with a variable lower limit...

Are you trying to plot $y=f(b) - \int_x^b f(t)\;dt$ for the some function $f$ over some interval $a \le x \le b$? Or maybe it's plus, $y=f(b) + \int_x^b f(t)\;dt$? The initial value $f(b)$ seems odd, but it follows from the graphs intersecting at $x=b=\pi$, assuming one curve is the integral and the other is the integrand.

  1. I wonder what you're trying to plot? Can you give a formula such as I gave? Which curve is the integral and which is the integrand?

  2. I doubt the first graph is the correct one, if one of the curves is the integral of the other. There should be a vertical shift, unless by random coincidence the shift is zero. If the graphs are phase-shifted sine curves, then the first graph is wrong. The following gives the vertical shift for $y=f(a) + \int_a^x f(t)\;dt$ where $f$ is a phase-shifted sine:

    Integrate[
      a*Sin[-Pi + b] + Integrate[a*Sin[t + b], {t, -Pi, x}],
      {x, -Pi, Pi}]/(2 Pi)
    (*  -a (Cos[b] + Sin[b])  *)
    

So the vertical shift is zero exactly when $\tan b = -1$, which is not the case in the first graph (assuming they are sines).

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard