# MTH229 integration problem question

**URL:** https://discourse.julialang.org/t/mth229-integration-problem-question/91344
**Category:** New to Julia
**Created:** [December 7, 2022, 3:44am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344 "2022-12-07T03:44:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![xArcoirisXx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xarcoirisxx/32/44877_2.png) [@xArcoirisXx](https://discourse.julialang.org/u/xArcoirisXx)
#### Post date: [December 7, 2022, 3:44am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344/1 "2022-12-07T03:44:53Z")

</div>

using MTH229  
using Plots

f(x)=x_cos((x_n\*π)/π)  
a=-π  
b=π  
T=π

f(x) = x

integrate(f(x), x,a,b)

a\_0=(1/T)\*integrate(f(x), x,a,b)

---

<div class="post-metadata">

### Author: ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)
#### Post date: [December 7, 2022, 4:59am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344/2 "2022-12-07T04:59:37Z")

</div>

Welcome to the Julia discourse!

Please read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757), the current title and formatting make it a bit difficult to tell what it is you want to know.

---

<div class="post-metadata">

### Author: ![xArcoirisXx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xarcoirisxx/32/44877_2.png) [@xArcoirisXx](https://discourse.julialang.org/u/xArcoirisXx)
#### Post date: [December 7, 2022, 5:25am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344/3 "2022-12-07T05:25:20Z")

</div>

Complicated

---

<div class="post-metadata">

### Author: ![Maucejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maucejo/32/39090_2.png) [@Maucejo](https://discourse.julialang.org/u/Maucejo)
#### Post date: [December 7, 2022, 6:38am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344/4 "2022-12-07T06:38:37Z")

</div>

It seems that you follow a course from the College of Staten Island (as suggested by ‘using MTH229’). Consequently, be aware that we are not here to help you in doing your homeworks (I don’t want to be harsh in saying that).

If your are a beginner in Julia and in programming languages in general, the Julia documentation is a good starting point. Googling is also a good way to obtain answers to basic questions. I generally use discourse in the last resort.

In conclusion, only use discourse when it is necessary.

---

<div class="post-metadata">

### Author: ![Maucejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maucejo/32/39090_2.png) [@Maucejo](https://discourse.julialang.org/u/Maucejo)
#### Post date: [December 7, 2022, 6:46am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344/5 "2022-12-07T06:46:27Z")

</div>

Regarding your problem, it seems that you want to compute the coefficients of a Fourier series.

You can look at this thread [Fourier series in Julia](https://discourse.julialang.org/t/extracting-fourier-coefficients-of-an-arbitrary-periodic-signal/51036). That being said, I doubt that it is what you are looking for.

---

<div class="post-metadata">

### Author: ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)
#### Post date: [December 7, 2022, 11:44am UTC](https://discourse.julialang.org/t/mth229-integration-problem-question/91344/6 "2022-12-07T11:44:50Z")

</div>

Thanks for helping. I’m not sure this is a question from our course, so I’ll answer it. The `MTH229` bit is a red herring, that package just reexports `SymPy`. The issue is, to get the syntax correct the poster needs:

- to use explicit multiplication in defining `f`
- to define the symbolic variables x, n: `@syms x n` will do
- call `integrate` properly: They need `(x,a,b)` to specify the variable of integration and limits of integration.
