acer

32385 Reputation

29 Badges

19 years, 336 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Here is one way,

restart;

PMSM_v_eq := V__alphabeta(t) = R__s * i__alphabeta(t)
                               + L__s*diff(i__alphabeta(t), t)
                               + diff(lambda__alphabeta(t), t);

V__alphabeta(t) = R__s*i__alphabeta(t)+L__s*(diff(i__alphabeta(t), t))+diff(lambda__alphabeta(t), t)

eq_desired := lambda__alphabeta(t) = int(V__alphabeta(t) - R__s * i__alphabeta(t), t)
                                     - L__s*i__alphabeta(t);

lambda__alphabeta(t) = int(V__alphabeta(t)-R__s*i__alphabeta(t), t)-L__s*i__alphabeta(t)

with(IntegrationTools):

Combine(value(Expand(dsolve(PMSM_v_eq, {lambda__alphabeta(t)}))));

lambda__alphabeta(t) = int(V__alphabeta(t)-R__s*i__alphabeta(t), t)-L__s*i__alphabeta(t)+_C1

evalindets(%,suffixed(_C),()->0);

lambda__alphabeta(t) = int(V__alphabeta(t)-R__s*i__alphabeta(t), t)-L__s*i__alphabeta(t)

 

Download PMSM_eq_ac.mw

[edit] The following is shorter (only because it avoids having to dispel the constant of integration), but it seems slightly odd (to me) to ignore the dsolve command entirely.

IntegrationTools:-Combine(solve(value(map(int,PMSM_v_eq,t)),
                                {lambda__alphabeta(t)})[]);

It's not clear from your question how you want to treat multiple (or nested) solutions coming out of solve, as your only example is simple. I could guess...

sol:={v[1]=t,v[2]=3/2*t,v[3]=v[3]};

{v[1] = t, v[2] = (3/2)*t, v[3] = v[3]}

subsindets(sol,And(`=`,':-satisfies'(s->(lhs=rhs)(s))),()->NULL);

{v[1] = t, v[2] = (3/2)*t}

Download solve_removal.mw

@coopersj The default behaviour of the 2D Input  ||V||  should match the current context's behaviour of Norm(V) , in the case where neither explicitly specifies a particular norm.

Of course, each should always be available -- if provided explicitly -- so as to clarify the situation if the nature of the worksheet's material and content make the context non-obvious. And so they are. I used command-completion on the word "Norm" whilst in 2D Input mode, to select a specified norm from the popup menu.

restart

with(LinearAlgebra)

V := `<,>`(2, 2, 2)

Vector[column](%id = 18446883978238448574)

LinearAlgebra[Norm](V)

2

LinearAlgebra[Norm](V, 2)

2*3^(1/2)

LinearAlgebra[Norm](V, infinity)

2

restart

with(VectorCalculus)

V := `<,>`(2, 2, 2)

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

LinearAlgebra[Norm](V)

2*3^(1/2)

LinearAlgebra[Norm](V, 2)

2*3^(1/2)

LinearAlgebra[Norm](V, infinity)

2

 

Download norm_LAVC.mw

One way to get the results without the x is to change how you call fsolve, ie.,

f := x^2-x+0.25:

fsolve({f=0}, x=0..1);

     {x = 0.5000000000}, {x = 0.5000000000}

[fsolve(f=0, x=0..1)];                          

         [0.5000000000, 0.5000000000]

Your first question about "storing" the results is unclear. If you assign the last result about to S then you can access each root by indexing, eg,

S := [fsolve(f=0, x=0..1)];

          S := [0.5000000000, 0.5000000000]

S[1];

                  0.5000000000

S[2];

                  0.5000000000

Under the location of my Linux installation of Maple 2020.1 there is a file (relative path):
   bin/Maple2020.png

That is a 1-layer 48x48 pixel RGB color space PNG image, at 72x72 ppi and a print size of 16.93x16.93 mm.

You could try scaling that up in size (after making a copy of the original file).

Of course, the final behavior is up to your twm window manager.

The simplest way to switch the orientation roles is to use the parametric calling sequence of the plot command.

plot([y^2, y, y = -3 .. 3],
     color=blue, thickness=3, title="T1.1 x=y^2 [ECE]",
     view=[-5..5, -5..5]);

I don't care so much for the three choices Tom mentioned. The rotate example involves more typing, a little extra computing, generates a temporary plot as collectible garbage, but is otherwise ok. Solving/inverting the expression analytically for all branches is problematic in general. And implicitplot is inefficient (compared to a direct plot).

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.

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