acer

32405 Reputation

29 Badges

19 years, 351 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I took reciprocals (twice, naturally) in order to get op(2,X) and v into the exact same form. But the rest was not so bad.

It's always interesting when simplify (or the is command) requires extra help. [I will submit a Software Change Request, citing the examples.)

restart

 

In Paul J. Nahin's book "The story of the square of " sqrt(-1) ", "Scipione del Ferro discovered the roots of the depressed cubic f (below, with p and q positive) by replacing x with u + v and by assuming that g (below) = 0.

del Ferro then found the values of u and v below

 

f := x^3+p*x = q

g := 3*u*v+p

u := ((1/2)*q+((1/4)*q^2+(1/27)*p^3)^(1/2))^(1/3); v := -(-(1/2)*q+((1/4)*q^2+(1/27)*p^3)^(1/2))^(1/3)


Although Maple's roots of f (Sol below) do not resemble del Ferro's, its two ops satisfy g and evaluate to x = 2 when p and q are 6 and 20 respectively, as in the example Nahin gives in his book.

 

How is this so when Maple's roots seem so different from del Ferro's?

 

Sol := solve([f, p > 0, q > 0], x)

piecewise(And(0 < p, 0 < q), [{x = (1/6)*(108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)-2*p/(108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)}], [])

X := `assuming`([eval(x, Sol[1])], [p > 0, q > 0])

(1/6)*(108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)-2*p/(108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)

`assuming`([simplify(combine(g))], [p > 0, q > 0])

0

simplify(eval(X, [p = 6, q = 20]))

2

`assuming`([simplify(combine(rationalize(X-u-v)))], [p > 0, q > 0])

0

simplify(eval(X-u-v, [p = 6, q = 20]))

0

`assuming`([simplify(combine(rationalize(op(1, X)-u)))], [p > 0, q > 0])

0

`assuming`([simplify(combine(rationalize(op(2, X)-v)))], [p > 0, q > 0])

0

simplify(rationalize(u), radical); op(1, X); evalb(% = `%%`)

(1/6)*(108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)

(1/6)*(108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)

true

`assuming`([simplify(rationalize(v))], [p > 0, q > 0]); `assuming`([1/simplify(1/v, radical)], [p > 0, q > 0]); evalb(% = `%%`)

-(1/6)*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)

-(1/6)*(-108*q+12*(12*p^3+81*q^2)^(1/2))^(1/3)

true

`assuming`([is(combine(rationalize(op(1, X)-u)) = 0)], [p > 0, q > 0])

true

`assuming`([is(combine(rationalize(op(2, X)-v)) = 0)], [p > 0, q > 0])

true

NULL

Download CubicRootsacc.mw

The line,
    combine(factor(expand(ee)))
will handle your expression, assigned below to ee.

If you have similar examples you might wish to restrict the combine by its exp option. If you have other examples where you don't want a blanket expand then you could target the original exp calls by using subsindets.

restart;

ee := exp(4*y) + 2*exp(2*y) + 1;

exp(4*y)+2*exp(2*y)+1

factor(expand(ee))

((exp(y))^2+1)^2

combine(factor(expand(ee)));

(exp(2*y)+1)^2

combine(factor(expand(ee)),exp);

(exp(2*y)+1)^2

 

Download exp_factor.mw

Is it because you misspelled "typeset"?

 

It's important to understand the basic kinds of structures and operations for differentiating.

Once you understand that you could move on to typeset "2D Math" representations. But IMO it's very important to understand what might be going on underneath.

note. You don't have to define a procedure such as f below, in order to obtain an expression such as
   y*sin(z)+2*cos(y)
You could also just type that expression out, assign that to some name, differentiate using the diff command, etc.

After you understand the following, you might look at these two older posts, here and here. (Note that I have not checked how those behave in modern versions.) There may also be support syntax for your input form from the Physics package. But you didn't attach your actual attempts.

restart;

# A procedure that takes two arguments (ie. has two
# parameters.

f := (y,z) -> y*sin(z)+2*cos(y);

proc (y, z) options operator, arrow; y*sin(z)+2*cos(y) end proc

# An expression

f(y,z);

y*sin(z)+2*cos(y)

# Differentiating the procedure with respect to its first
# parameter, by applying the differential operator `D`.

D[1](f);

proc (y, z) options operator, arrow; sin(z)-2*sin(y) end proc

# Using D as previously, and then evaluating at the
# arguments (Pi/2,Pi).

D[1](f)(Pi/2,Pi);

-2

# Differentiating the expression, with respect to y

diff(f(y,z),y);

sin(z)-2*sin(y)

# Differentiating the expression, with respect to y,
# and then evaluating at the point y=Pi/2,z=Pi.

eval(diff(f(y,z),y), [y=Pi/2,z=Pi]);

-2

 

And we can repeat all the above, but this time differentiating with
respect to the second parameter of procedure f, or with respect to
the name `z` for the expression f(y,z).

D[2](f);

proc (y, z) options operator, arrow; y*cos(z) end proc

D[2](f)(Pi/2,Pi);

-(1/2)*Pi

diff(f(y,z),z);

y*cos(z)

eval(diff(f(y,z),z), [y=Pi/2,z=Pi]);

-(1/2)*Pi

 

In 2D Input mode, the following syntax will also create a procedure.

note(!) This syntax will not accomplish the same thing in 1D plaintext
input. In that mode you should use the syntax at the start of this worksheet.

 

restart

"f(y,z):=y*sin(z)+2*cos(y)"

proc (y, z) options operator, arrow, function_assign; y*sin(z)+2*cos(y) end proc

f := (y,z) -> y*sin(z)+2*cos(y);

proc (y, z) options operator, arrow; y*sin(z)+2*cos(y) end proc

 

Download procs_expressions_differentiation.mw

Firstly, you can compare your technique's results with those of the plots:-conformal command (using suitable parameters, of course).  See attached.

Next, we can cobble together a version of multiple calls to plots:-conformal, so that we attempt a shading by hue which is similar to his scheme. (One could also scale the intensity, the "V" of "HSV", but I have not done that.)

Also -- and I expect this may be key for you -- one can compare his scheme on log(z) versus yours for exp(z), and vice-versa, and his for arcsin(z) against your for sin(z). Do that explain the discrepancy to your satisfaction, as a matter of direction of the operation? (I do not know why he chose to display the inverse mapping...)

restart;

with(plots):

xMax := 1: yMax := 1:
N := 10; step := abs(xMax)/N:
GL := proc(x, y) options operator, arrow; x+I*y end proc:
f := exp;
G := {}: for k from -N+1 to N+1 do
  G := `union`(G, {complexplot(f(GL(x, (k-1)*step)), x = -xMax .. xMax, color = brown)});
  G := `union`(G, {complexplot(f(GL((k-1)*step, y)), y = -yMax .. yMax, color = brown)})
end do:

10

exp

P1:=display(G,scaling=constrained,size=[300,300]):
P1;

P2:=plots:-conformal(f(z),z=-xMax-yMax*I..xMax+yMax*I,
                 grid=[2*N+1,2*N+1],color=brown,
                 scaling=constrained,size=[300,300]):
P2;

# compare with   http://davidbau.com/conformal/#log(z)
#

(m,n):=16,16;
P3:=plots:-display(seq(seq(plots:-conformal(f(z),
               z=   (-m*1/16+(i-1)*(1/16)) + (-n*1/16+(j-1)*(1/16))*I
                 .. (-m*1/16+(i)*(1/16))   + (-n*1/16+(j)*(1/16))*I,
                 grid=[2,2],numxy=[2,2],
                 color=ColorTools:-Color("HSV",[(Pi/2+arctan(((i-1)-m)/m,
                                                             ((j-1)-n)/n))/(2*Pi),
                                                1,1]),
                 scaling=constrained,size=[300,300]),
    i=1..2*m+1),j=1..2*n+1)):
P3;

16, 16

# alternate bookkeeping
# compare with  http://davidbau.com/conformal/#sin(z)
#
f := arcsin;
(a,b,c,d):=-1,-1,1,1;
(m,n):=(c-a)*16, (d-b)*16;
plots:-display(seq(seq(plots:-conformal(f(z),
               z=(a+(i-1)*(c-a)/(m-1))+(b+(j-1)*(d-b)/(n-1))*I
                 .. (a+(i)*(c-a)/(m-1))+(b+(j)*(d-b)/(n-1))*I,
                 grid=[2,2],numxy=[2,2],
                 color=ColorTools:-Color("HSV",[(Pi/2
                                                 +arctan((i-1-(m-1)/2)/(m-1),
                                                         (j-1-(n-1)/2)/(n-1)))/(2*Pi),
                                                1,1]),
                 scaling=constrained,size=[300,300]),
    i=1..m-1),j=1..n-1))

arcsin

-1, -1, 1, 1

32, 32

# compare with  http://davidbau.com/conformal/#arcsin(z)
#
f := sin;
(a,b,c,d):=-1,-1,1,1;
(m,n):=(c-a)*16, (d-b)*16;
plots:-display(seq(seq(plots:-conformal(f(z),
               z=(a+(i-1)*(c-a)/(m-1))+(b+(j-1)*(d-b)/(n-1))*I
                 .. (a+(i)*(c-a)/(m-1))+(b+(j)*(d-b)/(n-1))*I,
                 grid=[2,2],numxy=[2,2],
                 color=ColorTools:-Color("HSV",[(Pi/2
                                                 +arctan((i-1-(m-1)/2)/(m-1),
                                                         (j-1-(n-1)/2)/(n-1)))/(2*Pi),
                                                1,1]),
                 scaling=constrained,size=[300,300]),
    i=1..m-1),j=1..n-1))

sin

-1, -1, 1, 1

32, 32

# compare with  http://davidbau.com/conformal/#exp(z)
#
f := ln;
(a,b,c,d):=-1,-1,1,1;
(m,n):=(c-a)*16, (d-b)*16;
plots:-display(seq(seq(plots:-conformal(f(z),
               z=(a+(i-1)*(c-a)/(m-1))+(b+(j-1)*(d-b)/(n-1))*I
                 .. (a+(i)*(c-a)/(m-1))+(b+(j)*(d-b)/(n-1))*I,
                 grid=[2,2],numxy=[2,2],
                 color=ColorTools:-Color("HSV",[(Pi/2
                                                 +arctan((i-1-(m-1)/2)/(m-1),
                                                         (j-1-(n-1)/2)/(n-1)))/(2*Pi),
                                                1,1]),
                 scaling=constrained,size=[300,300]),
    i=1..m-1),j=1..n-1))

ln

-1, -1, 1, 1

32, 32

# compare with  http://davidbau.com/conformal/#log(z)
#
f := exp;
(a,b,c,d):=-1,-1,1,1;
(m,n):=(c-a)*16, (d-b)*16;
plots:-display(seq(seq(plots:-conformal(f(z),
               z=(a+(i-1)*(c-a)/(m-1))+(b+(j-1)*(d-b)/(n-1))*I
                 .. (a+(i)*(c-a)/(m-1))+(b+(j)*(d-b)/(n-1))*I,
                 grid=[2,2],numxy=[2,2],
                 color=ColorTools:-Color("HSV",[(Pi/2
                                                 +arctan((i-1-(m-1)/2)/(m-1),
                                                         (j-1-(n-1)/2)/(n-1)))/(2*Pi),
                                                1,1]),
                 scaling=constrained,size=[300,300]),
    i=1..m-1),j=1..n-1))

exp

-1, -1, 1, 1

32, 32

# compare with  http://davidbau.com/conformal/#arctan(z)
#

f := tan;
(a,b,c,d):=-1,-1,1,1;
(m,n):=(c-a)*16, (d-b)*16;
plots:-display(seq(seq(plots:-conformal(f(z),
               z=(a+(i-1)*(c-a)/(m-1))+(b+(j-1)*(d-b)/(n-1))*I
                 .. (a+(i)*(c-a)/(m-1))+(b+(j)*(d-b)/(n-1))*I,
                 grid=[2,2],numxy=[2,2],
                 color=ColorTools:-Color("HSV",[(Pi/2
                                                 +arctan((i-1-(m-1)/2)/(m-1),
                                                         (j-1-(n-1)/2)/(n-1)))/(2*Pi),
                                                1,1]),
                 scaling=constrained,size=[300,300]),
    i=1..m-1),j=1..n-1))

tan

-1, -1, 1, 1

32, 32

 

Download conformalfun.mw

ps. If I were to attempt such a coloring scheme from scratch I'd try and do it more gracefully and efficiently, rather than clumping all these plots:-conformal calls with shared edges (and duplicated calculations). I did it this way partly because I was trying a crude mimicing of his "1/16" block, with your own technique also in my mind, and partly because I wanted to see the end result sooner and with less coding effort.

It seems as if you are trying to find the discrete minimum, for nn a positive integer in 1..5.

If I have interpreted the goal properly, then I suspect that the following might not surprise anyone (where each xx[ii] attaints its lower bound, for each posint nn).

Hence my use of n-n^2 in the first computation below (where even that min and seq call are avoidable if we realize it is decreasing).

Your original formulation is an abuse of the notation and syntax, IMHO. But below is (just) one way to deal with the programming.

restart;

min(seq(n-n^2, n=1..5));

-20

W := proc(nn)
  local ii, rf;
  if not nn::posint then return 'procname'(args); end if;
  rf := add(xx[ii]^2-nn,ii=1..nn);
  return rf;
end proc:

K := proc(nn::posint)
  Optimization:-Minimize(W(nn),seq(xx[ii]=1..10,ii=1..nn));
end proc:

min(seq(K(i)[1], i=1..5));

-20.

K(5);

[-20., [xx[1] = HFloat(1.0), xx[2] = HFloat(1.0), xx[3] = HFloat(1.0), xx[4] = HFloat(1.0), xx[5] = HFloat(1.0)]]

 

Download discr_opt.mw

You could try something like this,

restart;

replace_all_C:=proc(expr::anything)
  subsindets(expr, ':-suffixed(_C, posint)',
           u->c[parse(convert(u,string)[3..])]);
end proc:

sol:=dsolve(diff(x(t),t$3) = x(t));

x(t) = _C1*exp(t)+_C2*exp(-(1/2)*t)*sin((1/2)*3^(1/2)*t)+_C3*exp(-(1/2)*t)*cos((1/2)*3^(1/2)*t)

tmp:=replace_all_C(sol)

x(t) = c[1]*exp(t)+c[2]*exp(-(1/2)*t)*sin((1/2)*3^(1/2)*t)+c[3]*exp(-(1/2)*t)*cos((1/2)*3^(1/2)*t)

 

Download q_acc.mw

There are several interesting ways to plot the logistic map, and it's not completely clear from your wording what kind of plot you are after (though I might guess that you might be looking for a straightforward solution, as a beginner in Maple).

On this forum, see herehere, here, and here.

You can also see the Bifurcation command, in more recent Maple versions.

See also here, for the cobweb plot example near the bottom.

This is a fequently asked question.

f:=x->x^2+x^3:

g:=unapply(diff(f(x),x),x);

   g := x -> 3*x^2+2*x

g:=D(f);
   g := x -> 3*x^2+2*x

Let me know if this is the kind of thing that you wanted to accomplish.

I used the DirectSearch ver.2 package for the nonlinear fitting (since the NonlinearFit command does local optimization and without a tight set of parameter ranges it can converge to a local optimum that is a measurably worse fit). You can install the DirectSearch ver.2 package in the Maple 2020 GUI from the menubar's Maple Cloud login, or obtain it from the Maple Cloud website here, or for much older Maple versions install from the Application Center here.
 

restart;

with(LinearAlgebra):

#data:=ExcelTools:-Import("D:/Maple/donnees_cycles_sin_lejeunes.xlsx"):
data:=ExcelTools:-Import(cat(kernelopts(homedir),"/mapleprimes",
                             "/donnees_cycles_sin_lejeunes.xlsx")):

PK1Expe:=Column(data,1):

fHz:=3: #fréquence
lambdaS:=0.5:
lambdaD:=0.3:
lambdaTrig:= piecewise(t < 1/fHz, 1+lambdaS*t*fHz, t >= 1/fHz, 1+lambdaS+lambdaD*sin((2*Pi*(t-1/fHz)*fHz))):

with(LinearAlgebra):
tensF:=Matrix([[lambdaTrig,0,0],[0,1/sqrt(lambdaTrig),0],[0,0,1/sqrt(lambdaTrig)]]):
tensdF:=diff(tensF,t):
tensFDev:=tensF-(1/3)*Trace(tensF)*Matrix(3,shape=identity):
tensB:=Multiply(tensF,Transpose(tensF)):
tensL:=Multiply(tensdF,MatrixInverse(tensF)):
tensD:=(1/2)*(tensL+Transpose(tensL)):
tensBe:=Matrix([[Be11(t),0,0],[0,1/sqrt(Be11(t)),0],[0,0,1/sqrt(Be11(t))]]):
tensBeDev:=tensBe-(1/3)*Trace(tensBe)*Matrix(3,shape=identity):

ode:=tensdBe[1,1]=-(2/3)*tensBe[1,1]*Trace(tensD)+Multiply(tensL[1,1],tensBe[1,1])+Multiply(tensBe[1,1],Transpose(tensL[1,1]))-(2/eta)*a*Multiply(tensBeDev[1,1],tensBe[1,1]): ivp:=[ode,Be11(0)=1]:

tensdBe:=diff(tensBe,t):

ode_sol:=dsolve(ivp,numeric,parameters=[a,eta]):

Be11Num:=proc(aValue,etaValue,tValue)
   global __old_a, __old_eta;
   local res;
   if not [aValue,etaValue,tValue]::list(numeric) then
      return 'procname'(args);
   end if;
   if __old_a<>A_value and __old_eta<>etaValue then
      (__old_a,__old_eta) := aValue,etaValue;
      ode_sol('parameters'=[a=aValue,eta=etaValue]);
   end if;
   res:=rhs(ode_sol(tValue)[2]);
   #evalf[8](res);
end proc:

Be11Num(a,eta,t); # returns unevaluated, good

Be11Num(a, eta, t)

ode_sol(parameters=[a=1,eta=0.1]);
ode_sol(2.0)[2], Be11Num(1,0.1,2.0); # these should agree

[a = 1., eta = .1]

Be11(t) = HFloat(1.2342315801626595), HFloat(1.2342315801626595)

ode_sol(parameters=[a=1.4,eta=0.3]);
ode_sol(2.0)[2], Be11Num(1.4,0.3,2.0); # these should agree

[a = 1.4, eta = .3]

Be11(t) = HFloat(1.1815627486067706), HFloat(1.1815627486067706)

tensTemp1:=2*C1*tensB+4*C2*(Trace(tensB)-3)*tensB+6*C3*(Trace(tensB)-3)*tensB-2*C4*MatrixInverse(tensB):
tensTemp1Dev:=tensTemp1-(1/3)*Trace(tensTemp1)*Matrix(3,shape=identity):
tensBe:=Matrix([[Be11Num(a,eta,t),0,0],[0,1/sqrt(Be11Num(a,eta,t)),0],[0,0,1/sqrt(Be11Num(a,eta,t))]]):
tensTemp2Dev:=2*a*tensBe-(1/3)*Trace(2*a*tensBe)*~Matrix(3,shape=identity):
sigma:=tensTemp1Dev+tensTemp2Dev-p*~Matrix(3,shape=identity):
p:=sigma[2,2]+p:
sigma:=tensTemp1Dev+tensTemp2Dev-p*~Matrix(3,shape=identity):
PK:=sigma.Transpose(MatrixInverse(tensF)):
PK:=PK[1,1]: #expression  to fit

vectorT:=[seq(i,i=0..13/3,0.01)]:
vectorT:=Vector(vectorT):

DS2:=CodeTools:-Usage(
        DirectSearch:-DataFit(PK,vectorT,PK1Expe,t,
                              [ a=0.1 .. 10.0, eta=0.1 .. 10.2
                                ,C1=0..1, C2=0..10, C3=-6..6, C4=0..1
                              ])
);

memory used=7.16GiB, alloc change=6.00MiB, cpu time=110.76s, real time=105.76s, gc time=10.59s

[HFloat(5.798836840043786e-7), [C1 = HFloat(0.07091614374135646), C2 = HFloat(0.19080181427660822), C3 = HFloat(-0.13066108619768044), C4 = HFloat(2.090135897538898e-5), a = HFloat(0.6139583977913079), eta = HFloat(0.5024357747664052)], 615]

plots:-display(
   plot(<vectorT|PK1Expe>, style=point, color=blue),
   plot(eval(PK,DS2[2]), t=min(vectorT)..max(vectorT),
   size=[600,300]));

 

Download donnees_cycles_sin_DS.mw

You are encountering an (old, eg Maple 11) evaluation issue in animate.

(The problem was fixed many years/releases ago.)

There are several possible workarounds, for your example in your version.

In your Maple 11, replace the call,

   animate(pointplot3d, [ [b(t),c(t),d(t)], symbol=box, color=blue],t=15..100,
                 background = odeplot(sol, [x(t),y(t),z(t)],t=15..100,numpoints=7000),
                 frames=20);

with,

   animate(t->pointplot3d([b(t),c(t),d(t)], symbol=box, color=blue),[t],t=15..100,
                 background = odeplot(sol, [x(t),y(t),z(t)],t=15..100,numpoints=7000),
                 frames=20);

 

I'm not sure what you want to do about "c". Do you want it as some new unit, and if so could you specify completely? I'm not sure I understand what you want with "c=h=1".

restart

Units:-UseUnit(MeV); Units:-UseUnit(MeV*s)

ro := 10^(-15)*Unit('m')

(1/1000000000000000)*Units:-Unit(m)

h := 0.658e-21*Unit('MeV'*'s')

0.658e-21*Units:-Unit(MeV*s)

pmin := 0.3e9*h*Unit('m'/'s')/((2*ro)*c)

98.70000000*Units:-Unit(MeV*s)*Units:-Unit(m/s)/(Units:-Unit(m)*c)

combine(pmin, units)

98.70000000*Units:-Unit(MeV)/c

simplify(pmin)

98.70000000*Units:-Unit(MeV)/c

By the way...

convert(Units:-Unit('h_bar'), units, MeV*s)

0.6582119515e-21*Units:-Unit(MeV*s)

By the way...

cc := ScientificConstants:-Constant('c'); ScientificConstants:-GetUnit(cc); ScientificConstants:-GetValue(cc); evalf(cc)

Units:-Unit(m/s)

299792458

299792458.

with(ScientificConstants)

Pmin := Unit('h_bar')*GetValue(cc)*GetUnit(cc)/((2*ro)*c)

149896229000000000000000*Units:-Unit(h_bar)*Units:-Unit(m/s)/(Units:-Unit(m)*c)

simplify(Pmin)

98.66348941*Units:-Unit(MeV)/c

 

Download unitsMeVs.mw

The problem seems to lie in how the GUI is attempting to typeset the echoed assignment, where the result from fsolve is NULL (no real solution found).

In particular the problem seems to be that the problematic paragraph in question has had its "Numeric Formatting" set to "fixed" with 3 decimal places. It seems that when the result of the computation is NULL this goes wrong and it mishandles trying to typeset that in the specified numeric format (which is a GUI bug).

I had difficulty fixing it by, say, changing the d_sample value to 4.5 so the an numeric result was attained, toggling off Numeric Formatting (I think successfully), re-executing OK, then changing the value of d_sample back to 4.6 so that no real root would be found. The problem remained. But I was able to reproduce the problem (see at end) in a way that convinces me that Numeric Formatting of the assignment of NULL is the cause.

One way to fix the example is to place a full colon as terminator of the problematic 2D Input line. Then d_cam_solved gets properly assigned NULL, but the problematic echoing of the assignment is avoided.

Another way to avoid the problem is to wrap the call to fsolve in square brackets, eg, [fsolve(...)] so that in the problematic case the result is the empty list [].

Another way to fix the example is to rewrite the whole line (manually), but without setting its Numeric Formatting. But not cut&paste of the input line, as that can inherit the prior Numeric Formatting. See attached.

 using ray transfer matrix analysis

 

 #We use Rads and mm as units

 

 

 #Ray transfer matrix for free space

Distance := proc (d) options operator, arrow; Matrix(2, 2, [1, d, 0, 1]) end proc

proc (d) options operator, arrow; Matrix(2, 2, [1, d, 0, 1]) end proc

NULL

Lens := proc (f) options operator, arrow; Matrix(2, 2, [1, 0, -1/f, 1]) end proc

proc (f) options operator, arrow; Matrix(2, 2, [1, 0, -1/f, 1]) end proc

Geometry := 2; if Geometry = 1 then f_obj := 4.5; f_fluo := 125; f_TIE := 45; d_sample := f_obj; d_max := 250; d_cam := f_TIE; d_interlens := d_max-d_cam end if; if Geometry = 2 then f_obj := 4.5; f_fluo := 125; f_TIE := 45; d_sample := 4.6; d_max := 250; d_interlens := d_max-d_cam end if

250-d_cam

TIE := Distance(d_cam).Lens(f_TIE).Distance(d_interlens).Lens(f_obj).Distance(d_sample).Vector(2, [distance, angle])

Vector[column](%id = 18446883956361111542)

NULL``

d_cam_solve := fsolve(coeff(TIE[1], angle, 1), d_cam, d_cam = 20 .. 100)

``

Download Ray_transfer_matrix_ac.mw

I can reproduce the problem elsewhere. I create a Document with the 2D Input,
   foo:=1.234567
and then execute, and then set the Numeric Formatting to say "fixed" with 3 decimal places. Then I change the 2D Input to instead be,
   foo:=NULL
and re-execute, and this problem appears. I will submit a bug report.

The problem also occurs if the input is in 1D plaintext Maple Notation, if the 2D Output Numeric formatting is so-adjusted, etc.

plots:-animate(plot3d,[[Re,Im](u^4*BesselJ(alpha+4,u)*BesselJ(alpha,v)),
                       u=-12..12, v=-12..12, grid=[51,51],
                       color=[red,blue]],
               alpha=-1..4, frames=50);

Below I make no extra attempt at gaining efficiency (eg. by memoization).

plots:-animate(plot3d,[abs(u^4*BesselJ(alpha+4,u)*BesselJ(alpha,v)),
                       u=-12..12, v=-12..12, grid=[51,51],
                       color=[argument(u^4*BesselJ(alpha+4,u)*BesselJ(alpha,v)),
                              1,1,colortype=HSV]],
               alpha=-1..4, frames=50);

You can use plot(...,style=point) or you can use Statistics:-ScatterPlot.

You can also add options axes=box and a color, and have plot(...,style=point) produce something similar to the ScatterPlot result here.

Sieving out the non-numeric data has an added benefit that the plot determines the horizontal range of the valid data more nicely. 

restart;

N := 200:

V1 := LinearAlgebra:-RandomVector(N,generator=-1.0..1.0):

#
# V2 contains some Float(undefined) entries.
#
V2 := map(x->RealDomain:-sqrt(0.4-x)-RealDomain:-sqrt(0.3+x),V1):

M:=<V1|V2>:

M[1..6,..];

Matrix(6, 2, {(1, 1) = .589662833766906092, (1, 2) = Float(undefined), (2, 1) = .635255416644524118, (2, 2) = Float(undefined), (3, 1) = 0.215431283442193422e-1, (3, 2) = 0.481407545e-1, (4, 1) = 0.170173107622539899e-1, (4, 2) = 0.558130487e-1, (5, 1) = -.387301055966885244, (5, 2) = Float(undefined), (6, 1) = -.106432501140387492, (6, 2) = .2716776453})

plot(M,style=point,size=[300,300]);

A:=`<,>`(select(type,[seq(M[i,..],i=1..N)],'Vector'(numeric))[]):

A[1..6,..];

Matrix(6, 2, {(1, 1) = 0.215431283442193422e-1, (1, 2) = 0.481407545e-1, (2, 1) = 0.170173107622539899e-1, (2, 2) = 0.558130487e-1, (3, 1) = -.106432501140387492, (3, 2) = .2716776453, (4, 1) = -.128282822838161836, (4, 2) = .3124429564, (5, 1) = -0.264167351936552830e-1, (5, 2) = .1299540470, (6, 1) = .251237121459380708, (6, 2) = -.3567555365})

#
# If you want the horizontal domain to be restricted
# automatically, then you could select only the numeric rows.
#
plot(A,style=point,size=[300,300]);

plot(A,style=point,color="SteelBlue",axes=box,size=[300,300]);

#
# ScatterPlot is here (mostly) acting like the plot(..,style=point).
#
Statistics:-ScatterPlot(A,size=[300,300]);

#
# ScatterPlot can handle Float(undefined).
#
# It also doesn't determine the nicer horizontal range automatically.
#
Statistics:-ScatterPlot(<V1|V2>,size=[300,300]);

#
# Or, using a list of lists (of the pairs of values).
#
L1:=[seq([V1[i],V2[i]],i=1..N)]:
#L1[1..6,..];
plot(L1,style=point,size=[300,300]);

L2:=select(hastype,L1,list(realcons)):
#L2[1..6,..];
plot(L2,style=point,size=[300,300]);

#
# Or, generate the shorter list of lists directly,
# without wasting space on the unwanted points.
#
L3:=[seq(`if`(V2[i]::realcons,[V1[i],V2[i]],NULL),i=1..N)]:
#L3[1..6,..];
plot(L3,style=point,size=[300,300]);

Statistics:-ScatterPlot(L3,size=[300,300]);

 

Download point_plot_undef.mw

First 110 111 112 113 114 115 116 Last Page 112 of 336