Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

I wanted to integrate this function

I've tried the following but as you can see, it does not work.

```
(%i1) f(x) := if x>0 then sin(x) else 0$
(%i2) integrate(f(x),x,-%pi,%pi);
%pi
/
[
(%o2) I (if x > 0 then sin(x) else 0) dx
]
/
- %pi
```

What to do?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

Hi Agnishom;

I have no idea how to do this, but you could do the following:

`romberg(if x>0 then sin(x) else 0, x, -%pi, %pi);`

or perhaps

`quad_qags(if x>0 then sin(x) else 0, x, -%pi, %pi);`

They integrate the function numerically rather than analytically.

Or better yet, try Mathematica

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Why not just integrate sin(x) between 0 and π?

In geogebra it is done like this.

f(x)=If[x<0,0,1]

g(x)=If[x>=0,1,0]

Integral[f,1,2]

Integral[g,1,2]

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **A number by itself is useful, but it is far more useful to know how accurate or certain that number is.**

Offline

I tried that but still there are too many 'too many context' errors, also the integration does not work fine.

So, you are an expert geogebra user now.

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Example in Sage:

```
f1(x) = 1
f2(x) = 1-x
f3(x) = x^2-5
f = Piecewise([[(-oo,0),0],[(0,1),f1],[(1,2),f2],[(2,3),f3],[(3,oo),0]])
integrate(f,x,-oo,oo)
```

= 11/6

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

Sage is very powerful. But it is too huge a download.

What does oo mean?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Infinity probably.

I can handle geogebra. You will have to find a way to have M around all the time.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **A number by itself is useful, but it is far more useful to know how accurate or certain that number is.**

Offline

You will have to find a way to have M around all the time.

Why?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Hmmm, how can you follow what I am posting if we speak different languages?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **A number by itself is useful, but it is far more useful to know how accurate or certain that number is.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Sage is very powerful. But it is too huge a download.

That's true, around 4 GB after decompressing, takes more space than some linux distro installations!

Anyway, you may be having a friend with unlimited data usage plan to download it for you.

What does oo mean?

it's infinity. You may use the full form also

`integrate(f,x,-infinity,infinity)`

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 16,015

bobbym wrote:

Hmmm, how can you follow what I am posting if we speak different languages?

We already found that that can be quite a problem.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

You will have to find a way to have M around all the time.

Install a native linux in a phone (Ubuntu touch is on its way), and use ARM version of the software! Then can be used with a remote login.

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

gAr wrote:

You will have to find a way to have M around all the time.

Install a native linux in a phone (Ubuntu touch is on its way), and use ARM version of the software! Then can be used with a remote login.

I do not have a smartphone

ARM version of which software? There is a android version of Maxima. Also, why Ubuntu Touch? Ain't Android a linux already?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Hi Agnishom;

What you could try is using your Windows machine with your CAS when you are on MIF. If you are worried about security then do not go anywhere else while on Windows. When you are finished here then you can reboot and start Linux.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

I do not have a smartphone

Me neither! Just telling.

ARM version of which software?

Anything that you wanted to use. Did you know that you can get free Mathematica with Raspberry Pi?

Also, why Ubuntu Touch? Ain't Android a linux already?

Android is linux with Java bloat, owned by morons in or*cle! And to use its applications, you need to trade your identity with g**gle. Now they have billions of identities to give to the governments.

You can use ubuntu touch just like the desktop version. You can even have the terminal applications running, and all the repository is available to the phone also. Though I'm not sure whether they have all the packages for ARM architecture also.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

Hi bobbym;

Do not worry. I'll be able to run any M command you give within 12 hours whenever needed. And since the forum is not an instant chat cafe, this delay is okay.

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

That is very long when we are working on something together. But if that is all you have then it will have to be enough.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

OK, I will be near my M when we are working on something.

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Do you know that a Fourier series can also help sum another series?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

No, and I do not see how a Fourier series is useful.

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

The graphs should be showing you that they are useful to approximate other functions.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

I beg your pardon?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Agnishom wrote:

No, and I do not see how a Fourier series is useful.

bobbym wrote:

The graphs should be showing you that they are useful to approximate other functions.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline

Why should that be useful?

May I ask you a different question about M usage?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 104,747

Because after polynomials, trig terms are the next easiest to compute. So it just natural that we would want to approximate difficult functions with bunches of easier ones.

May I ask you a different question about M usage?

Hmm, what question? And maybe you should make a new thread for it.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**

Offline