acer

30655 Reputation

29 Badges

18 years, 353 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@MaPal93 

I mean,

  max( 0, min( 10, Z(X,Y) ) )

That makes only the range 0..10 be used for applying your shading scheme. You get to see actual green even if Z(X,Y) would produce a huge value otherwise for some X,Y in domain.

It can also fix the flashing that the GUI can have when rotating 3d plots in such situations of massive out-of-view values.

Also,

  view=[default,default,0-1e-5 .. 10+1e-5]

(or, keep original view and adjust added max/min cutoffs accordingly by small amount)

if necessary due to possibility of introduced flat artefact.

In the following example, the first surface doesn't actually show any green portion.

plot3d( 1/(100*(x-3)*(y-2)),
        x=2..3, y=1..2,
        'colorscheme'=["zgradient",["LightGray", "Gray", "Green"]],
        view = 0..10);

plot3d( max( 0, min( 10, 1/(100*(x-3)*(y-2)) ) ),
        x=2..3, y=1..2,
        'colorscheme'=["zgradient",["LightGray", "Gray", "Green"]]);

@C_R You can also write an extension to convert, which pulls the argument (arg) out front of a usual polar cal, if that is what you'd prefer.

With a polar call it can be further used, as usual.

Here's that convert-extension idea, and then using it alongside the print-extension from my Answer.

Also, this makes the "e" appear in upright roman, like the usual `exp` pretty-printing. (Other names pretty-print in italics.)

This "e" also pretty-prints in purple, as a visual cue, which I personally like since the underneath it's a `polar` call. Remove if you'd prefer.

restart;

`convert/Polar`:=proc(ee)
   abs(ee)*polar(1,argument(ee));
end proc:

 

res := convert( (6-6*I)/sqrt(2), Polar );

6*polar(1, -(1/4)*Pi)

1/2 * res; # it really is pulled out front

3*polar(1, -(1/4)*Pi)

`print/polar`:=proc(a,b)
  InertForm:-Display(a* '`#mn("e",mathcolor="purple");`'^(b*I),
                     ':-inert'=false);
end proc:

 

res;

6*polar(1, -(1/4)*Pi)

1/2 * res;

3*polar(1, -(1/4)*Pi)

convert( -1, polar );

polar(1, Pi)

eval(%); # no-op, as wanted

polar(1, Pi)

evalc(%);

-1


Download convertPolar.mw

You can also add your content-menu items, you know. Do you want one for converting a complex number to such a form?

One could also use the inert representation from my Answer to construct a custom print-extension for polar.

In the following worksheet the returns are all still just polar(...) calls, underneath, and evalc et. al. work on them as usual. They just happen to display in 2D Ouput as the OP has asked.

restart;

 

`print/polar`:=proc(a,b)
  InertForm:-Display(a*%exp(b*I),':-inert'=false);
end proc:

 

convert( -1, polar );

polar(1, Pi)

convert( 1-I, polar );

polar(2^(1/2), -(1/4)*Pi)

convert( 1.0-I, polar );

polar(1.414213562, -.7853981634)


Download printslashpolar.mw

Personally I would never do this for usual Maple work. It's be unnecessarily confusing, because it's not WYSIWYG. There is no visual cue that the typeset output is not as it appears. Maybe if it were in purple...

@C_R No, it's not "automatic simplification" in the sense of the Maple manuals, that'd get in your way here and would undo the direct attempt. It's just usual evaluation.

Enter exp(I*Pi) and hit return and the evaluated result is -1.

So you can avoid that evaluation by using some kind of inert representation.

1) 'exp(I*Pi)' with single right-ticks in only good ephemerally. Any subsequent full evaluation undoes it. Assigning to a name foo and only passing it around as eval(foo,1) is quite awkward. (Btw, this shows that automatic simplication is not the problem.)
2) Some hack like exp(``(I*Pi)) is often ugly. Extra bracketing as output, extra op calls to manipulate, etc. ugh.
3) This is the kind of thing and inert operations (beginning with %) are designed for; a useful way to prevent evaluation while still being able to programmatically manipulate expressions in some usual ways. If you want you could also construct it (in 1D) as %exp(I %* Pi) .

Of course you could also start off with exp(i*Pi) and then eval(..,i=I) when you wanted. Seems clunkier to me. Or something weird with, say, i:=I: followed by local I: then eval the other way. Also clunkier, IMO.

You could easily write an app in embedded components, or just nifty commands, to demonstrate all this to students. But, then, you could easily write apps to do an untold number of different things.

@JAMET Please stop creating duplicate Question threads for this. They get flagged as such and then deleted.

You should explain what your program is supposed to accomplish, in proper detail.

If you only put one long sentence in your Reply's title then that gets elided by this site, and we can't see it all.

Please write a short paragraph in the body of a Reply, and explain what you are trying to accomplish.

If you are trying to get a parametric equation for the line then you could usefully start by explaining where the parameter(s) comes from.

Does it come from the arbitrarily chose point?  Or is the point fixed and the parameter(s) come from the ellipse (which is varying)?

It's not very useful to post only a block of code and expect the code attempt itself to be sel-explanatory.

@nm Your having difficulties with some programming approach, in and of itself, doesn't make the approach an illness.

I changed the tags on this Question to things like assuming and precedence (prior to any Replies or Answers appearing), because that's where your difficulties lie here (ie. not with map per se).

Without proper bracketing, your attempt

   map(X->odetest(X,ode) assuming x>0,[sol])

is not splitting up arguments as you expect.

IMO you should go with choices that you already understand and have no difficulty with, such as,

1) use map with this functional form of calling sequence, and with simple infix syntax for assuming,

    map(odetest,[sol],ode) assuming x>0

or

2) go for the robust and clear separation of `assuming` arguments by using this kind of prefix operator syntax,

   `assuming`([map(odetest,[sol],ode)],[x>0])


If you didn't anticipate or figure out on your own any precedence issues (relative binding strength of assuming, etc) on your own then why go for any bracketed quick-fix alternative solution? The prefix-form call of `assuming` is programatically flexible, clear, robust, and bypasses this given issue (which may otherwise be more likely to trip you again later...).

@janhardo Your followup example's syntax for calling plot3d is not valid.

You may have intended the effect of,

   view=[x_range, y_range, z_range]

which you could use instead of your,

   x = x_range,
   y = y_range,
   z = z_range

@Khair Muhammad Saraz You still haven't provided any worksheet. I doubt it would help, though. It's your project work, not mine.

Yes, I alluded to this aspect of the axes tickmarks before, but I guess you didn't notice: The listcontplot command doesn't provide a mechanism for using custom axes tickmarks or scale. It just uses the dimensions of the Matrix/listlist for tickmarks.

That's why (when I alluded to this before) I also(!) referenced interpolating alternatives and provided links for that. With an interpolating function one can just use contourplot and get tickmarks that match the ranges.

Sorry, I cannot answer any more of your queries. I suggest that you learn how to use Maple enough to do these things for yourself. You could read and understand and use/adapt material in the links provided, for this.

@Aung I did it in stages to try and make it more understandable.

Sure, you can wrap together some of the steps, and bypass inert calls, to make it a bit shorter.

But there is no dedicated command for turning an integral of a sum into a sum of an integral. That's what that particular subsindets call does.

restart:

with(IntegrationTools):

eq1:=int(1-(sum(p[i]*(1-exp(-((t-xi)/tau[i]))),i=1..n)),xi=0..t);

int(1-(sum(p[i]*(1-exp(-(t-xi)/tau[i])), i = 1 .. n)), xi = 0 .. t)

temp := subsindets(Expand(eq1),specfunc({specfunc(sum),name=range},int),
                   u->sum(int(op([1,1],u),op(2,u)),op([1,2],u)));

t-(sum(p[i], i = 1 .. n))*t+sum(-tau[i]*p[i]*exp(-t/tau[i])+tau[i]*p[i], i = 1 .. n)

combine(temp);

sum(-tau[i]*p[i]*exp(-t/tau[i])+tau[i]*p[i]-t*p[i], i = 1 .. n)+t


Download 1111_acc.mw

@Dkunb Your procedure proj_wigner is neither assigning nor returning the result of,

   [seq([seq(subs(m=i,n=j,wp),j=1..d2)],i=1..d2)];

to anything. It worked, but no more use was made of it.

You could try, instead,

   w :=  [seq([seq(subs(m=i,n=j,wp),j=1..d2)],i=1..d2)];

and then return w at the end, to see it working.

Also, I recommend using eval instead of subs, unless you have some good reason not to. I.e.,

   w :=  [seq([seq(eval(wp,[m=i,n=j]),j=1..d2)],i=1..d2)];

@Dkunb My point is that the concept of "simpler" here is ambiguous. There's short-and-ugly and larger-with-great-structure-insight-and-symmetry, and a world in between.

Do you want as much combining of trig terms as possible (even if the result is slightly larger?)

Does you want the exp terms in trig form? If so, do you want the terms grouped by trig function or by real and imaginary parts? And so on...

@Khair Muhammad Saraz 

Please attach your worksheet.

Taking nops of a Matrix or a Vector (one of its rows or columns) does not return the number of elements. Your MM is a Matrix. The command for that is numelems, not nops. There are better ways to get the dimensions, IMO.

Perhaps you intended on of these:

listcontplot(MM[..,2..], axes=boxed);

listcontplot(MM[..,2..]^%T, axes=boxed);

listcontplot([seq([seq(MM[i,j],
                       j=2..op([1,2],MM))],
                  i=1..op([1,1],MM))], axes=boxed);

Let me know whether you'd rather do interpolation (linear, spline, cubic) instead, to get smoother curves or nicer axes tickmarks.

@MaPal93 

Regarding your attachment above that balked after 55 iterations (I think maybe it was named fsolve_does_not_work.mw):

Once INDEX gets up to about 0.55 (or 0.554...) some of the solved variables become very large (in a solution). Then you have both small and large values in the "root". In order for fsolve (or you) to establish that it really has obtained a root it performs a residual calculation. But as things get worse the required working precision (Digits) needed to do that accurately gets larger too.

Experiment indicated to me that default Digits=10 was producing bogus results already. Still indicative that solution values might be approaching a singularity. But not accurately. Raising Digits (30, 50, 100...) only brings temporary relief.

Moreover (and I know this sounds facile, but I'm being serious), it can help to pause and try to define the notion of a "root" -- in this float context. Once you have such, you can program for it.

By default the residual check (after resubstitution; forward error) looks to inbound Digits to fsolve for its scale. You can make an end-run around that by using operator-form instead of expressions, for the equations. Such black-box procedures are free to temporarily raise just their own working precision, for just each time they are invoked. This is an end-run around the catch-22 that raising Digits at the higher level -- as a means to evaluate the expressions more carefully at each iteration -- also has the effect of making the residual checks more strict. Using black-box procedures can separate the working precision for the functional evaluations (Digits now set withing the scope of the procedures) from the accuracy requirement in the residual check.

First 7 8 9 10 11 12 13 Last Page 9 of 562