acer

33400 Reputation

29 Badges

20 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@panke What is T(t), if not just t?

@ecterrab For future reference, this site allows you to upload a .zip file.

@Alessia Verme Yes, the plotting command can be viewed when using the (new, Maple 2018) PlotBuilder.

And, while that even survives a restart, the plotting command's details are actually stored in the Embedded Components that the PlotBuilder embeds in the worksheet.

But even in that case the command is not part of the plot data structure.

So all plots produced by other plotting commands do not contain the literal command call that produced them.

Did you intend this?

plot([x, cos(x)], x = -Pi .. Pi, y = -.5 .. .5);

@tomleslie The (old) maplenet backend to this site does not support a "Task Region" when rendering a .mw worksheet. So Explore, ImageTools:-Embed, DocumentTools:-Tabulate, and some other embedded items will not show here.

For some older discussions of this topic you could see here and here.

Do you want a surface that interpolates the data (ie. the surface should pass through the z-values of the given data points), or a smooth surface that approximates the data (without necessarily passing through each data point)?

Sometimes the choice will depend on on whether you anticipate that the data values have some error due to (say, physical) measurement.

Once you've imported the data you might have a look at the example worksheet with help topic,
    examples,Interpolation_and_Smoothing

That example worksheet has a smoothing example for 3D data, using the ScatterPlot3D command (similar to Carl's fine Answer, which also shows you how to import the data).

Alternatively, in Maple 2018 the new Interpolation package can be used to produce an interpolating object (call it F) from you data triples. This F can then be called with other numeric x and y values, where that F(x,y) computes an interpolated numeric z value. And so you can then use that F inside 3D plotting commands like plot3d . The example worksheet contains an example of that too. There are a variety of methods and options for the interpolation.

@Markiyan Hirnyk The time to evaluate to floating-point is not of greatest importance here.

I also added an exact simplifcation, for the original expression evaluated at each of the roots. I agree with Carl that that is important consideration in such examples, although I don't see it in his Answer.

Another aspect that can be of importance in related questions is whether small float imaginary components are mere artefacts due to roundoff error, etc. And so the application of evalc is a useful kind of simplification technique to know. So while not directly relevant for this example it's still worth mentioning.

The application of evalc can also be also useful for the verification step. Eg, for Carl's solution for the roots, and using his f definition and code,

CLans:=simplify~(eval~(Z, {solve(evalc~({Re,Im}(f(Z))), {x,y}, explicit)})):

simplify(convert~(evalc(eval~(f(z),z=~(CLans))),expln));
                            {0}

 

@Carl Love That does produce a nice surface, and there's no seam (because the suface doubles up when c>0). On my machine the horizontal gridlines are not evenly spaced when c>0, however.

So please forgive me if I offer an alternative here, where the gridlines are evenly spaced (but there is a very slightly darker horizontal gridline at z=0 when c>=0 -- the choice being either that or a small number of chinks visible upon manual rotation).

Explore(plots:-display(  
          plot3d([abs(sqrt(z^2+c))],
                 theta=-Pi..Pi,z=`if`(c>=0,0,sqrt(abs(c)))..sqrt(2),
                 coords=cylindrical,thickness=0),
          plot3d([(sqrt(max(0,z^2+c)))],
                 theta=-Pi..Pi,z=-sqrt(2)..`if`(c<=0,-sqrt(abs(c)),-5e-4),
                 coords=cylindrical,thickness=0),
          view= [-2..2,-2..2,-sqrt(2)..sqrt(2)]),
        c=-1.0..1.0);

With style=surface all these gridline issues vanish, naturally.

@stefanv It works in the command line interface but not in a Worksheet in the Standard GUI.

@nm 

What I'm trying to say is that a program that forces repeated copying of (immutable structures) sets or lists by repeatedly assigning into entries (using whatever syntax) is already a poor program.

And any syntax that makes coding that easier, in any language, is a poor language feature.

A syntax which makes a poor language feature "more natural to use" is no virtue at all.

@Carl Love Reaching for the eliminate command seems the natural thing to do here. But it looks as if there's something to fix, because the following returns the empty set instead of restrictions on the remaining name k.

That is, I am seeing this,

restart;

eqs:={-6*c+(3/2)*c^2-2*b-3*b*c+(3/2)*b^2-3*a*c+(k^2)*b-b+(3/2)*(a^2)+(k^2)*a-a=0,
      -2*b-3*b*c+3*(b^2)-6*a*c+2*(k^2)*c-2*c-9*a*b+3*(k^2)*b-3*b+6*(a^2)+4*(k^2)*a-4*a=0,
      (3/2)*(b^2)-3*a*c+(k^2)*c-c-9*a*b+3*(k^2)*b-3*b+9*(a^2)+6*(k^2)*a-a=0,
      -3*a*b+(k^2)*b-b+6*(a^2)+4*(k^2)*a-4*a=0, 
      (3/2)*(a^2)+(k^2)*a-a=0}:

eliminate(eqs, {a,b,c}):

           [{a = (1/3)*k^2-1/3, b = 0, c = 0}, {}]

But I would have expected something with a restriction on k in one part of the result, say something like this,

    [{a = 0, b = 0, c = 0}, {}],

    [{a = (1/3)*k^2-1/3, b = 0, c = 4}, { k^2 - 1 }]

The difference between Maple 16.02 and Maple 17.02 is that frac(Pi^22) is no longer being returned as (the same) unevaluated frac call. I completely missed that before.

Eg,

restart;            
kernelopts(version);

      Maple 16.02, X86 64 LINUX, Nov 18 2012, Build ID 788210

frac(Pi^22);

                             22
                      frac(Pi  )

versus,

restart;            
kernelopts(version);

        Maple 17.02, X86 64 LINUX, Sep 5 2013, Build ID 872941

frac(Pi^22);

                        22
                       Pi   - 86556004191

So the difference is Library side (rather than any change in the underlying kernel-extension mechanism, AFAIK). So with the current control-flow (and with frac(Pi^22) returning just Pi^22-86556004439 ) it's not clear at what point the frac computation could be intercepted and Digits adequately raised internally (see Carl's exposition) so that evalf(frac(Pi^22)) would return an answer accurate to inbound Digits.

@ecterrab I wrote a comment here which I've now deleted. I missed the fact that, in Maple 17.02 onwards, frac(Pi^22) is no longer returning unevaluated as it did in Maple 16.02.

I like vv's idea of approaching the problem via a parameterization.

The real and imaginary components of the original can be plotted, for some insight. It's harder for implicitplot if those are two surfaces which intersect along a curve at height z=0. And it's harder still if either of them only touches z=0 without crossing it.

Using fsolve can work, provided there is only one relevant solution p for each b (or vice versa), and if fsolve can always find the desired other real coordinate value (eg, when called with its complex option).

Here a a few more brief considerations:

restart;

 

ee := sqrt(b)*sqrt(1-4*p/b)-2*arctan(sqrt((9*p/b-22201/10000)/(9/4-9*p/b))):

# Try and create a single real-valued version which shares the same
# zeros as the original, but where the single surface crosses zero.

fun := proc(B,P,expr)
  local re,im,temp;
  if not ( B::numeric and P::numeric ) then
    return 'procname'(args);
  end if;
  temp := eval(expr,[b=B,p=P]);
  re,im := Re(temp),Im(temp);
  if re<0 and im<0 then
    min(re,im);
  else
    max(abs(re),abs(im));
  end if;
end proc:

CodeTools:-Usage(
  plots:-implicitplot('fun'(b,p,ee), b=0..5, p=0..1.5,
                      gridrefine=1, crossingrefine=7,
                      rangeasview)
);

memory used=150.27MiB, alloc change=4.00MiB, cpu time=1.10s, real time=1.10s, gc time=61.92ms

 

 

#plot3d( [ Re(ee), Re(fun(b,p,ee)) ], b=0..5, p=0..5, color=[red,blue] );
#plot3d( [ Im(ee), Im(fun(b,p,ee)) ], b=0..5, p=0..5, color=[red,blue] );

 

# Or one could try to turn off the refinement, increase
# the initial grid size, and wait.
#

CodeTools:-Usage(
  plots:-implicitplot(ee, b=0..5, p=0 .. 1.5,
                      gridrefine=0, crossingrefine=0,
                      grid=[601,100001], rangeasview)
);

memory used=0.92GiB, alloc change=0.94GiB, cpu time=51.10s, real time=51.05s, gc time=159.42ms

 
   
 

impl3.mw

First 269 270 271 272 273 274 275 Last Page 271 of 612