acer

32333 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I'm not sure what aspect of your original you found wanting.

restart;
with(Statistics):
randomize():
N := RandomVariable(Normal(300, 10)):
S := map(round,Sample(N, 100000)):
Histogram(S, frequencyscale = absolute,
          bincount = 75, binwidth = 1, tickmarks = [default, default]);

Pass it recursively as ':-num'=num .

The colon minus makes the lhs of that be a reference to the global name. The single right quotes protect against the case where you also might have assigned a value to the global name (ie. at the top level).

Use the plotsetup command to set the target device (ie. plot export driver).

And then use plots:-display or usual methods of "printing" the plot to output (which will direct it toward the set device).

Here are a few ways of shading the contours or its filled regions, on the 2D projection.

restart;

f := proc(x, y) options operator, arrow; sin(x)*cos(y) end proc:

Psurf:=plot3d(f, -Pi..Pi, -Pi..Pi, style=surface,
              colorscheme=["zgradient", ["Orange","Blue"]]):

Pcont2D_1:=plots:-contourplot(f, -Pi..Pi, -Pi..Pi,
                              coloring=["Orange","Blue"]):

Proj:=plottools:-transform((a,b)->[a,b,-1]):

plots:-display(
  Psurf,
  Proj(Pcont2D_1)
);

Pcont2D_2:=plots:-contourplot(f, -Pi..Pi, -Pi..Pi,
                              filledregions, coloring=["Orange","Blue"]):

plots:-display(
  Psurf,
  Proj(subsindets(Pcont2D_2,
                  specfunc(CURVES),
                  u->NULL))
);

plots:-display(
  Psurf,
  Proj(Pcont2D_1),
  Proj(subsindets(Pcont2D_2,
       specfunc(CURVES),
       u->NULL))
);

plots:-display(
  Psurf,
  Proj(subsindets(Pcont2D_2,
                 specfunc(CURVES),
                 u->CURVES(op(u),COLOUR(RGB,0.,0.,0.))))
);

 

surf_proj_contours.mw

You can resize the GUI Table inserted by the plots:-display command by manually dragging its borders.

Or you can change its Properties by right-clicking within it (in the white space, not the plot).

Note that if you re-execute the plots:-display command then the changed Table will be replaced with a new one (with default size).

If you want to be able to programmatically embed a GUI Table containing a plot, with a specific size, then you can use the DocumentTools:-Tabulate command in modern Maple (eg. version 2017). That command did not exist in your Maple 18, but the attached worksheet shows how you can programmatically get a similar effect for a plot. Note that the commands in use there are not documented in Maple 18, and are a bit fragile due to some lack or argument validation.

M18_DT_plot.mw

If your actual goal was to programmatically produce a 3D plot that displays automatically with a specific size (in Maple 18) then the following attachment illustrates another way to get that effect. This approach is not documented, and "your mileage may vary".

M18_sized_3dplot.mw

If your data is purely real numeric then you might try the LinearAlgebra:-CARE command.

For example,

restart;

with(LinearAlgebra):

C := Matrix([[-1.0/48,7.0/48],[7.0/48,-1.0/48]]);

_rtable[18446884658575974398]

M := Matrix([[121,314],[314,148]]);

_rtable[18446884658575975718]

a := ZeroMatrix(2):
b := IdentityMatrix(2):

U := CARE(a, b, M, C^(-1), 'output'=[':-X'])^%T;

_rtable[18446884658457859726]

U^%T . C . U = M;

_rtable[18446884658457861526] = _rtable[18446884658575975718]

 

Download CARE.mw

restart;

B := Vector([2,3]);

_rtable[18446883873619603454]

C := Vector([4]);

_rtable[18446883873619605494]

LinearAlgebra:-OuterProductMatrix(C, B);

_rtable[18446883873619606934]

LinearAlgebra:-OuterProductMatrix(B, C);

_rtable[18446883873619604774]

VectorOptions(B, orientation)

column

VectorOptions(C, orientation);

column

C . B^%T;

_rtable[18446883873619606814]

B . C^%T;

_rtable[18446883873588282182]

Br := Vector[row]([2,3]);

_rtable[18446883873588282782]

C . Br;

_rtable[18446883873588284102]

Cr := Vector[row]([4]);

_rtable[18446883873588284702]

B . Cr;

_rtable[18446883873588277726]

 

Download mult.mw

restart;

ee:=2*ln(3)-3*ln(2);

2*ln(3)-3*ln(2)

qq:=convert(ee,arctanh);

4*arctanh(1/2)-6*arctanh(1/3)

simplify(convert(qq,arcsinh));

4*arcsinh((1/3)*3^(1/2))-6*arcsinh((1/4)*2^(1/2))

simplify(convert(ee,arccosh));

2*arccosh(5/3)-3*arccosh(5/4)

simplify(convert(qq-ee,ln));

0

# This next part is ugly and awkward, and generally difficult to extend.
ff:=subsindets(ee,specfunc(positive,ln),u->ln(convert(op(u),name))):
ff:=combine(ff) assuming positive:
ff:=subsindets(combine(ff),name,parse);

ln(9/8)

pp:=convert(ff,arctanh);

2*arctanh(1/17)

simplify(convert(pp,arcsinh));

2*arcsinh((1/24)*2^(1/2))

simplify(convert(ff,arccosh));

arccosh(145/144)

simplify(convert(pp-ee,ln));

0

kernelopts(version);

`Maple 14.01, X86 64 LINUX, Oct 15 2010, Build ID 535952`

 

Download conv_arctrigh.mw

The fsolve command can have difficulty with the original because of the ill-behaviour numerically, alongside the fact that the expression is non-real-valued when K[1]<-1 or K[1]>1. This can be mitigated in several ways.

[edited] I am deliberately proceeding with ranges for K[1] that are wider than -1..1 on at least the positive side, simply because restricting the domain to within -1..1 is one way to mitigate the issue. It is of interest to see what happens when the user is not required to do such preliminary analysis to arrive at that approach.

restart;

ee:=-2*sqrt(-K[1]^2+1)*K[1]+4*K[1]^2-Pi-2*arctan(sqrt(-K[1]^2+1)/K[1]):

fsolve(ee,K[1]=0.5..2);
                          0.9832314847

fsolve(abs(ee),K[1]=0.5..20);
                          0.9832314847

# The next can return unevaluated (it varies with the range supplied).
fsolve(ee,K[1]=-2..2); 
fsolve(ee,K[1]=-2..20); 

These plots illustrate what's going on.

plot([Re,Im](ee),K[1]=-3..3,color=[red,blue],thickness=3,view=-20..20);
plot(abs(ee),K[1]=-3..3,color=[red,blue],thickness=3,view=0..20);

The difficulties with specifying the domain affect the Roots command as well.

Student:-Calculus1:-Roots(ee,K[1]=-1..1,numeric);
     [               -13                 -13              ]
     [-2.901814752 10   , -2.539955697 10   , 0.9832314847]

Student:-Calculus1:-Roots(abs(ee),K[1]=-2..2,numeric);
                         [0.9832314847]

# These next can return the empty list, it varies with range supplied
Student:-Calculus1:-Roots(ee,K[1]=-2..2,numeric);
                               []

Student:-Calculus1:-Roots(ee,K[1]=-2..20,numeric);
                               []

The solve command can be made to return a RootOf that can also produce the root your want (but is slower).

restart;
ee:=-2*sqrt(-K[1]^2+1)*K[1]+4*K[1]^2-Pi-2*arctan(sqrt(-K[1]^2+1)/K[1]):

evalf(allvalues([solve(ee,K[1])]));
Warning, solutions may have been lost

              [               -13]                
              [-2.147052793 10   ], [0.9832314847]

Shading of the polygon is done only when the interface renders it.

Maple consists of a executing kernel (computational engine) and an interface (the GUI say).

A plotting structure can be examined and manipulated by you using Maple language code which the kernel executes.

But it's only after the kernel sends the plotting structure off to the GUI (interface) that shading of the plotting structure gets done (when rendered for the output plotting device).

So AKAIK we never have access to the shaded polygon except through the plotting device (e.g. the rendered picture).

The contents of that Math Container is not a valid expression.

What were you hoping to accomplish?

The command you want is print, not display.

Did you attempt to copy&paste the output (or use an Equation Label) when constructing the operator that you assigned to eta? If so then that wouldn't work.

If you want to turn an expression (in q) into an operator (taking parameter q) then use the unapply command instead.

Q__gr := Typesetting[delayDotProduct](Vector[row](8, {(1) = 0, (2) = 5, (3) = 10, (4) = 15, (5) = 20, (6) = 25, (7) = 30, (8) = 35}), Unit('m'^3/'day'), true)

Vector[row](%id = 18446883716156560678)

`&eta;__gr` := Vector[row](8, {(1) = 0, (2) = 9.324, (3) = 17, (4) = 23.232, (5) = 27.192, (6) = 29.6, (7) = 29.516, (8) = 24.592})

Vector[row](%id = 18446883716156556702)

`points&eta;` := [seq([Q__gr[i], `&eta;__gr`[i]], i = 1 .. 8)]

[[0, 0], [5*Units:-Unit(m^3/d), 9.324], [10*Units:-Unit(m^3/d), 17], [15*Units:-Unit(m^3/d), 23.232], [20*Units:-Unit(m^3/d), 27.192], [25*Units:-Unit(m^3/d), 29.6], [30*Units:-Unit(m^3/d), 29.516], [35*Units:-Unit(m^3/d), 24.592]]

res := CurveFitting[PolynomialInterpolation](`points&eta;`, q)

0.2348698413e-7*q^7/Units:-Unit(m^3/d)^7-0.2980622223e-5*q^6/Units:-Unit(m^3/d)^6+0.1482222222e-3*q^5/Units:-Unit(m^3/d)^5-0.3663955556e-2*q^4/Units:-Unit(m^3/d)^4+0.4666528890e-1*q^3/Units:-Unit(m^3/d)^3-.3165382223*q^2/Units:-Unit(m^3/d)^2+2.655161905*q/Units:-Unit(m^3/d)

eta := unapply(res, q)

proc (q) options operator, arrow; 0.2348698413e-7*q^7/Units:-Unit(m^3/d)^7-0.2980622223e-5*q^6/Units:-Unit(m^3/d)^6+0.1482222222e-3*q^5/Units:-Unit(m^3/d)^5-0.3663955556e-2*q^4/Units:-Unit(m^3/d)^4+0.4666528890e-1*q^3/Units:-Unit(m^3/d)^3-.3165382223*q^2/Units:-Unit(m^3/d)^2+2.655161905*q/Units:-Unit(m^3/d) end proc

eta(12*Unit('m'^3/'day'))

19.76619849

``

Download unit_test_a.mw

There may be some other funny busniness going on, with distinct locals in the Units names appearing in numerators and denominators. But that could be hard to reproduce without knowing exactly what you did when entering that construction of the operator. Anyway, the unapply approach would be needed regardless.

Or perhaps one of these, either of which could be used subsequently with eval.

sol1:=simplify(solve(3^665/2^x=y, {x}, real, allsolutions));

                              665 ln(3) + ln(1/y)
                 sol1 := {x = -------------------}
                                     ln(2)

eval(sol1, y=3/2);

                           665 ln(3) + ln(2/3)
                      {x = -------------------}
                                  ln(2)

sol2:=simplify(solve({y>1,y<2,3^665/2^x=y}, {x}, real, allsolutions));

                  {            []                    y <= 1
                  {
                  {       665 ln(3) - ln(y)
          sol2 := { [{x = -----------------}]        y < 2
                  {             ln(2)
                  {
                  {            []                    2 <= y

eval(sol2, y=3/2);

                        665 ln(3) - ln(3/2)
                  [{x = -------------------}]
                               ln(2)

eval(sol2, y=1/2);

                              []

eval(sol2, y=5/2);

                              []
The empty list denotes no solutions. And you could also pass non-strict inqualities to solve.

One way is to plot either the real or the imaginary part, or both, using the Re and Im commands.

Below, the real part of u(x,t) is the red surface, and the imaginary part is the blue surface.

``

restart

u := proc (x, t) options operator, arrow; 1/2+I*sqrt(2)/(exp(-t+x)+2*exp(t-x))+(1/2)*(exp(-t+x)-2*exp(t-x))/(exp(-t+x)+2*exp(t-x)) end proc

proc (x, t) options operator, arrow; 1/2+I*sqrt(2)/(exp(-t+x)+2*exp(t-x))+(1/2)*(exp(-t+x)-2*exp(t-x))/(exp(-t+x)+2*exp(t-x)) end proc

plot3d(([Re, Im])(u(x, t)), x = -3 .. 3, t = -3 .. 3, color = [red, blue])


Download plot33_a.mw

First 181 182 183 184 185 186 187 Last Page 183 of 336