majd

5 Reputation

3 Badges

14 years, 50 days

MaplePrimes Activity


These are answers submitted by majd

The actual code is very long (the integrand is actually few pages of code, but that was not the problem at all), but i did find out how to make it work, and most importantly, the things that fieldplot cannot do.

lets say we have two functions F(x,y,r,phi) and G(x,y,r,phi). the vector field that I wanted to plot was

V(x,y)=[Vx(x,y), Vy(x,y)]

where

Vx=(x,y)->evalf(Int(F(x,y,r,phi),[phi=0..2*Pi,r=0..infinity]))

and

Vx=(x,y)->evalf(Int(G(x,y,r,phi),[phi=0..2*Pi,r=0..infinity]))

 

here I had to use evalf and Int() instead of just int() because the functions F and G can only be integrated numerically. Maple could evaluate Vx and Vy at any specific value of x and y easily. Howver, when i tried to use fieldplot, it gave me the error message i mentioned above "Error, (in plots/fieldplot) no non-zero vectors found".

I had to change two things to make it work. First, and most importantly, fieldplot needs to see the double integral written explicitly (I did find that out by trial and error, maybe it does not use the regular evalf). In other words i had to rewrite Vx and Vy in the following way.

Vx=(x,y)->evalf(Int(Int(F(x,y,r,phi),phi=0..2*Pi),r=0..infinity))

However, this comes with a cost. This way I cannot use specific multiple ingegration options like MonteCarlo (sometime this option makes evaluating the double integraion faster by an order of magnitute if not more), so this is bad, but at least fieldplot workds now, but can somebody find a way around it (allowing me to use MonteCarlo option with fieldplot)

Second, i even had to type in F and G explicity in the defintion of Vx and Vy. To clarify, F and G were derived from many operations applied to previous functions. fieldplot did not like that, so i had to explicity evaluate F(x,y,r,phi) and copy that long term, and paste it explicity in the definition of Vx in place of F.

Long story short, now it works, but there should be a better way, and why doesn't fieldplot accept functions that evalf has no problems with?

Page 1 of 1