Search code examples
maxima

Can't draw electric field dipole


I am trying to simulate electric field dipole by using Maxima. Here is the code:

P : 1$
eps0 : 8.854$
Ex : 3*P*y*x/(4*π*eps0*(x^2 + y^2)^2.5)$
Ey : P*(3*y^2/(x^2 + y^2) + 1)/(x^2 + y^2)^1.5/(4*π*eps0)$
ew : sqrt(Ex^2 + Ey^2)$

contour_plot (ew,[x, -4, 4], [y, -4,4]);

But i am getting only straight lines.
What can be wrong, because similar code in Wolfram Mathematica works fine.


Solution

  • contour_plot is not as smart as the corresponding function in Mathematica. You can help it a bit.

    P : 1$
    eps0 : 8.854$
    Ex : 3*P*y*x/(4*%pi*eps0*(x^2 + y^2)^2.5)$
    Ey : P*(3*y^2/(x^2 + y^2) + 1)/(x^2 + y^2)^1.5/(4*%pi*eps0)$
    ew : sqrt(Ex^2 + Ey^2)$
    
    BIG: subst([x=1/4, y=1/4], ew)$
    cap_log(e, c):= if e > c then log(c) else log(e)$
    
    set_plot_option ([gnuplot_preamble, "set cntrparam levels 8"])$
    contour_plot ('cap_log(ew, BIG), [x, -4, 4], [y, -4, 4])$