acer

32363 Reputation

29 Badges

19 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

It's clearly a weakness that simplify(e1,trig) does not gets the compact sec form, while the following does,
   simplify(tan(x+c__1)^2+1,trig);   # returns sec(x+c__1)^2
 

e1:=a/sqrt(tan(x+c__1)^2+1);

a/(tan(x+c__1)^2+1)^(1/2)

evalindets(e1,`+`,simplify,trig);

a/(sec(x+c__1)^2)^(1/2)

Download tan_sec_simplification_june_9_2024_ac.mw


Note: this is not the first time that you've mentioned that you expected simplify(...,size) to get some particular form that required a mathematical transformation outside of that option's documented functionality. See the first bullet point of the Description section of the ?simplify,size Help-page.

Check whether this is the minimization you intended.

restart

with(Optimization); with(plots)

R1 := Jv*(1-x)*d; R2 := Jr*Q2+Ce*(d*y-Q1); R3 := Cm*Q1+I1*Q1a+I2*Q1b+Vr*k

TC := proc (I1, I2, Q2) options operator, arrow; R1+R2+R3 end proc

TC(I1, I2, Q2)

Q1 = Q1a+Q1bQ1a = alpha(I1)*dalpha(I1) = 0.2e-1*exp(.4*I1)Q1b = beta(I2)*dbeta(I2) = 0.2e-1*exp(.3*I2)-0.2e-1

C1 := delta*(Q1a+Q1b)+Q2 >= x*d; C1a := subs([Q1a = alpha(I1)*d, Q1b = beta(I2)*d], C1)

C1b := subs([alpha(I1) = 0.2e-1*exp(.4*I1), beta(I2) = 0.2e-1*exp(.3*I2)-0.2e-1], C1a)

C2a := {k >= alpha(I1)*d+beta(I2)*d, alpha(I1)*d+beta(I2)*d >= rho*k}

C2 := subs([alpha(I1) = 0.02*exp(0.4*I1), beta(I2) = 0.02*exp(0.3*I2) - 0.02], C2a):

C3 := I1 <= I2:

TC1a := subs([Q1 = Q1a+Q1b], TC(I1, I2, Q2))

TC1b := subs([Q1a = alpha(I1)*d, Q1b = beta(I2)*d], TC1a)

TC1c := subs([alpha(I1) = 0.2e-1*exp(.4*I1), beta(I2) = 0.2e-1*exp(.3*I2)-0.2e-1], TC1b)

DATA := [Jv = 2.8, Jr = 3.15, d = 2*10^9, h = 35, k = 2*10^8, delta = .5, rho = .6, y = .6, x = .25, Ce = 1.5, Cm = 1, Vr = 0.15e-3]

TRC := unapply(eval(TC1c, DATA), I1, I2, Q2):

s := Minimize(TRC(I1, I2, Q2), {C1b, C3} union C2, I1 = 0 .. 5, I2 = 0 .. 7, assume = nonnegative);

[5979250877.72649193, [I1 = HFloat(0.0), I2 = HFloat(0.25474549280535297), Q2 = HFloat(0.0), d = HFloat(0.29837235850951205), delta = HFloat(1.0629016402605893), k = HFloat(0.08025849756859023), rho = HFloat(0.08025792480959956), x = HFloat(0.022571008132838303)]]

plot3d(TRC(I1, I2, eval(Q2, s[2])), I1 = 0 .. 5, I2 = 0 .. 7,
       orientation=[165, 75, 0]);

display(
  plot3d(TRC(I1, I2, eval(Q2, s[2])), I1 = 0 .. 0.1, I2 = 0 .. 1,
         color=cyan),
  pointplot3d([eval([I1,I2,TRC(I1,I2,Q2)],s[2])],symbolsize=30,
              color=red,symbol=solidcircle,orientation=[165,75,0]));


Download Updated_model_ac.mw

Your updated model attempt had several mistakes (syntax, spelling, etc).

Here is what I get,

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Linux, March 01 2024 Build ID 1794891`

A:=Matrix(1,0);

A := Matrix(1, 0, {})

print("My matrix is =",A);

"My matrix is =", Matrix(1, 0, {})

lprint("My matrix is =",A);

"My matrix is =", Matrix(1,0,{},datatype = anything,storage = rectangular,order
= Fortran_order,shape = [])


Download why_print_empty_june_7_2024_ac.mw

I am running with this setting:

   interface(typesetting);    # standard

That is the default for a wholly fresh installation of Maple 2024.0 on Linux (with no older preferences imported).

That corresponds to the GUI Tools->Options->Display setting,
    Typesetting level   :   Extended
whereas you show that above as being,
    Typesetting level   :   Maple Standard

If I changed the interface setting (by interface command or by GUI Options menu) from extended to standard then I do get a blank output for the relevant line.

When that happens, I also get some Java error messages in the shell from which I launched the GUI. The beginning of that indicates that it has run amok of the Matrix with a dimension being zero.

While there were GUI changes for Maple 2024.0 related to the new Scrollable Matrices feature, I was unable to work around it for your example by disabling the effect of that new GUI feature. However I don't see the issue in my Maple 2023.2.

Here is one way, which shows it as 2D Math.

You can also put unassigned parameter names into a InertForms:-Display call, and then substitute numeric values for those (using `eval`, or `subs`) after computing such.

plots:-textplot([2,0.9,
                 InertForm:-Display(W__LJ=0.75 %+ 0.98 %* ((1.18/Gamma)%^1.9-(1.15/Gamma)%^0.98),'inert'=false)],
                 'font'=["helvetica","roman",15],
                 size=[600,300]);


Download inertform_textplot.mw

You could instead use,

   patmatch(stat,`^`(0,a::anything))

This is to avoid your  0^(a::anything) becoming zero during your call.

restart;

stat:=0^n:

foo:=proc(stat)
  local a;
  if  patmatch(stat,`^`(0,a::anything)) then
     0;
  else
     stat;
  fi;
end proc:

foo(stat);

0


Download nm_zero_power_proc.mw

For your original, I see these arguments being passed to patmatch. Note that the second  argument received is just 0.

restart;

stat:=0^n:

foo:=proc(stat)
  local a;
  if  patmatch(stat,0^a::anything) then
     0;
  else
     stat;
  fi;
end proc:

trace(patmatch):

foo(stat);

{--> enter patmatch, args = 0^n, 0

false

<-- exit patmatch (now in foo) = false}

0^n


Download nm_zero_power_orig.mw

With the prefix form given above, trace shows that patmatch receives,
    0^n, 0^a::anything

 

There appear to be some inconsistencies (not affecting your given example, however) which I'll report.
hm_zero_power.mw

Here's one way.

restart;

e1:=-sqrt(-(exp(-2 + 2*x) - 2)*exp(-2 + 2*x))/(exp(-2 + 2*x) - 2);

-(-(exp(-2+2*x)-2)*exp(-2+2*x))^(1/2)/(exp(-2+2*x)-2)

convert(simplify(combine(simplify(convert(e1,trig)))),exp) assuming real;

1/(2*exp(-2*x+2)-1)^(1/2)

sort(%);

1/(2*exp(-2*x+2)-1)^(1/2)


Download nm_simp_exp0.mw

The sort call is there only because, depending on what's gone on earlier in the session, the subexpresssion in the final result can appear as,
      -1 + 2*exp(-2*x + 2)
instead of,
       2*exp(-2*x + 2) - 1
and you may have an aesthetic preference. This happens for me if I merely define e2 as you have it, before proceeding.

I presume you have some way to elect whether you accept this or not for other examples where it doesn't improve things.

Your given example can be handled by either of the following two ways,

C:={a=1/sqrt(2+A),b=6*sqrt(4+N) ,c=sqrt(7),d=5*H,e=-12,f=-96}:

selectremove(u->not type(rhs(u),constant), C);

   {a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), d = 5*H},
   {c = 7^(1/2), e = -12, f = -96}

selectremove(u->indets(rhs(u),name)<>{}, C);

   {a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), d = 5*H},
   {c = 7^(1/2), e = -12, f = -96

That first way can also be entered with a terser syntax for the type-check,

    selectremove(u->not rhs(u)::constant, C);

And if you just need the first of that returned pair of sets,

    remove(u->rhs(u)::constant, C);

For that second way (in the gray box) I just used a custom operator as the first argument, in a two argument call to selectremove. The first argument doesn't need to be the name of some stock command, and you don't always need to pass in extra aguments to it.

However, for that second way, in general you might want to guard against some special cases, and be more picky about which kinds of name matter.

For example, Pi is of type name but you might want to exclude it from the names that matter.

And if you have Int(4,t=0..1) and that name t acting as the variable of integration doesn't appear anywhere else then you might not want it to count. (I know, it's a contrived example.) The point is that you might want to consider only names upon which the rhs depends.

These aspects might not matter to you here, but in practice they crop up quite often when trying to extract variable names from expressions. 

C:={a=1/sqrt(2+A),b=6*sqrt(4+N) ,c=sqrt(7),d=5*H,e=-12,f=-96}

{a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), c = 7^(1/2), d = 5*H, e = -12, f = -96}

selectremove(u->indets(rhs(u),
                       And(name,Not(constant),
                           satisfies(nm->depends(rhs(u),nm))))<>{}, C);

{a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), d = 5*H}, {c = 7^(1/2), e = -12, f = -96}


Download 2024-06-05_Q_Select_Remove_indet_elements_ac.mw

note: You might well find shorter syntax. Look for code that you could understand later on your own (provided it's reasonably efficient), over code that is less natural to you (no matter how terse).

You could try using

    max( lowvalue, min( maxvalue,  expr ) )

around the expression, and then using,

   view = [ lowvalue+eps .. maxvalue+eps ]

for some relatively small eps.

Those view particulars prevent any extra flat portions induced by this approach from appearing. But the max/min allow the colorscheme to use your specified boundaries for the extremes of the zgradient. Hence the color gradient is created and applied only for the targeted range.

An alternative is to use valuesplit instead of zgradient in the colorscheme. That allows to you to target your desired shading for just a range that matches your specified view. (Ie. you write the splitting values to make them match.) This seems to be the approach that you mentioned avoiding.

I prefer the first method because sometimes when there is a huge variation the GUI has weird flashing as the 3d plot is manually rotated. Getting rid of the huge (pos/neg) extremes fixes that for me. Also, the max/min approach can work better with a colorbar. It gets rid of the extreme values altogether. The valuesplit is not so helpful for these aspects.

You'd normally need an inert representation in some way, or else the result will evaluate right back to your complex number.

For example, (sorry, the site's not rendering the worksheet quite properly),

restart;

 

P := z -> abs(z)*%exp(I*argument(z)):

 

P(-1);

%exp(I*Pi)

value(%);

-1

ans := P(1-I);

2^(1/2)*%exp(-((1/4)*I)*Pi)

simplify(value(ans));

1-I

InertForm:-Display(ans,inert=false);

sqrt(2)*%exp(-(1/4*I)*Pi)


Download inert_exp.mw

The Kr value is the subscript, in the legend items.

This uses the same color for a given Kr value, and the same linestyle for a given function (from f,Theta,Phi).

animation_of_ode_ac.mw

For your second example, here is one way,

restart;

kernelopts(version);

`Maple 2024.0, X86 64 LINUX, Mar 01 2024, Build ID 1794891`

e := -1/2*(-2*x*sqrt(4*x^2 + 1) + (16*x^3*sinh(3/2*arcsinh(2*x)) - 8*x^2*cosh(3/2*arcsinh(2*x))*sqrt(4*x^2 + 1) + 4*sinh(3/2*arcsinh(2*x))*x - cosh(3/2*arcsinh(2*x))*sqrt(4*x^2 + 1))*sqrt(-2 + 2*sqrt(4*x^2 + 1)))/sqrt(4*x^2 + 1);

-(1/2)*(-2*x*(4*x^2+1)^(1/2)+(16*x^3*sinh((3/2)*arcsinh(2*x))-8*x^2*cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2)+4*sinh((3/2)*arcsinh(2*x))*x-cosh((3/2)*arcsinh(2*x))*(4*x^2+1)^(1/2))*(-2+2*(4*x^2+1)^(1/2))^(1/2))/(4*x^2+1)^(1/2)

simplify(evala(convert(e,arctan))) assuming x<0;

0


Download nm_simp_exh.mw
 

Also, for x>0,

combine(evala(simplify(convert(e,arctan)))) assuming x>0;

2*x


Of course, there may well be shorter alternatives.

You have,

   xM2 = rhs(sol2[1]);
   yM2 = rhs(sol2[2]);
   xM3 = rhs(sol3[1]);
   yM3 = rhs(sol3[2]);

which are not assignments. Those are just equations.

Change = to := and it works.

You don't need the assume call.

JAMET_2.mw

I've deliberately done this in stages, for a little more clarity.

The idea is to replace a subexpression of the form Int(Sum(...)) with Sum(Int(...)), i.e. bring the integration inside the sum.

restart:

with(IntegrationTools):

NULL

eq1:=int(1-(sum(p[i]*(1-exp(-((t-xi)/tau[i]))),i=1..n)),xi=0..t);

int(1-(sum(p[i]*(1-exp(-(t-xi)/tau[i])), i = 1 .. n)), xi = 0 .. t)

temp := IntegrationTools:-Expand(eq1);

t-(sum(p[i], i = 1 .. n))*t+int(sum(p[i]*exp(xi/tau[i])/exp(t/tau[i]), i = 1 .. n), xi = 0 .. t)

temp := subsindets(temp, specfunc({specfunc(sum),name=range},int),
                   u->Sum(Int(op([1,1],u),op(2,u)),op([1,2],u)));

t-(sum(p[i], i = 1 .. n))*t+Sum(Int(p[i]*exp(xi/tau[i])/exp(t/tau[i]), xi = 0 .. t), i = 1 .. n)

simplify(temp);

t-(sum(p[i], i = 1 .. n))*t+Sum(p[i]*(Int(exp((-t+xi)/tau[i]), xi = 0 .. t)), i = 1 .. n)

value(%);

t-(sum(p[i], i = 1 .. n))*t+sum(p[i]*(-tau[i]*exp(-t/tau[i])+tau[i]), i = 1 .. n)

simplify(combine(%));

-(sum(p[i]*(tau[i]*exp(-t/tau[i])+t-tau[i]), i = 1 .. n))+t


Download 1111_ac.mw

@Dkunb You could examine the results from, say,

   collect(combine(convert(eq13,trig)),[sin,cos],simplify)

which could also be done with, say, assuming n::even,m::odd etc.

In such a case I don't know whether you'd prefer the collecting of terms by real/imaginary (ie. factor of I) or by sin/cos arguments, or by denominator factors.

The command log (with no index supplied, ie. no base specified) is the same in Maple as the command ln, i.e. the logarithm with respect to the default base e=exp(1), ie. the natural logarithm.

log(0.5/1.65)
                          -1.193922469

ln(0.5/1.65)
                          -1.193922469

log[exp(1)](0.5/1.65)
                          -1.193922469

log10(0.5/1.65)
                         -0.5185139399

log[10](0.5/1.65)
                         -0.5185139399

See also the second paragraph here.

This is also described on the Maple Help-page viewed by executing  ?log .

First 20 21 22 23 24 25 26 Last Page 22 of 336