acer

32328 Reputation

29 Badges

19 years, 318 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Try closing the context-panel, by which I mean the right-hand window in which context menu operations appear.

The problem may be the so-called smart-popup operations (a plot, etc) that appear at the top of that right-hand panel.

 

You have `u` as an expression in `y`, but then you call it like u(y) inside diff(u(y),y) as if it were an operator.

That's a mismatch.

Either differentiate like diff(u,y) or make `u` an operator/procedure of one parameter, eg. u:=u->expression_in_y .

But don't change both, or they'll still be mismatched.

Here is one way, a short edit from your code,

restart;

expr := exp(x)^3*sin(x)+3/(exp(x)^n):

subsindets(expr,'exp(anything)^anything',
           f->combine(f,exp,symbolic)):

       exp(3*x)*sin(x)+3/exp(x*n)

By the way, the "problem" was not that the exp call was in the denominator. The difference was the name n as outer power.

expr:=exp(x)^3*sin(x)+3/(exp(x)^3);

(exp(x))^3*sin(x)+3/(exp(x))^3

subsindets(expr,'exp(anything)^anything',f->simplify(f,exp));

exp(3*x)*sin(x)+3*exp(-3*x)

expr:=exp(x)^n*sin(x)+3/(exp(x)^n);

(exp(x))^n*sin(x)+3/(exp(x))^n

subsindets(expr,'exp(anything)^anything',f->simplify(f,exp));

(exp(x))^n*sin(x)+3/(exp(x))^n

subsindets(expr,'exp(anything)^anything',f->combine(f,exp,symbolic));

exp(x*n)*sin(x)+3/exp(x*n)

Download exp_comb.mw

[edit] I am supposing that you know that the identity is not true for all complex values of the parameters. However you might have had the following in mind,

subsindets(expr,'exp(anything)^anything',
           f->combine(f,exp)) assuming x::real;

       exp(x*n)*sin(x)+3/exp(x*n)

The location of the preferences file is platform specific, and you haven't mentioned your platform.

You can set the preference for input mode in the main menu, from item,
   Tools->Options->Display
and toggle the combo-box "Input Display" to "Maple Notation".

You can set the default for new sheets to Worksheet  in the main menu, from item,
   Tools->Options->Interface
and toggle the combo-box "Default format for new worksheets" to "Worksheet".

If you then click the "Apply Globally" button in the preferences popup then it should write out and save those values in the preferences file.


restart

f := 9.765625000*10^(-6)*(-6671.221362*(x^2+2)^5*sqrt(2)*arctan((1/2)*x*sqrt(2))*x-555.9351135*(x^2+2)^6/((1/2)*x^2+1)-10479.13001*(x^2+2)^5*sqrt(2)*x-(374220*(0.297116730e-1*x^9+.269385824*x^7+.99643086*x^5+5.18951288*x^3+4.42867382*x))*x-1111.870227*x^10-12601.19538*x^8-62147.39274*x^6-485504.8775*x^4-828649.1585*x^2-788850.2769)/(x^2+2)^6-(0.1171875000e-3*(-555.9351135*(x^2+2)^6*sqrt(2)*arctan((1/2)*x*sqrt(2))-873.2608343*(x^2+2)^6*sqrt(2)-(374220*(0.29711673e-2*x^10+0.33673228e-1*x^8+.16607181*x^6+1.29737822*x^4+2.21433691*x^2+2.107985348))*x))*x/(x^2+2)^7+(3.484800000*sqrt(2)*(x^2+2)*arctan((1/2)*x*sqrt(2))*x+.8712000000*(x^2+2)^2/((1/2)*x^2+1)+(5.473911040*(x^2+2))*sqrt(2)*x+5.227200000*x^2-22.99200001)/(16*(x^2+2)^2)-(.8712000000*sqrt(2)*(x^2+2)^2*arctan((1/2)*x*sqrt(2))+1.368477760*sqrt(2)*(x^2+2)^2-36*x*(-0.484000000e-1*x^2+.638666667))*x/(4*(x^2+2)^3)

Digits := 15

15

ip := select(type, [solve(f = 0, x)], realcons)

[.654041130071197, -.654041130089551, -6252.01029859155]

[fsolve(numer(f) = 0, x = -10000 .. 1, maxsols = 4)]

[-6252.01031084807, -.654041130089551, .654041130071197]

[fsolve(f = 0, x = -10000 .. 1, maxsols = 4)]

[-6252.01029859155, -.654041130089551, .654041130071197]

plot(numer(f), x = -1 .. 1, size = [400, 200])

plot(numer(f), x = -6500 .. 1, size = [400, 200])

plot(f, x = -1 .. 1, size = [400, 200])

plot(f, x = -7000 .. -5000, size = [400, 200])

 

Download help_fsolve_real_root_acc.mw

Perhaps the question is asking for something like the following (where the flow units will be in m^3/s).

(If you are being asked a homework question on the trapezoidal and midpoint methods then will you not have covered those in lectures?)

restart;

d := x -> x*(10-x)/25;

proc (x) options operator, arrow; (1/25)*x*(10-x) end proc

v := x -> x*(10-x)/100;

proc (x) options operator, arrow; (1/100)*x*(10-x) end proc

ig := x -> d(x)*v(x);

proc (x) options operator, arrow; d(x)*v(x) end proc

exact := int(ig(x), x=0..10);

4/3

evalf(%);

1.333333333

# Compound trapezoidal rule, written explicitly
  (2.5 - 0)*( ig(0) + ig(2.5) )/2
+ (5 - 2.5)*( ig(2.5) + ig(5) )/2
+ (7.5 - 5)*( ig(5) + ig(7.5) )/2
+ (10 - 7.5)*( ig(7.5) + ig(10) )/2;

1.328125000

# Compound trapezoidal rule, as formula
h := (10 - 0)/4:
evalf( h * ( ig(0)
             + add( ig(0 + i*h), i=1..3)
             + ig(10) ) );

1.328125000

abs(exact - %);

0.5208333e-2

# Compound midpoint rule, written explicitly
 (2.5 - 0)*( ig((0 + 2.5)/2) )
+ (5 - 2.5)*( ig((2.5 + 5)/2) )
+ (7.5 - 5)*( ig((5 + 7.5)/2) )
+ (10 - 7.5)*( ig((7.5 + 10)/2) );

1.337890625

# Compound midpoint rule, as formula
h := (10 - 0)/4:
evalf( h * add( ig( h*(2*i - 1)/2 ), i=1..4) );

1.337890625

abs(exact - %);

0.4557292e-2

 

Download trmdpt.mw

It seems that you have avoided reading the Maple help pages for LinearAlgebra.

(check for mistakes)

restart;

A := <<1,1>|<1,0>>;

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 1, (2, 2) = 0})

(u,w) := <1,0>, <1,2>;

u, w := Vector(2, {(1) = 1, (2) = 0}), Vector(2, {(1) = 1, (2) = 2})

2*u+w;

Vector(2, {(1) = 3, (2) = 2})

A^3;

Matrix(2, 2, {(1, 1) = 3, (1, 2) = 2, (2, 1) = 2, (2, 2) = 1})

A^(-1);

Matrix(2, 2, {(1, 1) = 0, (1, 2) = 1, (2, 1) = 1, (2, 2) = -1})

with(LinearAlgebra):

Determinant(A);

-1

CharacteristicPolynomial(A,z);

z^2-z-1

x=LinearSolve(A,u);

x = (Vector(2, {(1) = 0, (2) = 1}))

x=LinearSolve(A,w);

x = (Vector(2, {(1) = 2, (2) = -1}))

 

v[1] := <1,0>;

Vector(2, {(1) = 1, (2) = 0})

for i from 2 to 10 do
  v[i] := A.v[i-1];
end do;

Vector(2, {(1) = 1, (2) = 1})

Vector(2, {(1) = 2, (2) = 1})

Vector(2, {(1) = 3, (2) = 2})

Vector(2, {(1) = 5, (2) = 3})

Vector(2, {(1) = 8, (2) = 5})

Vector(2, {(1) = 13, (2) = 8})

Vector(2, {(1) = 21, (2) = 13})

Vector(2, {(1) = 34, (2) = 21})

Vector[column](%id = 18446883841807642006)

seq(seq(v[i][j],j=2..1,-1),i=1..10);

0, 1, 1, 1, 1, 2, 2, 3, 3, 5, 5, 8, 8, 13, 13, 21, 21, 34, 34, 55

[seq(v[i][1],i=1..10)];

[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

[seq(combinat[fibonacci](n), n=1..10)];

[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

 

Download lahw.mw

There is no such command, RTABLE.

The name RTABLE is a protected name, and is utilized as an inert function call for printing purposes. For example, the procedure `print/rtable` uses such calls for formatting, in a way that the GUI understands and deals with. Printing rtables (Matrix,Array,Vector) has some special situations.

This is undocumented, and I am hard pressed to imagine a good reason why anyone would want to display using such calls. Your remarks about "messing up the order of things like sums" is pretty opaque.

Relying on undocumented behavior for complicated, customized display effects is a bad idea.

I am wary of the methodology that the local proc may return expressions with an unknown number or escaped locals -- possibly without pattern in their naming, but it's difficult to judge without knowing full details. On the surface it sounds like a programming mistake. I would prefer to utilize `tools/genglobal` to produce a new unassigned global name safely than to escape a local (which is poor practice).

In examples such as for your new edit, with alpha as the dummy variable of integration, assumptions during subsequent computation would more usually be placed on x the name appearing in the limit of integration.

Your question is not about simplify (or even assuming) per se. It is about programmatic access to (and use of) the names appearing in the expression returned from the procedure. It is about handling escaped locals programmatically -- or, IMO, whether it would better practice to use a better approach that does not return escaped locals.

restart;

getdeps:=proc(ee)
local nm;
  [indets(ee,And(name,Not(:-constant),
                  ':-satisfies'(nm->depends(ee,nm))))[]];
end proc:

getnondeps:=proc(ee)
local nm;
  [indets(ee,And(name,Not(:-constant),
                 Not(':-satisfies'(nm->depends(ee,nm)))))[]];
end proc:

foo:=proc(x)
local int_result,alpha;
local integrand:=1/ln(x^2+1);

int_result:= int(integrand,x);
if has(int_result,'int') then  #did not integrate
   int_result:=Int(subs(x=alpha,integrand),alpha=0..x);
fi;

  return int_result;
end proc:

int_result:=foo(x);

Int(1/ln(alpha^2+1), alpha = 0 .. x)

getdeps(int_result);

[x]

getnondeps(int_result);

[alpha]

 

Download deps.mw

You can easily programmatically generate conditions from the dependent (or independent) variable names, and use those in a call to simplify (or other command) under `assuming`. That's generally quite straightforward, once you have lists of such names with which to further program.

I will repeat that I think it is poor practice to return escaped locals from a procedure. The fact that they are subsequently awkward to deal with programmatically is just one reason that it's poor. Instead, I suggest passing in a global name of your own choice or generating new (safely non-assigned) global names using `tools/genglobal` and a base name of your own choice. I realize that `tools/genglobal` is undocumented, but its usage it simple. It exists because it is used by Library routines quite a bit. It serves a rather frequently occurring programmatic purpose. I used it as a key part of an Answer to your Question of 07/07/2020 and another Question of 19/09/2020, both of which have similarities in vein to this thread.

Here is something, numerically,

restart;

f := x^4*sin(x^2 + y^3)^2*ln(y) + 2*y*x:

fx := diff(f,x);

4*x^3*sin(y^3+x^2)^2*ln(y)+4*x^5*sin(y^3+x^2)*ln(y)*cos(y^3+x^2)+2*y

fy := diff(f,y);

6*x^4*sin(y^3+x^2)*ln(y)*y^2*cos(y^3+x^2)+x^4*sin(y^3+x^2)^2/y+2*x

H := Int(sqrt(fx^2 + fy^2 + 1), [x = 0 .. 4, y = 1 .. 5]):

evalf[6](evalf[15](Int(op(H),epsilon=1e-6,method=_CubaCuhre)));

21351.1

evalf[6](evalf[15](Int(op(H),epsilon=1e-5,method=_CubaDivonne)));

21351.1

 

Download cuba_surfint.mw

Here is one way to generate it as a list of column Vectors. (I haven't looked at whether it is an efficient way, or whether it scales up well, etc. I suspect that it may be wasteful in terms of producing unnecessary collectible garbage.)

Also, do you really need all of them at once (like this), rather than comptuing with them one at a time?

restart;

kernelopts(version);

`Maple 17.02, X86 64 LINUX, Sep 5 2013, Build ID 872941`

with(StringTools):

(parse~@Vector@Explode)~(Generate(3,"012"));

[Vector(3, {(1) = 0, (2) = 0, (3) = 0}), Vector(3, {(1) = 0, (2) = 0, (3) = 1}), Vector(3, {(1) = 0, (2) = 0, (3) = 2}), Vector(3, {(1) = 0, (2) = 1, (3) = 0}), Vector(3, {(1) = 0, (2) = 1, (3) = 1}), Vector(3, {(1) = 0, (2) = 1, (3) = 2}), Vector(3, {(1) = 0, (2) = 2, (3) = 0}), Vector(3, {(1) = 0, (2) = 2, (3) = 1}), Vector(3, {(1) = 0, (2) = 2, (3) = 2}), Vector(3, {(1) = 1, (2) = 0, (3) = 0}), Vector(3, {(1) = 1, (2) = 0, (3) = 1}), Vector(3, {(1) = 1, (2) = 0, (3) = 2}), Vector(3, {(1) = 1, (2) = 1, (3) = 0}), Vector(3, {(1) = 1, (2) = 1, (3) = 1}), Vector(3, {(1) = 1, (2) = 1, (3) = 2}), Vector(3, {(1) = 1, (2) = 2, (3) = 0}), Vector(3, {(1) = 1, (2) = 2, (3) = 1}), Vector(3, {(1) = 1, (2) = 2, (3) = 2}), Vector(3, {(1) = 2, (2) = 0, (3) = 0}), Vector(3, {(1) = 2, (2) = 0, (3) = 1}), Vector(3, {(1) = 2, (2) = 0, (3) = 2}), Vector(3, {(1) = 2, (2) = 1, (3) = 0}), Vector(3, {(1) = 2, (2) = 1, (3) = 1}), Vector(3, {(1) = 2, (2) = 1, (3) = 2}), Vector(3, {(1) = 2, (2) = 2, (3) = 0}), Vector(3, {(1) = 2, (2) = 2, (3) = 1}), Vector(3, {(1) = 2, (2) = 2, (3) = 2})]

 

Download vecsplode.mw

restart;
ee:=Int(x^x,x=0..1);

Int(x^x, x = 0 .. 1)

evalf(ee);

.7834305107

subs(x^x=exp(x*ln(x)),ee);

Int(exp(x*ln(x)), x = 0 .. 1)

temp1:=convert(%,Sum);

Int(Sum((x*ln(x))^_k1/factorial(_k1), _k1 = 0 .. infinity), x = 0 .. 1)

svar:=lhs(op([1,2],temp1));

_k1

Sum(Int(op([1,1],temp1),op([2],temp1)),op([1,2],temp1));

Sum(Int((x*ln(x))^_k1/factorial(_k1), x = 0 .. 1), _k1 = 0 .. infinity)

subsop(1=IntegrationTools:-Change(op([1],%),u=-ln(x),u),%);

Sum(Int((-1)^_k1*exp(-u*(_k1+1))*u^_k1/factorial(_k1), u = 0 .. infinity), _k1 = 0 .. infinity)

temp2:=simplify(eval(%,Int=int)) assuming svar::nonnegint;

Sum((-1)^_k1*(_k1+1)^(-_k1-1), _k1 = 0 .. infinity)

ans:=subs(svar=n,Sum(eval(op(1,temp2),svar=svar-1),svar=map(`+`,rhs(op(2,temp2)),1)));

Sum((-1)^(n-1)*n^(-n), n = 1 .. infinity)

evalf(ans);

.7834305107

 

Download funintegral.mw

vv mentioned doing it by hand. The only heavy lifting in the above is in the evaluation of the integral (inside the sum) following the call to Change. One could recognize a GAMMA call for that -- followed by cancellation of the factorial terms.

Try specifying the labels with the option as,

  labels = [:-D[m1], c]

or,

  labels = [`#msub(mi("D"),mi("m1"))`, c]

or (if you prefer the font in upright Roman),

  labels = [`#msub(mtext("D"),mtext("m1"))`, c]

labels_glob.mw

 

You can specify a predicate which does a table lookup on the entries.

Using a key (to specify the quality to compare) should be more efficient, which could matter if you have many items to sort.

Listsort_ac.mw

You get the comparison of strings automatically. Hence the only thing you needed to add is supplying a comparison that did the table lookup of the quality by which you wished to sort.

evalb("Concrete" < "Timber");

                true

materiallist[1]["material"], materiallist[2]["material"];

           "Timber", "Steel"

evalb(materiallist[1]["material"] < materiallist[2]["material"]);

               false

Have a look at these references, which mention difficulties for the floating-point computation:

  wikipedia

  Matlab help

The first of those also points at the Schur decomposition (see also SchurForm in Maple).

First 105 106 107 108 109 110 111 Last Page 107 of 336