开发者

Maple: How to give values to assumptions for plotting?

So I have a simple example of what I want to do:

r开发者_如何学Goestart;
assume(can, real);
f := {g = x+can*x*y, t = x+x*y};
assign(f[1]); g;
can := 2;
plot3d(g, x = 0 .. 100, y = 0 .. 100);

Maple: How to give values to assumptions for plotting?

while this works:

restart;
f := {g = x+can*x*y, t = x+x*y};
assign(f[1]);
can := 2;
plot3d(g, x = 0 .. 100, y = 0 .. 100);

Maple: How to give values to assumptions for plotting?

But that assumptions are really important for my real life case (for some optimisations with complex numbers) so I cant just leve can not preassumed.

Why it plots nothuing for me and how to make it plot?


The expression (or procedure) to be plotted must evaluate to a numeric, floating-point quantity. And so, for your expression g, the name can must have a specific numeric value at the time any plot of g is generated.

But you can produce a sequence of 3D plots, for various values of can, and display them. You can display them all at once, overlaid. Or you can display them in an animated sequence. And you can color or shade them each differently, to give a visual cue that can is changing and different for each.

restart;

f := {g = x+can*x*y, t = x+x*y};

eval(g,f);

N:=50:
Pseq := seq(
  plot3d(eval(g,f),
         x=0..10,y=0..10,
         color=RGB(0.5,0.5,can/(2*N)),
         transparency=0.5*(can/(N+1))),
            can=1 .. N):

plots:-display(Pseq, axes=box);

plots:-display([Pseq],insequence=true,axes=box);

By the way, you don't have to assign to g just for the sake of using the equation for g that appears inside f. Doing that assignment (using assign, say, like you did) makes it more awkward for you subsequently to create other equations in terms of the pure name g unless you first unassign the name g. Some people find it easier to not make the assignment to g at all for such tasks, and to simply use eval as I've done above.

Now on to your deeper problem. You create an expression containing a local, assumed name. and then later on you want to use the same expression but with the global, unassumed version of that name. You can create the expression, with it containing the global, unassumed name instead of the local, assumed name, buy performing a substitution.

restart;
assume(can, real);
f := {g = x+can*x*y, t = x+x*y};

            {g = x + can~ x y, t = x + x y}

assign(f[1]);
g;

                      x + can~ x y

can := 2:

g;

                      x + can~ x y

# This fails, because g contains the local name can~
plot3d(g, x=0..100, y=0..100);

# A procedure to make the desired substitution
revert:=proc(nm::name)
local len, snm;
  snm:=convert(nm,string);
  len:=length(snm);
  if snm[-1]="~" then
    return parse(snm[1..-2]);
  else return parse(nm);
  end if;
end proc:

# This is the version of the expression, but with global name can
subsindets(g,`local`,revert);

                      x + can x y

# This should work
plot3d(subsindets(g,`local`,revert),
       x=0..100,y=0..100);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜