Math Is Fun Forum

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

You are not logged in.

#1 2011-07-20 09:16:35

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Help with Python!!!

I need help to Plot this function:

W = 4/3*(N*E*math.sqrt(R)*integrate(math.pow(z-d,3/2)*phi,(z,d,oo)))
with
phi=(1/(Sq*math.sqrt(2*math.pi))*exp(-((z-Sa)**2)/(2*(Sq**2))))
Sa=0.34
Sq=0.45
N = 11746.875
E = 0.04945
R = 4.4194

I need 'd' between [0 , 0.1 , 0.2 , ...... , 3.0]

I believe my problem is with the integration. I don't know how to integrate that part of W.

Thanks.

Offline

#2 2011-07-20 10:44:51

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Hi Paolamazzu;

Is this what you want for phi?

Is this the integral you are having problems with?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#3 2011-07-21 03:29:34

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

Yes. That's exactly the integral I'm having problems with!!
I will appreciate any help you can give me!

Offline

#4 2011-07-21 08:13:28

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

That integral looks very much like a hybridized Normal Distribution.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#5 2011-07-21 08:47:05

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

And how do I solve that in Python? I can not use integrate, right? I have to use another code, is that right?

Offline

#6 2011-07-21 08:53:39

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

For a test please do this in python.

Tell me what you get?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#7 2011-07-21 09:17:07

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

The only thing I got is this:
2               
⌠               
⎮      1       
⎮ ─────────── dx
⎮                  2
⎮ cos(x) + x   
⌡               
1               

It does not solve for me.

Last edited by Paolamazzu (2011-07-21 09:23:18)

Offline

#8 2011-07-21 09:26:38

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Okay that is what you should be getting for you integral too.

Please bear with me, ask him for this:

and this:


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#9 2011-07-21 09:37:04

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

That's exactly what happens with mine.
The first you asked, I got the right answer.
The second as well.
No problem at all.

Offline

#10 2011-07-21 09:39:37

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Hi;

What did you get, may I see?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#11 2011-07-21 09:41:01

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

The first one:
3
x
──
3
The second one:
     3       3
    a      b
- ── + ──
    3       3

Offline

#12 2011-07-21 09:42:41

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Very good that means the integrate command in python is doing a symbolic integration. A question, do you have a numerical integration command in python?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#13 2011-07-21 09:44:01

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

Not that I'm aware of.
I'm a begginer at Python.

Last edited by Paolamazzu (2011-07-21 09:46:42)

Offline

#14 2011-07-21 09:49:45

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Okay, hold please while I do some checking.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#15 2011-07-21 09:50:19

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

Ok, thank you a lot.

Offline

#16 2011-07-21 09:58:24

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Here is what we have so far:

This is the problem,

That integral can not be done mathematically in closed form. In simple terms we can not get rid of the integral sign.

I asked you whether you were working with a standard normal curve.

If so then there may be ways around this problem. You must numerically evaluate this integral.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#17 2011-07-21 10:09:18

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

And those can not be done by this method??

Offline

#18 2011-07-21 10:12:28

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Hi;

Not by the methods that your integrate command has.

You must numerically evaluate this integral. For that you need a command that will do that in your language. Or I can do the whole plot for you because I have the tools. If you only need this done once then that is the best solution.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#19 2011-07-21 10:17:11

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

I do need to plot, but the problem is that I need also the program to get there, so I can do other similar plots.

Offline

#20 2011-07-21 10:20:35

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Now, if that curve was related to the standard normal curve then there are tables for that integral and polynomial approximations. First I would like to know something about it so I can cut away the fat.


Also start to search your help, python must support a numeric integrate command. It has to be there, that would also solve the problem.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#21 2011-07-21 10:32:51

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

It is related to the standard normal curve..I think I found something while searching..it's called scipy...I'm gonna try it here..if I get nothing, I will return again...But thanks a lot for your help!

Offline

#22 2011-07-21 10:34:30

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

That should do it! Scipy has numeric routines, let me know how you end up!


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#23 2011-07-22 06:53:33

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

Hey bobbym!
I think I really do have problems with Python. I found that Scipy command but something is not right. I think I don´t no how to use the command. Can you please help me???

Offline

#24 2011-07-22 09:34:31

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Help with Python!!!

Hi Paolamazzu;

What is the command?


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#25 2011-07-22 12:47:18

Paolamazzu
Member
Registered: 2011-07-20
Posts: 13

Re: Help with Python!!!

Hey bobbym,
the code is scipy.integrate.quad

Last edited by Paolamazzu (2011-07-22 12:58:11)

Offline

Board footer

Powered by FluxBB