acer

32697 Reputation

29 Badges

20 years, 78 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Even in old Maple 17 the Help pages for radsimp states, "The original radsimp has been removed and replaced by a wrapper to simplify(...,radical,symbolic)."

If you don't want to operate under assumptions about the signum of the squared term under the radical then don't use the symbolic option (or radsimp).

restart;

kernelopts(version);

`Maple 17.01, X86 64 LINUX, Jun 25 2013, Build ID 849430`

m := M-M^2/(2*R)+Q^2/(2*R);

M-(1/2)*M^2/R+(1/2)*Q^2/R

temp := subs(M=4*Pi*R^2*sigma,Q=4*Pi*R^2*sigmae,sigmae=beta*sigma,m-sqrt(m^2-Q^2));

4*Pi*R^2*sigma-8*Pi^2*R^3*sigma^2+8*Pi^2*R^3*beta^2*sigma^2-(-16*Pi^2*R^4*beta^2*sigma^2+(8*Pi^2*R^3*beta^2*sigma^2-8*Pi^2*R^3*sigma^2+4*Pi*R^2*sigma)^2)^(1/2)

new := subs(beta=0,temp);

4*Pi*R^2*sigma-8*Pi^2*R^3*sigma^2-((-8*Pi^2*R^3*sigma^2+4*Pi*R^2*sigma)^2)^(1/2)

radsimp(new);

-16*Pi^2*R^3*sigma^2+8*Pi*R^2*sigma

simplify(new,radical,symbolic);

-16*Pi^2*R^3*sigma^2+8*Pi*R^2*sigma

simplify(new,radical);
factor(%);

4*Pi*R^2*sigma-8*Pi^2*R^3*sigma^2-4*Pi*(R^4*sigma^2*(2*Pi*R*sigma-1)^2)^(1/2)

-4*Pi*(2*Pi*R^3*sigma^2-R^2*sigma+(R^4*sigma^2*(2*Pi*R*sigma-1)^2)^(1/2))

radnormal(new);

-4*Pi*(2*Pi*R^3*sigma^2-R^2*sigma+(R^4*sigma^2*(2*Pi*R*sigma-1)^2)^(1/2))

 

Download radsimp_example.mw

You are using Maple 18 (and not Maple 2018 as your Question's header was incorrectly marked by you). That is why Tom's earlier suggestion did not work for you. I have corrected the Question's header.

Please don't submit duplicates queries for this problem. Post your followups here.

(You should also figure out how to search Mapleprimes -- since I suspect that previous students of your course/supervisor have been tasked with very similar examples and asked here before.)

You can change the name of the color palette (assigned at the top of this attachment). There are a few other choices. (Perhaps see here too.)

 

restart;

with(plots):

palette := "Spring"; # "Dalton" "Niagara"

#

# Define the ODE system

#

  odeSys:= { (diff(F(eta), eta, eta, eta))*(1+epsilon-alpha((diff(F(eta), eta, eta))^2))+F(eta)*(diff(F(eta), eta, eta))+S*(diff(F(eta), eta))-(1/2)*S*eta*(diff(F(eta), eta, eta))-(diff(F(eta), eta))^2-M*(diff(F(eta), eta)), (diff(theta(eta), eta, eta))*(1+R)-delta*(diff(F(eta), eta))^2-Pr((3/2)*S*theta(eta)+(1/2)*S*eta*(diff(theta(eta), eta))-2*(diff(F(eta), eta))*theta(eta)+F*(diff(theta(eta), eta)))}:

#

# Define the first set of boundary conditions

#

  bcs1:= { F(0) = 0, (D(F))(0) = 1, (D(F))(inf) = 0, theta(0) = 1, theta(inf) = 0

         }:

 

  RVals:=[0.1, 0.5, 1]:

  for k from 1 by 1 to numelems(RVals) do

      pList:=[ epsilon = 0.18, M = 0.5, S = 1.5, delta = 0.3, Pr = 1.5, alpha = 0.4, R = RVals[k],inf=1]:

      sol1[k]:= dsolve( eval

                        ( `union`( odeSys, bcs1),

                           pList

                        ),

                        numeric

                      );

    od:
  display
  ( [ seq
      ( odeplot
        ( sol1[i],
          [eta, theta(eta)],
          eta=0..2,
          color=cat(palette," ",i)
        ),
        i=1..numelems(RVals)
      )
    ],
    title = typeset( theta(eta), " versus ", eta),
    titlefont = [times, bold, 20]
  );

"Spring"

Warning, right boundary of range exceeds domain of the problem, it has been adjusted

Warning, right boundary of range exceeds domain of the problem, it has been adjusted

Warning, right boundary of range exceeds domain of the problem, it has been adjusted

 

 p1:= display
      ( [ seq
          ( odeplot
            ( sol1[i],
              [eta, theta(eta)],
              eta=0..1,
              color=cat(palette," ",i)
            ),
            i=1..numelems(RVals)
          )
        ],
        title = typeset( theta(eta), " versus ", eta),
        titlefont = [times, bold, 20]
     ):

 p2:= display
      ( [ seq
          ( odeplot
            ( sol1[i],
              [eta, diff(theta(eta), eta)],
              eta=0..1,
              color=cat(palette," ",i)
            ),
            i=1..numelems(RVals)
          )
        ],
        title = typeset( diff(theta(eta),eta), " versus ", eta),
        titlefont = [times, bold, 20],
        linestyle=solid
     ):

display([p1,p2], title=typeset( theta(eta), " and ", diff(theta(eta),eta), " versus ", eta));

 

NULL

Download lines_ac.mw

 

You can augment the ODE system with a new differential equation involving g(t) such that g(1) equals the integral of Y0 from 0 to 1. For example, diff(g(t),t)=y0(t) and initial condition g(0)=0.

For example,

restart;
ICs := {y0(0)=3}:
ODESys := {diff(y0(t),t)=y0(t)}:
F := dsolve(ODESys union ICs union {diff(g(t),t)=y0(t), g(0)=0},
            {y0(t),g(t)}, numeric, output=listprocedure):

G := eval(g(t),F):

G(1);
            5.15484531216027

Or you can numerically integrate a Y0 procedure using evalf(Int(....)). For example,

restart;
ICs := {y0(0)=3}:
ODESys := {diff(y0(t),t)=y0(t)}:
F := dsolve(ODESys union ICs,
            {y0(t)}, numeric, output=listprocedure):

Y0 := eval(y0(t),F):

evalf(Int(Y0(t),t=0..1));
            5.15484514547602

I believe that using the augmented ODE system is more often somewhat better (numerically speaking) than numerically integrating the result procedure.

You don't have to use the listprocedure option, however (though I prefer it). There are other valid alternatives for picking off y0(t).

You could also do it with just a slight modification of your original code, using operator-form for the integrand and a floating-point end-point for the range of integration. (I consider this way of picking off the Y0 procedure to be fragile and inferior, and I also prefer my earlier syntax and methodology for the numeric integration.) For example,

restart;
ICs := {y0(0)=3}:
ODESys := {diff(y0(t),t)=y0(t)}:
F := dsolve(ODESys union ICs, {y0(t)}, numeric):

Y0 := t -> rhs(op(2, F(t))):

int(Y0,0..1.0);
            5.15484514547602

restart:

EQ := 1/4*n[1]^4 - 1/2*n[1]^2 + 1/4;

(1/4)*n[1]^4-(1/2)*n[1]^2+1/4

convert(EQ,sqrfree);

(1/4)*(n[1]^2-1)^2

with(Student[Precalculus]):

thaw(CompleteSquare(algsubs(n[1]^2=freeze(n[1]^2),EQ)));

(1/4)*(n[1]^2-1)^2

thaw(simplify(algsubs(n[1]^2=freeze(n[1]^2),EQ),size));

(1/4)*(n[1]^2-1)^2

 

Download sqr_ex.mw

Naturally, the robustness of any technique can depend on the examples provided up front. I don't know what other examples you might have.

I am supposing that you really do want the factor of 1/2 distributed throughout the sum in brackets in the result, otherwise you could take combine(subexp) which returns with the 1/2 factored out front.

restart;

subexp := M__a*sin(omega*t + alpha)*I__a*sin(omega*t + phi);

M__a*sin(omega*t+alpha)*I__a*sin(omega*t+phi)

subexp2 := M__a*I__a*(1/2*(cos(alpha - phi)-cos(2*omega*t + alpha + phi)));

M__a*I__a*((1/2)*cos(alpha-phi)-(1/2)*cos(2*omega*t+alpha+phi))

op(0,subexp)(combine~([selectremove(type,subexp,trig)])[]);

M__a*I__a*((1/2)*cos(alpha-phi)-(1/2)*cos(2*omega*t+alpha+phi))

 

Download combine_trig_ex.mw

note. The order of the additive terms in the bracket depend only on the order in which they appear when subexp2 is first formed.

I could have used `*` instead of op(0,subexp) (since I can see that it is so) but I wanted it more generally programmatically valid and less ad hoc. Ie,

`*`(combine~([selectremove(type,subexp,trig)])[]);

Alternatives -- getting more precise -- might include,

subsindets(subexp,`*`,
           u->`*`(combine~([selectremove(type,subexp,trig)],trig)[]));

subsindets(subexp,And(`*`,satisfies(u->nops(select(type,u,trig))>1)),
           u->`*`(combine~([selectremove(type,subexp,trig)],trig)[]));

restart;

with(Statistics):

X:=Vector([0,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.01,0.012]):
Y:=Vector([1.103,1.057,1.016,0.978,0.94,0.91,0.88,0.85,0.826,0.8,0.778,0.735]):

res:=Fit((-a*t+b)/(-d+e*t+f*t^3),X,Y,t,output=solutionmodule):-Results():

eval("residualsumofsquares",res);

0.8857314486e-5

Fn:=eval("leastsquaresfunction",res);

(HFloat(5.570317278545915e-8)*t+HFloat(9.299492440664645e-9))/(HFloat(5.6227984603429837e-5)*t^3+HFloat(4.191948978543518e-7)*t+HFloat(8.43004582827281e-9))

plots:-display(plot(X,Y,style=point,color=red,symbol=solidcircle),
               plot(Fn,t=min(X)..max(X),color=blue),
               labels=["X","Y"],size=[400,300]);

eval("parametervalues",res);

[a = HFloat(-5.570317278545915e-8), b = HFloat(9.299492440664645e-9), d = HFloat(-8.43004582827281e-9), e = HFloat(4.191948978543518e-7), f = HFloat(5.6227984603429837e-5)]

res;

["residualmeansquare" = 0.1265330641e-5, "residualsumofsquares" = 0.8857314486e-5, "residualstandarddeviation" = 0.1124869166e-2, "degreesoffreedom" = 7, "parametervalues" = [a = -5.570317278545915*10^(-8), b = 9.299492440664645*10^(-9), d = -8.43004582827281*10^(-9), e = 4.191948978543518*10^(-7), f = 0.56227984603429837e-4], "parametervector" = (Vector(5, {(1) = -0.5570317279e-7, (2) = 0.9299492441e-8, (3) = -0.8430045828e-8, (4) = 0.4191948979e-6, (5) = 0.56227984603429837e-4})), "leastsquaresfunction" = (5.570317278545915*10^(-8)*t+9.299492440664645*10^(-9))/(0.56227984603429837e-4*t^3+4.191948978543518*10^(-7)*t+8.43004582827281*10^(-9)), "residuals" = (Vector[row](12, {(1) = 0.1366412595140698e-3, (2) = 0.16823177724600846e-3, (3) = -0.6784881336476811e-3, (4) = -0.9686555350072457e-3, (5) = 0.1830443681129612e-2, (6) = -0.6708520719832523e-3, (7) = -0.7999853175416627e-3, (8) = 0.11659468614327873e-2, (9) = -0.10090592909720586e-2, (10) = 0.472803591991533e-3, (11) = -0.5626311607461743e-3, (12) = 0.23114746722663337e-3}))]

 

Download fit_solmodule.mw

There are various "Paragraph Styles" which you can modify.

There is a "Paragraph Style" names "Maple Output", whose alignment property can be changed from "Center" to "Left".

Here's what you do:

 - On the main menubar, Format -> Styles...

 - In the popup, left combo-box, select "P Maple Output", then click the "Modify" button

 - Change the "Alignment" dropmenu from "Center" to "Left"

Then execute and compute in your Document, and output should appear left-aligned.

You can even save an empty Document with this change as a so-called style sheet, and make it your default for New Documents.

See in the Help system, here and here

You can use the right-click Unit Formatting facility, or the Units:-UseUnit command.

In the actual Maple GUI the units appear in upright roman without the double-bracing. They appear that way when the worksheet is inlined here on Mapleprimes because that's the "old" way that they used to appear in Maple.

restart

kernelopts(version)

`Maple 2020.1, X86 64 LINUX, Jun 8 2020, Build ID 1474533`

with(Units:-Simple)

Units:-UseUnit(J/(kg*K))

22.5*Unit('kJ')/((.25*Unit('kg')*100)*Unit('K'))

900.0000000*Units:-Unit(J/(kg*K))

12.5*Unit('kJ')/(.17*Unit('kg')*(113*Unit('degC')))

650.7027590*Units:-Unit(J/(kg*K))

simplify(22.5*Unit('kJ')/((.25*Unit('kg')*100)*Unit('K')))

900.0000000*Units:-Unit(J/(kg*K))

simplify(0.9e-3*Unit('km'^2/('s'^2*'K')))

900.0000*Units:-Unit(J/(kg*K))

restart

with(Units:-Simple)

 

For the next one I used the right-click menu and chose
the item:  "Convert Output Units...", then I chose the
"Enter Unit" item and typed in J/(kg*K) .

(I did not type in words like "joule per kilogram times kelvin".)

 

22.5*Unit('kJ')/((.25*Unit('kg')*100)*Unit('K'))

900.0000000*Units:-Unit(m^2/(s^2*K))

 

Download unitpref.mw

Starting with a RealRange, you can convert to relations (inequalities) and use the solve command. Union and intersection can be expressed pretty well using inert And and Or.

You can use Open ends, or not, and get strict or nonstrict inequailities accordingly.

Of course, there is nothing stopping you from beginning with inequalities. You don't have to begin from RealRange structures.

Depending on how you express the variables parameter to solve, the result can be in RealRange or relation form.

And so on.

restart;

A:=RealRange(Open(-infinity),Open(7));
B:=RealRange(Open(-10),Open(25));
C:=RealRange(Open(15),Open(infinity));

RealRange(-infinity, Open(7))

RealRange(Open(-10), Open(25))

RealRange(Open(15), infinity)

convert(x::A,relation);
lprint(%);

And(-infinity <= x, x < 7)

And(-infinity <= x,x < 7)

solve(convert~(And(x::A,x::B),relation));
lprint(%);

RealRange(Open(-10), Open(7))

RealRange(Open(-10),Open(7))

solve(convert~(And(x::A,x::B),relation),{x});
lprint(%);

{-10 < x, x < 7}

{-10 < x, x < 7}

solve(convert~(And(x::B,x::C),relation));

RealRange(Open(15), Open(25))

#for a in {A,B,C} do
#  for b in {A,B,C} do
#    temp := And(x::a,x::b);
#    print(temp = solve(convert~(temp,relation)));
#    temp := And(x::a,x::b);
#    print(temp = solve(convert~(temp,relation)));
#    print();
#  end do;
#end do;

 

Download solveRealRange.mw

You have used both y(t) and y, and it complains.

Perhaps you intended this:

eq1 := diff(y(t), t) = 1/2*cos(t - 2*y(t));
with(DEtools);
DEplot(eq1, y(t), t = -2 .. 2, y(t) = -2 .. 2);

If you want to substitute for diff(x(t), t, t) you don't have to assign to it.

(I find you intention slightly confusing, since it appears that the substitution is merely the equation from isolating `Eq__&lambda;1`=0 for diff(x(t), t, t), hence the result is zero. If you intended something else then please explain.)

For example,

restart;

`Eq__&lambda;1`:=diff(x(t),t,t)-R*diff(psi(t),t,t)*cos(phi(t))
                 +R*diff(psi(t),t)*diff(phi(t),t)*sin(phi(t))  

diff(diff(x(t), t), t)-R*(diff(diff(psi(t), t), t))*cos(phi(t))+R*(diff(psi(t), t))*(diff(phi(t), t))*sin(phi(t))

eq:=diff(x(t),t,t)=-R*diff(psi(t),t)*diff(phi(t),t)*sin(phi(t))
    +R*diff(psi(t),t,t)*cos(phi(t));

diff(diff(x(t), t), t) = -R*(diff(psi(t), t))*(diff(phi(t), t))*sin(phi(t))+R*(diff(diff(psi(t), t), t))*cos(phi(t))

eval(`Eq__&lambda;1`, eq);

0

isolate(`Eq__&lambda;1`=0, diff(x(t),t,t)); # same as `eq`

 

 

diff(diff(x(t), t), t) = -R*(diff(psi(t), t))*(diff(phi(t), t))*sin(phi(t))+R*(diff(diff(psi(t), t), t))*cos(phi(t))

 

Download subst_example.mw

Outside the loop (right after calling dsolve) you can make this assignment,

   Y:=eval(y(t),lambdaE):

Then, replace all your calls lambdaE(tCompute[i]) by Y(tCompute[i]) in the later code.

The above works because you used the output=listprocedure option when you called the dsolve command.

If you had omitted the output=listprocedure option then you could get avoid the assignment to Y above, and instead replace all your calls lambdaE(tCompute[i]) by eval(y(t),lambdaE(tCompute[i])) in the subsequent code.

I prefer the way with listprocedure, but that's a stylistic coding preference.

[edit] I could add that it can be needlessly inefficient to call lambdaE(tCompute[i])  (or whatever you replace it with) multiple times for the same numeric value of tCompute[i]. Instead, inside your loop, you could simply call it once and assign the result to a temporary variable.
    temp := lambdaE(tCompute[i]);  # or whatever
And then use temp in the multiple locations your formulas.

Here are two ways.

The first has Nu[a] in italics (because I used single left-quotes to make it a name).

The second has Nu[a] in upright roman.

I specified the axes font, only so that the labels renders more clearly on this site. Adjust as you wish.
 

plot(axes=box,gridlines,size=[375,300],
     labelfont=["Tahoma",bold,14],
     labeldirections=[horizontal,vertical],
     labels=[eta,`Nu[a]`(eta)]);

plot(axes=box,gridlines,size=[375,300],
     labelfont=["Tahoma",bold,14],
     labeldirections=[horizontal,vertical],
     labels=[eta,Typesetting:-mrow(Typesetting:-mo("Nu",':-fontstyle'="normal"),
                                   Typesetting:-mfenced(Typesetting:-mi("a"),
                                   ':-open'="&lsqb;",':-close'="&rsqb;"))(eta)]);

 

 

Download indexedname_label.mw

[edit] A couple of simpler ways (square brackets matching the bold, which you are free remove)
   labels=[eta,Typesetting:-mtext("Nu[a]")(eta)]
and,
   labels=[eta,`#mtext("Nu[a]");`(eta)]

What matters more is how you process and display the results in the second worksheet, rather than how they are returned from the worksheet which computes them.

Let's suppose that your first worksheet does,

   return [matrix(G), matrix(A), matrix(DR), figplot]

do that it returns a list of the items.

Let's suppose that your are making a call like,

   RunWorksheet(...);

in the second worksheet. You could try making that instead be, say,

   results := RunWorksheet(...):
   map(print, results):

That will print each of the results separately, so that the plot renders with its proper size and the matrices don't interfere with each others lines.

Notice that the command above are termined with full colons.

note: Why use lowercase matrix (instead of modern Matrix) which has been deprecated for 20 years?

note: Plots render small when you print them as part of an expression sequence.

note: A fancier way to do all this would be to use Embedded Components in the second worksheet, or Tabulate. But I guess you don't want to change it all.

There is no point-probe functionality provided by the GUI for 3D plots.

First 115 116 117 118 119 120 121 Last Page 117 of 340