Question: How can plot density and contour of a function?

i want to plot density i try to use code of [interactive] but didn't give me density 

restart

_local(gamma)

Warning, A new binding for the name `gamma` has been created. The global instance of this name is still accessible using the :- prefix, :-`gamma`.  See ?protect for details.

 

NULL

sol3 := (2*(2*k[2]^2*p[2]^2/p[1]^2+2*k[2]^2))/((-x*k[2]*p[2]/p[1]+y*p[1])^2+(x*k[2]+y*p[2])^2+a[0])-2*(-(2*(-x*k[2]*p[2]/p[1]+y*p[1]))*k[2]*p[2]/p[1]+(2*(x*k[2]+y*p[2]))*k[2])^2/((-x*k[2]*p[2]/p[1]+y*p[1])^2+(x*k[2]+y*p[2])^2+a[0])^2

NULL

lprint(indets(sol3, name))

{x, y, a[0], k[2], p[1], p[2]}

 

P :=   [  a[0]=1.2, k[2]=0.8, p[1]=-0.8, p[2]=0.4]

[a[0] = 1.2, k[2] = .8, p[1] = -.8, p[2] = .4]

(1)

latex(P)

[a_{0} =  1.2, k_{2} =  0.8, p_{1} = - 0.8, p_{2} =  0.4]

 

NULL

Assume some functional form for U(xi)

 

insert numerical values

solnum :=subs(P, sol3);

3.200000000/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)-5.120000000*x^2/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)^2

(2)

CodeGeneration['Matlab']('3.200000000/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)-5.120000000*x^2/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)^2')

cg0 = 0.3200000000e1 / ((0.4000000000e0 * x - 0.8e0 * y) ^ 2 + (0.8e0 * x + 0.4e0 * y) ^ 2 + 0.12e1) - 0.5120000000e1 * x ^ 2 / ((0.4000000000e0 * x - 0.8e0 * y) ^ 2 + (0.8e0 * x + 0.4e0 * y) ^ 2 + 0.12e1) ^ 2;

 

 

P := Array(1 .. 3); P[1] := plot3d(map(Re, solnum), x = -20 .. 20, y = -5 .. 5, title = Re); P[2] := plot3d(map(Im, solnum), x = -20 .. 20, y = -5 .. 5, title = Im); P[3] := plot3d(map(abs, solnum), x = -20 .. 20, y = -5 .. 5, title = abs); plots:-display(P)

 

 

 

 

 

 

``

 

 

Q := Array(1 .. 2); Q[1] := plot3d(map(density, solnum), x = -20 .. 20, y = -5 .. 5, title = den); Q[2] := plot3d(map(contour, solnum), x = -20 .. 20, y = -5 .. 5, title = contour); plots:-display(Q)

Warning, expecting only range variables [x, y] in expression density(3.200000000/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2))+density(-5.120000000*x^2/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)^2) to be plotted but found name density

 

Warning, expecting only range variables [x, y] in expression contour(3.200000000/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2))+contour(-5.120000000*x^2/((.4000000000*x-.8*y)^2+(.8*x+.4*y)^2+1.2)^2) to be plotted but found name contour

 

 

 

 

 

 

 

 

Download graph-density-countour.mw

Please Wait...