acer

32358 Reputation

29 Badges

19 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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)

`η__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η` := [seq([Q__gr[i], `η__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η`, 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(radnormal(newerB),size): length(%);

2501

newestB[1]; length(%);

y[n+1] = ((h^2*g[n+1]+4*h*f[n+1]+4*y[n])*(h^2*f[n]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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

Try it under the assumption that x>0 .

restart;

f:=(x,z)->ln(x^z);

                                      / z\
                     f := (x, z) -> ln\x /

simplify(f(x,2)) assuming x>0;

                            2 ln(x)

Now consider a value for x such as -1/3 . Notice that your expected formula doesn't produce the same result.

ln((-1/3)^2), 2*ln(-1/3);

                  -2 ln(3), -2 ln(3) + 2 I Pi

Your Question was, "Can a Data Table be used as an input in a procedure?"

If I understand the question properly, then my Answer is as follows. The name of the unique Array/rtable/Matrix/Vector associated with a particular DataTable can be the argument to a procedure call, as can the unique string identity of a particular DataTable.

Now on to your bullet points, which seem to be more about having an Array associated with a DataTable be returned from a procedure call:

Issue 3)

When your procedure BiPolyNum returns a copy of the Array ary then it is deliberately breaking any connection with the DataTable associated with ary.

Subsequent changes in the DataTable (made manually) will not be accompanied by any changes in the Array returned by BiPolyNum as copy(ary). And vice versa.

So, if you expect the returned Array and the DataTable to be associated, then don't use copy on the return value.

Issue 2)

This is the same as issue 3), except you're not using a procedure. But your copy(ary) is still not going to be associated with the DataTable. A DataTable is associated with only one rtable (Array, say). A copy of that Array won't be associated with the DataTable.

Issue 1)

I'll check whether I can reproduce the lag. You could submit a bug report. I suggest submitting a bug report in which you've inserted the DataTable by hand, via the Components palette, so that it's clear that the issue has nothing to do with the DocumentTools commands.

 

That's not 1D Math output.

It's 2D Math output where the bodies of the operators are showing prefix form rather than infix form.

It's likely that it's related to your use of Units:-Standard , since the rebound arithmetic operators in that package will return calls to the global operators.

It's not clearly a bug. What you're seeing is the bodies of procedures. It's not clear why they *ought* always to pretty-print exactly the same as do plain output expressions. But we might be able to suggest a change to make it happen...

It would make most sense for you to upload an actual Document, which contained all the inputs. (We'd also be able to tell which mnor and major version you're using. There are have been some related changes since Maple 2016.)

You can programmatically insert a new (invisible, so-called) Task Region right after the currently focused Execution Group or Document Block (paragraph). And you can programmatically construct the contents that will go into it.

And that includes contents like Embedded Components such as Math Containers. See the help page for topic,

    DocumentTools,Components,MathContainer

You can also programmatically replace the contents of a previously inserted Task Region.

But an insertion of a new Task Region can only be done from overt code. It cannot be done from within a Button. It can only be inserted below the current Execution Group or Document Block. It cannot be done to some other execution group elsewhere in the sheet.

Part of your description makes it sound like you want "day of the year" to be the independent data and "amount of chemical" to be the dependent data. That makes sense to me, and it's what I show below.

When you write that you want, "day of the year vs amount of chemical" then there may be a confusion in terminology. Usually one talks of plotting dependent quantity vs independent quanity.

restart;

A:=Array([[10,283.2],[21,293.3],[27,294.4],[103,300.7],[211,302.1]]):
M:=Matrix(A);

chem_formula:=13.0+7.0*sqrt(273+temp);
chem_func:=unapply(chem_formula, temp);

M[1..-1,1]; # the day numbers (in the year)

M[1..-1,2]; # the temperatures

map(chem_func, M[1..-1,2]); # the chemical amounts

plot( <M[1..-1,1] | map(chem_func, M[1..-1,2])>,
      view=[1..365, default] );
First 182 183 184 185 186 187 188 Last Page 184 of 336