PatrickT

Dr. Patrick T

2108 Reputation

18 Badges

16 years, 303 days

MaplePrimes Activity


These are replies submitted by PatrickT

@acer 

thanks acer, strip does a great job.

I guess I'm luck I don't have Pi in my expressions, so evalf is good enough for me at this time. Also kind of lucky that the e of the exponential function is not processed by evalf and replaced by 2.718, as it might have been in another implementation.

I thought it would be easy to fix evalf for this purpose, along the lines of:

evalfn := proc(x)
  if type(x,'complex'('float')) then
    return evalf[5](x);
  end if;
  return x;
end proc:

evalfn(Pi);
evalfn(evalf(Pi));
evalfn(Pi+evalf(Pi));
                               Pi
                             3.1416
                        Pi + 3.141592654

But something more advanced would be needed than this simple proc to deal with combinations of floats and symbols.

Anyways, I'm completely satisfied with the results I get with your strip, acer. Thanks a lot.

as you're new to Maple, perhaps you're experiencing what I experienced just a few days ago: expecting the animation to play by default, but it doesn't, you have to right-click on animation and select play in order to see that.

would be nice to have a play=true option, but I don't think there is anything like it.

as you're new to Maple, perhaps you're experiencing what I experienced just a few days ago: expecting the animation to play by default, but it doesn't, you have to right-click on animation and select play in order to see that.

would be nice to have a play=true option, but I don't think there is anything like it.

After all placing the legend at the bottom works better visualy than placing it on the left, I think.

The procedure StripTrailingZeroes has not worked as well as I'd hoped on some more complicated formulae than the one exemplified earlier, so I haven't used it at all after all,  but perhaps it is fine to have some trailing zeroes after all (the drawback is it takes up extra space).

Here is the result of a more complicated example than the one displayed above. It's not perfect, but acceptable.

 

As remarked by acer, the inline behaviour is different from the behaviour within the legend. When applying evalf[3] within the worksheet, I get this, where 0.10 replaces 1/10,

piecewise(t < 10., (.50*(1-.100*t))*exp(-0.500e-1*t)+.50*exp(-.10*t), .50*exp(-.10*t));

but if I apply evalf[3] within the legend, I get this, where t<10.00 replaces t<10.

If I find a better way, I'll report back, but in the meantime I'm satisfied with the result of the plot at the top here.

After all placing the legend at the bottom works better visualy than placing it on the left, I think.

The procedure StripTrailingZeroes has not worked as well as I'd hoped on some more complicated formulae than the one exemplified earlier, so I haven't used it at all after all,  but perhaps it is fine to have some trailing zeroes after all (the drawback is it takes up extra space).

Here is the result of a more complicated example than the one displayed above. It's not perfect, but acceptable.

 

As remarked by acer, the inline behaviour is different from the behaviour within the legend. When applying evalf[3] within the worksheet, I get this, where 0.10 replaces 1/10,

piecewise(t < 10., (.50*(1-.100*t))*exp(-0.500e-1*t)+.50*exp(-.10*t), .50*exp(-.10*t));

but if I apply evalf[3] within the legend, I get this, where t<10.00 replaces t<10.

If I find a better way, I'll report back, but in the meantime I'm satisfied with the result of the plot at the top here.

  1. I used the evalf[5] command as acer suggested,
  2. the striptrailing proc was used to eliminate superfluous zeroes that weren't going away,
  3. and I also controlled the font size within the legend to squeeze the legend within thebox
  4. I don't think it's possible to control the size of the box
  1. I used the evalf[5] command as acer suggested,
  2. the striptrailing proc was used to eliminate superfluous zeroes that weren't going away,
  3. and I also controlled the font size within the legend to squeeze the legend within thebox
  4. I don't think it's possible to control the size of the box

Thanks acer, great idea. In the meantime I chanced upon an old thread with some useful stuff, which I have implemented as shown below.

http://www.mapleprimes.com/questions/36812-How-To-Delete-Zeros-After-Decimal-Point

It may not be the most succinct approach, but it's working on these examples.

StripTrailingZeroes := proc(x)
 local n,xi, M,E, str_M, str_mu,mu,k,eta;
 if not( type(x, float) ) then return 'x'; end if;
 if x=0 then return 0. end if;
 if x < 0 then return -procname(-x); end if;
 M,E := SFloatMantissa(x),SFloatExponent(x);
 str_M := convert(M,string);
 StringTools:-SubstituteAll(%, "0", " ");
 StringTools:-TrimRight(%);
 str_mu:=StringTools:-SubstituteAll(%, " ", "0");
 mu:=parse(%);
 k:=length(str_M)-length(str_mu);
 SFloat(mu,E+k);
end proc:

functionList := [ exp(-0.06123456789*t), exp(-0.06*t)*exp(-1+exp(-0.50*t)) ] :
colorList := [ red , blue ] :
legendList := functionList :
testPlot :=
  plot( [ seq( functionList[k], k = [1,2] ) ]
    , t = 0 .. 100
    , 'colour' = [ seq( colorList[k], k = [1,2] ) ]
    , 'legend' = [ seq( 'D(t)' = subsindets(evalf[5](legendList[k]),float,StripTrailingZeroes) , k = [1,2] ) ]
    , 'legendstyle' = [ 'font' = [TIMES,ROMAN,10], 'location' = left ]
  ) :

Thanks acer, great idea. In the meantime I chanced upon an old thread with some useful stuff, which I have implemented as shown below.

http://www.mapleprimes.com/questions/36812-How-To-Delete-Zeros-After-Decimal-Point

It may not be the most succinct approach, but it's working on these examples.

StripTrailingZeroes := proc(x)
 local n,xi, M,E, str_M, str_mu,mu,k,eta;
 if not( type(x, float) ) then return 'x'; end if;
 if x=0 then return 0. end if;
 if x < 0 then return -procname(-x); end if;
 M,E := SFloatMantissa(x),SFloatExponent(x);
 str_M := convert(M,string);
 StringTools:-SubstituteAll(%, "0", " ");
 StringTools:-TrimRight(%);
 str_mu:=StringTools:-SubstituteAll(%, " ", "0");
 mu:=parse(%);
 k:=length(str_M)-length(str_mu);
 SFloat(mu,E+k);
end proc:

functionList := [ exp(-0.06123456789*t), exp(-0.06*t)*exp(-1+exp(-0.50*t)) ] :
colorList := [ red , blue ] :
legendList := functionList :
testPlot :=
  plot( [ seq( functionList[k], k = [1,2] ) ]
    , t = 0 .. 100
    , 'colour' = [ seq( colorList[k], k = [1,2] ) ]
    , 'legend' = [ seq( 'D(t)' = subsindets(evalf[5](legendList[k]),float,StripTrailingZeroes) , k = [1,2] ) ]
    , 'legendstyle' = [ 'font' = [TIMES,ROMAN,10], 'location' = left ]
  ) :

@acer wrote:

I also couldn't seem to put color on the symbols in that second example above. If I tried to use `#mo("&ast;",mathcolor = "red")` instead of `&ast;` then my Maple 12 GUI froze solid.


This now works on Maple 15 / Windows 7-64 / Standard.

@acer wrote:

I also couldn't seem to put color on the symbols in that second example above. If I tried to use `#mo("&ast;",mathcolor = "red")` instead of `&ast;` then my Maple 12 GUI froze solid.


This now works on Maple 15 / Windows 7-64 / Standard.

It may be useful to have relevant discussions in one place, here a few links that contain discussions about problems, workarounds, suggestions for improvements, and functionality extensions, listed in no particular order:

http://www.mapleprimes.com/questions/125991-Export-Plot-In-Standard-Gui-More-Problems

http://www.mapleprimes.com/questions/124671-Plotsetup-Versus-Mouse-Export-Inconsistencies

http://www.mapleprimes.com/questions/125945-Plot-Size-On-Export-With-Maple-15

http://www.mapleprimes.com/posts/125899-Presized-Plots

http://www.mapleprimes.com/questions/123177-Exporting-3D-Plots-In-Maple-15

http://www.mapleprimes.com/posts/125952-Export-Plot-Driver-In-Standard

http://www.mapleprimes.com/questions/37133-Tickmarks--How-To-Set-Spacing-And-Thickness

http://www.mapleprimes.com/questions/37921-Plot-Legend-Of-Lines-With-Symbols-solidcircle

http://www.mapleprimes.com/questions/125531-Anyone-Else-Discover-This-Bug-In-The

To substantiate the claim above, that the default width for a plot with legend, inline, is too narrow, consider the default appearance within a Standard GUI worksheet under Maple 15, Windows 7-64 bits:

On this and a workaround suggested by acer when exporting was discussed here:

http://www.mapleprimes.com/questions/125945-Plot-Size-On-Export-With-Maple-15

To substantiate the claim above, that the default width for a plot with legend, inline, is too narrow, consider the default appearance within a Standard GUI worksheet under Maple 15, Windows 7-64 bits:

On this and a workaround suggested by acer when exporting was discussed here:

http://www.mapleprimes.com/questions/125945-Plot-Size-On-Export-With-Maple-15

To quote Joe on this, "  It would be helpful to have the actual model that is causing the problem."

First 35 36 37 38 39 40 41 Last Page 37 of 93