acer

32405 Reputation

29 Badges

19 years, 346 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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

Here's one way to manipulate the equation in question.

Download File_to_help_a.mw

It worked for me, using Maple 2015.2., after I got changed the double .xlsx.xlsx filename extension of your attachment to just .xlsx .

Let me repeat my first question from above, which you did yet not answer. Does it work when you reference the file explicitly, like say the following?

ExcelTools:-Import("C:/Users/Usman/Desktop/Employees.xlsx", 1,"A1:B101");

By the way, Maple 2015 is not the same as Maple 15. If you're going to mark your Questions with the version you're using then please keep that in mind, thanks.

I changed your last two lines to assign to A and B rather than a and b, since you were already using a[0],a[1], etc, and the collision of names seems unnecessary and not useful.

I suggest simplifying "coefficients" in A after collecting. But I'd agree than collecting (first) wrt y[n] is likely best.

Also, simplifying before applying allvalues seems to save time (and produce a better result perhaps). (The application of allvalues just resolves an inplicit RootOf of a quadratic. I did not look at calling solve with option explicit as possible alternative.)

[edited] I found some simpler forms from my earlier answer. Here's the earlier answer, but now with an example call to radnormal and simplify(..,size) which reduces the size about 8 times smaller than I had before.
 

restart:
P:=a[0]+(a[1]*x)/(1+(a[2]*x)/(1+(a[3]*x))):
Q:=diff(P,x):
T:=diff(P,x,x):
e1:=simplify(eval(P, x=q))=y[n]:
e2:=simplify(eval(Q,x=q))=f[n]:
e3:=simplify(eval(Q,x=q+h))=f[n+1]:
e4:=simplify(eval(T,x=q+h))=g[n+1]:
var:=seq(a[i], i=0..3):
M:=e||(1..4):
Cc:=eval(<var>, solve(eval({M}),{var}) ):
for i from 1 to 4 do
        a[i-1]:=Cc[i]:
end do:

Cf:=P:

# your original
A:=y[n+1]=collect(simplify(eval(Cf, x=q+h)),
                  [y[n],f[n],f[n+1],g[n+1]], recursive):

# your original
B:=map(eval@allvalues, [A]):

length(A),length(B);

110982, 400221

newA:=y[n+1]=collect(expand(eval(Cf, x=q+h)),[y[n]],
                     u->simplify(simplify(u),size)):
length(newA);

12320

newB:=[allvalues(newA)]:
length(newB); nops(newB);

33793

2

newerB:=map(ee->collect(expand(ee),[y[n]],
                        u->simplify(simplify(u),size)),newB):
length(newerB); nops(newerB);

19063

2

newestB:=simplify(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(f[n]-f[n+1]))^2*(h*g[n+1]-8*f[n]+8*f[n+1])*h^3)^(1/2))/((4*h^2*f[n]*g[n+1]^2+16*h*f[n]*f[n+1]*g[n+1]+16*f[n]*f[n+1]^2-16*f[n+1]^3)*q^2+8*h^2*f[n]*g[n+1]*(h*g[n+1]+3*f[n+1])*q+4*h^3*f[n]*g[n+1]*(h*g[n+1]+2*f[n+1]))

1248

 

Download simplif_ex3.mw

And here below are two other approaches.

The first of these next approaches is somewhat similar to what I did above.

The second of these next approaches eliminates only a[1],a[2],a[3] as a first step (as opposed to calling solve for all four variables), and then eliminates a[0] from the restrictions that ensue from the first step. That elimination of a[0] produces the pair of results (that previously came from calling allvalues on the quadratic RootOf). This approach gets a pair of formulas each of length 625, which is half the size of the other approaches results.

So now there are three pairs formulas for y[n+1]. Evaluation at random float values shows agreement (but in one of the pairs the agreement can flip partners).
simpl_alt1.mw

The smallest I see so far (using either length or LeafCount as the metric), is,

collect(EXPR,[Gr,Br],u->simplify(simplify(u),size));

where EXPR is the original (as converted to 1D by Preben). That result has length 2645 , without any assumptions, using Maple 2017.3.

simp_expr.mw

restart:

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

#k=2:
omega:=u/h:
psi:=v/h:
t:=(sum(a[j]*x^j,j=0..2)+a[3]*sin(omega*x)+a[4]*cos(omega*x)+a[5]*sin(psi*x)+a[6]*cos(psi*x)):
F:=diff(t,x):
G:=diff(t,x,x):
p1:=simplify(eval(t,x=q+h))=y[n+1]:
p2:=simplify(eval(F,x=q))=f[n]:
p3:=simplify(eval(F,x=q+h))=f[n+1]:
p4:=simplify(eval(F,x=q+2*h))=f[n+2]:
p5:=simplify(eval(G,x=q))=g[n]:
p6:=simplify(eval(G,x=q+h))=g[n+1]:
p7:=simplify(eval(G,x=q+2*h))=g[n+2]:
vars:= seq(a[i],i=0..6):
Cc:=eval(<vars>, solve({p||(1..7)}, {vars})):
for i from 1 to 7 do
        a[i-1]:=Cc[i]:
end do:
Cf:=t:

K:= collect(combine(simplify(eval(Cf,x=q+2*h),size),trig),{y[n+1],f[n],f[n+1],f[n+2],g[n],g[n+1],g[n+2]},factor):


alpha[1]:=simplify(coeff(K,y[n+1])):
beta[0]:=simplify(coeff(K,f[n]),size):
beta[1]:=simplify(coeff(K,f[n+1]),size):
beta[2]:=simplify(coeff(K,f[n+2]),size):
gamma0:=simplify(coeff(K,g[n]),size):
gamma1:=simplify(coeff(K,g[n+1]),size):
gamma2:=simplify(coeff(K,g[n+2]),size):

H := ee -> collect(numer(ee),[sin],u->simplify(simplify(u),size))/collect(denom(ee),[sin],u->simplify(simplify(u),size)):

newgamma2 := (H@expand)(gamma2);
length(newgamma2);
simplify(expand(gamma2-newgamma2));

((-h^2*v*u*((v^2+8*cos(v)-8)*cos(u)+cos(v)*u^2-u^2-v^2-8*cos(v)+8)*sin(v)-2*h^2*((u^2+2*v^2)*cos(v)-3*cos(u)*v^2-u^2+v^2)*u*(cos(v)-1))*sin(u)-2*h^2*v*(cos(u)-1)*(2*cos(u)*u^2-3*cos(v)*u^2+cos(u)*v^2+u^2-v^2)*sin(v)-h^2*(((4*u^2+4*v^2)*cos(v)^2+((v^2-4)*u^2-4*v^2)*cos(v)-3*u^2*v^2)*cos(u)^2+(((v^2-4)*u^2-4*v^2)*cos(v)^2+4*u^2*v^2*cos(v)+(-v^2+4)*u^2+4*v^2)*cos(u)-3*u^2*v^2*cos(v)^2+((-v^2+4)*u^2+4*v^2)*cos(v)+(2*v^2-4)*u^2-4*v^2))/((4*u*v*(u^2+v^2)*(cos(u)-1)*(cos(v)-1)*sin(v)+4*u^3*v^2*(cos(v)-1)*(cos(v)-cos(u)))*sin(u)-4*u^2*v^3*(cos(u)-1)*(cos(v)-cos(u))*sin(v)+8*u^2*v^2*(cos(u)-1)*(cos(v)-1)*(cos(u)*cos(v)-1))

1081

0

all:=[alpha[1],beta[0],beta[1],beta[2],gamma0,gamma1,gamma2]:
all1:=simplify~(expand~([alpha[1],beta[0],beta[1],beta[2],gamma0,gamma1,gamma2]),size):
all2 := (H@expand)~([alpha[1],beta[0],beta[1],beta[2],gamma0,gamma1,gamma2]):

length~(all);
length~(all1);
length~(all2);

[1, 1945, 1765, 2129, 1941, 2039, 2073]

[1, 1381, 1349, 1429, 1377, 1425, 1441]

[1, 941, 993, 1045, 1033, 977, 1081]

normal(expand~(all-all1));
normal(expand~(all-all2));

[0, 0, 0, 0, 0, 0, 0]

[0, 0, 0, 0, 0, 0, 0]

 

Download simp_ex.mw

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