acer

32395 Reputation

29 Badges

19 years, 343 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Your eq1 is an equation, with x1 given explicitly.

You can use it to substitute a value for x1 into your eq2 equation (or something else in which x1 appears).

For example,

   eval(eq2, eq1);

 

Your code is full of syntax errors. The error messages explain them.

For example, your brackets don't match in the first mistake. The number of opening and closing brackets (delimiters) are different.

Also, you need to enter if...then and while..do all in a single execution group. You have mistakenly tried to write thise across multiple execution groups. Use Shift-Enter to move to a new line inside an execution group, and only use Enter to finish and execute it.

Maple works with radians, not degrees. So use Pi/6 instead of 30.

Also, use a floating point value if that's what you want in return (if there is no easy exact result). Eg, sin(4.8) etc.

You could try closing the palettes (panel on the left side of the GUI). I have a recollection of some stall issues related to that.

You could also try closing the context-panel (right side of the GUI). Let us know if either of these makes a difference.

And if you are able to discover a trigger example, then please do share it.

Let us know is the domain over which you want an approximating polynomial is not just 0..1.

restart

lambda := proc (x) options operator, arrow; (-1.565845910+2.393779704*x^2+1.564996800*x^4+1.800900000*x^6)/(x^2+2)^4 end proc

a, b := 0, 1; Digits := 15; K := expand(eval(numapprox:-chebpade(lambda(t), t = 0 .. 1, [11, 0]), T = orthopoly[T]))

0, 1

-1.52912602770120*t^8+.316503853656742*t^7-0.10877005919702e-1*t^5-0.724603953293e-3*t^3+1.54422942262127*t^9-.698472042216867*t^10+.124540489696808*t^11-0.978653647938183e-1+.345390592384950*t^2-.441314123152201*t^4+.499491688907188*t^6-0.1185138058e-5*t

plot(log10(abs(lambda(t)-K)), t = a .. b, size = [500, 200], adaptive = false, numpoints = 70, view = -15 .. 0)

plot([lambda(t), K], t = a .. b, style = [line, point], color = [red, blue], adaptive = false, numpoints = 30, size = [500, 200])

 

Download help2_ac.mw

You could add the listprocedure option to dsolve, and then pick off the procedures individually.

It's generally more efficient to use plots:-odeplot than to plot using the procedures separately as done below. But these compute pretty quickly, so performance may not be a central concern here.

(There are also other ways to pick off the individual results. You can recover some efficiency by using option remember.)

For example,

restart;

ddesys := {diff(S(t),t) = -beta*S(t)*Ix(t)/N,
diff(Ex(t),t) = beta*S(t)*Ix(t)/N - sigma*Ex(t-tau__1),
diff(Ix(t), t) = sigma*Ex(t - tau__1)- gamma*Ix(t-tau__2),
diff(R(t),t) = gamma*Ix(t-tau__2),
diff(Dx(t),t) = delta*Ix(t),
S(0) = 80900, Ex(0) = 1, Ix(0) = 1, R(0) = 0, Dx(0) = 0 }:

dsn := dsolve(eval(ddesys, {beta = 4, gamma = 0.0478, sigma = 0.10,
              delta = 0.0005, N=80900, tau__1 = 1.1,tau__2 = 8.7,tau__3 = 0}),
              numeric, output=listprocedure):

Dxfun := eval(Dx(t), dsn):
Exfun := eval(Ex(t), dsn):
Ixfun := eval(Ix(t), dsn):
Rfun := eval(R(t), dsn):
Sfun := eval(S(t), dsn):

Dxfun(20.0), Exfun(20.0), Ixfun(20.0);

HFloat(4.89877539841769), HFloat(26744.91529379044), HFloat(4309.387881985894)

### Compare
plots:-odeplot(dsn, [[t,Dx(t)], [t,Ex(t)], [t,Ix(t)],
                      [t,R(t)], [t,S(t)]],
               t=0..120, size=[500,300]);

plot([Dxfun, Exfun, Ixfun, Rfun, Sfun], 0..120, size=[500,300]);

 

Download listprocedure.mw

Here are two ways.

You could adjust the values used for width, distance, and offset. (The values are assigned to w,d,o respectively. See the ColumnGraph help page for their meaning.)

If your actual data is quite different then it would really help if you uploaded and attached it. If your numeric and string data are simply rows/columns of a Matrix then you could extract those, convert to lists, and use like L and S below.

restart;

L:=[74,71,87,83,85,61]:
S:=["Belgium","Bulgaria","Czechia","Denmark",
    "Germany (until 1990 former territory of the FRG)",
    "Estonia"]:

(w,d,o) := 25,60,30:
Statistics:-ColumnGraph(L, width=w, distance=d, offset=o,
                        axis[2]=[tickmarks=[[seq(0..100,10)],color=black],
                                 gridlines=[color=black], color=white],
                        axis[1]=[tickmarks=[seq(o+w/2+(i-1)*(w+d)
                                                =typeset(StringTools:-WrapText(S[i],11)),
                                                i=1..nops(S))]],
                        axesfont=["Lucida Sans",10], axes=normal, color="SteelBlue",
                        view=[0..o+(nops(S)-1)*(w+d)+d,0..100], size=[600,400]);

 

Download columngraph_ac.mw

The following uses plots:-textplot instead of tickmarks on the x-axis.

restart;

L:=[74,71,87,83,85,61]:
S:=["Belgium","Bulgaria","Czechia","Denmark",
    "Germany (until 1990 former territory of the FRG)",
    "Estonia"]:

(w,d,o) := 25,60,30:
plots:-display(
  Statistics:-ColumnGraph(L, width=w, distance=d, offset=o,
                          axis[2]=[tickmarks=[[seq(0..100,10)],color=black],
                                   gridlines=[color=black], color=white],
                          axis[1]=[tickmarks=[]], axesfont=[TIMES,10],
                          axes=normal, color="SteelBlue"),
  seq(plots:-textplot([o+w/2+(i-1)*(w+d),-2,
                       typeset(StringTools:-WrapText(S[i],11))],
                       align=[below],font=[TIMES,10]),i=1..nops(S)),
  plots:-pointplot([[0,102]],color=white),
  view=[0..o+(nops(S)-1)*(w+d)+w+d/2,default], size=[600,400]);

 

Download columngraph_tpl.mw

The sort command can be used to rearrange the additive terms in some kinds of polynomial, using a flavour of monomial ordering. It works by replacing the particular expression's form that the kernel stores in its table of "uniquified" expressions (aka "simpl" table).

I can cook one up for your example, by eye. For such a monic example it'd be easy to write a procedure that does a subsindets on suitable `+` subterms -- where the action involves a scan and a sort call.

restart;


I forcibly enter the expression in the undesired form, to illustrate
that it can occur. Then I sort it. And then I show that its form has
been changed.

( - a1b2 + a2b1) * j1 + ( - a3b5 + a4b4) * j2:
a := (a2b1-a1b2)*j1+(a4b4-a3b5)*j2:

 

a;

(-a1b2+a2b1)*j1+(-a3b5+a4b4)*j2

 

sort(a, order=plex(a2b1,a4b4)):

 

a;

(a2b1-a1b2)*j1+(a4b4-a3b5)*j2

Download sort_ex.mw

But the facility is restricted. You can easily construct a more general example for which none of the available sortings would be able to achive the goal.

 

kernelopts(version)

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

restart; assume(1 <= x, x <= 4)

assume(0 < y, y < 1)

f := 1-4*(x-1)*(1+y)/(x^2*(1-y))

sols := [solve(f > 0, useassumptions)]

[{x = 1, 0 < y, y < 1}, {0 < y, 1 < x, x < 2, y < (x^2-4*x+4)/(x^2+4*x-4)}, {0 < y, 2 < x, x < 4, y < (x^2-4*x+4)/(x^2+4*x-4)}, {x = 4, 0 < y, y < 1/7}]

seq(`assuming`([is(f > 0)], [sols[i][]]), i = 1 .. nops(sols))

true, true, true, true

restart

f := 1-4*(x-1)*(1+y)/(x^2*(1-y)):

solsO := [solve({f > 0, 1 <= x, x <= 4, 0 < y, y < 1})];

[{x = 1, 0 < y, y < 1}, {0 < y, 1 < x, x < 2, y < (x^2-4*x+4)/(x^2+4*x-4)}, {0 < y, 2 < x, x < 4, y < (x^2-4*x+4)/(x^2+4*x-4)}, {x = 4, 0 < y, y < 1/7}]

seq(`assuming`([is(f > 0)], [solsO[i][]]), i = 1 .. nops(solsO));

true, true, true, true

``

Download positive_function_ac.mw

Append the string with the full location of the .mla file to libname, in Maple. For example,

   libname := libname, "C:/Users/Lisa6/Documents/myfolder/filename.mla";

You only need to do that once per session, so you could put it at the beginning of your worksheet, or right after a restart .

Note that a .mla file can contain several things. It's possible that your file blah.mla also happens to contain a module package blah, so that you can issue the with(blah); command. But the name of the things stored in your blah.mla file may be named differently.

A unit is not part of the embedded component per se.

But you can force a particular unit for a particular dimension, as a preference set with the Units:-UseUnit command. And that will get carried over to what is put inside a MathContainer. For example,

restart;

W := 87.7 * Unit(joule/m^2);

87.7*Units:-Unit(J/m^2)

combine(W, units);

87.7*Units:-Unit(kg/s^2)

V := 45.6 * Unit(kg/s^2);

45.6*Units:-Unit(kg/s^2)

Units:-UseUnit(N/m):

combine(W, units);

87.7*Units:-Unit(N/m)

combine(V, units);

45.6*Units:-Unit(N/m)

simplify(V);

45.6*Units:-Unit(N/m)

DocumentTools:-SetProperty("MathContainer0", expression, combine(V, units));

Download UseUnit_EC.mw

You can also re-express something in terms of units of compatible dimension. And that can always be done directly, without Units:-UseUnit . Again, the unit is simply a part of the expression, and not specific to the embedded component. For example,

restart;

V := 45.6 * Unit(kg/s^2);

45.6*Units:-Unit(kg/s^2)

convert(V, units, N/m);

45.6*Units:-Unit(N/m)

DocumentTools:-SetProperty("MathContainer0", expression, convert(V, units, N/m));

Download Unit_EC.mw

In either scenario above you could also produce results in terms of kN/m if you prefer. The component step would be done similarly.

restart;

V := 45.6 * Unit(kg/s^2);

45.6*Units:-Unit(kg/s^2)

convert(V, units, kN/m);

0.4560000000e-1*Units:-Unit(kN/m)

Units:-UseUnit(kN/m):

combine(V, units);

0.4560000000e-1*Units:-Unit(kN/m)

 

Download Unit_kN.mw

 

There are several ways to get such an effect.

You should be able to adjust the following easily (to alter the colors or symbolsize, include the axes, remove the blue circle, slow it down with more frames, etc). If you want help just state precisely what effects you want. Or see the Help pages for Topics like animate or plot,options .

restart;

bg := plot([sin(tt),cos(tt),tt=0..2*Pi],color="Navy",thickness=0):

G := proc(t) local tt;
  plots:-display(
    bg,
    plot([sin(tt),cos(tt),tt=0..t],color="Red",thickness=3),
    plot([[sin(t),cos(t)]],style=point,color="Red",
         symbol=solidcircle,symbolsize=30));
end proc:

plots:-animate(G, [t], t=0..2*Pi, frames=50,
               paraminfo=false, axes=none);

 

Download circle_trace.mw

I find that one of the easiest ways to start doing an animation is to contruct a procedure that produces just a single frame. Here, the procedure G can be called to show a single frame. For example,

G(Pi/4)

That makes calling plots:-animate much simpler. And it allows you to test easily the generation of any particular frame, without having to build the whole animation.

Your a and b are Matrices whose entries are Vectors.

You could consider something like these (alas, there is no andzip).

   andmap(evalb,Equal~(a,b));

   Equal~(a,b);

If you need extra efficiency -- with false return upon the first mismatch -- you could write your own.

Your first use of PDEtools[declare] makes psi(t) appear as just psi in output. But it doesn't affect input, and in your usage you'd still need to type psi(t) if you want to refer to it.

The Physics:-diff command will allow you to differentiate with respect to psi(t).

The name theta__l gets prettyprinted with an underscore. You could use another name if you'd prefer to avoid that.

restart

PDEtools[declare](`&theta;__l`(t), `&beta;__l`(t), `&theta;__si`(t), `&beta;__si`(t), psi(t), x(t), z(t)); PDEtools[declare](prime = t)

`derivatives with respect to`*t*`of functions of one variable will now be displayed with '`

V__1lx := diff(x(t), t)-(1/2)*l__b*sin(psi(t))*(diff(psi(t), t))-l__1c*sin(`&theta;__l`(t)-psi(t))*(diff(`&theta;__l`(t), t)-(diff(psi(t), t))); V__1lz := diff(z(t), t)-(1/2)*l__b*cos(psi(t))*(diff(psi(t), t))-l__1c*cos(`&theta;__l`(t)-psi(t))*(diff(`&theta;__l`(t), t)-(diff(psi(t), t)))

V__1l := simplify(V__1lx^2+V__1lz^2, size)

(diff(x(t), t)-(1/2)*l__b*sin(psi(t))*(diff(psi(t), t))+l__1c*sin(-theta__l(t)+psi(t))*(diff(theta__l(t), t)-(diff(psi(t), t))))^2+(diff(z(t), t)-(1/2)*l__b*cos(psi(t))*(diff(psi(t), t))-l__1c*cos(-theta__l(t)+psi(t))*(diff(theta__l(t), t)-(diff(psi(t), t))))^2

Physics:-diff(V__1l, psi(t))

2*(diff(x(t), t)-(1/2)*l__b*sin(psi(t))*(diff(psi(t), t))+l__1c*sin(-theta__l(t)+psi(t))*(diff(theta__l(t), t)-(diff(psi(t), t))))*(-(1/2)*l__b*cos(psi(t))*(diff(psi(t), t))+l__1c*cos(-theta__l(t)+psi(t))*(diff(theta__l(t), t)-(diff(psi(t), t))))+2*(diff(z(t), t)-(1/2)*l__b*cos(psi(t))*(diff(psi(t), t))-l__1c*cos(-theta__l(t)+psi(t))*(diff(theta__l(t), t)-(diff(psi(t), t))))*((1/2)*l__b*sin(psi(t))*(diff(psi(t), t))+l__1c*sin(-theta__l(t)+psi(t))*(diff(theta__l(t), t)-(diff(psi(t), t))))

``

Download DiffExpr_ac.mw

You could use the DocumentTools:-Tabulate command to embed a GUI Table of values. The values and column headings are constructed in a Matrix.

In the attached, I show two ways to handle the column headings (y3 and y4, with the formula for the latter shown explicitly). You can make both column headers the same, of course, using which form you prefer.

The attached also shows a variant of the above is to use a DataFrame structure instead of a Matrix, but I find that a little awkward.

The Tabulate command has several options, which allow you to customice the cell coloring, border display, column weighting, Table width, etc.

NULL

Example: Verifying Inverse Functions Numerically

 

"ex17f6(x):=(x-5)/(2);"

proc (x) options operator, arrow, function_assign; (1/2)*x-5/2 end proc

"ex17g6(x):=2 x+5;"

proc (x) options operator, arrow, function_assign; 2*x+5 end proc

y3:=ex17f6@ex17g6;

`@`(ex17f6, ex17g6)

y4:=ex17g6@ex17f6;

`@`(ex17g6, ex17f6)

NULL

V1 := Vector(7, proc (i) options operator, arrow; i-3 end proc); M := `<|>`(V1, map(y3, V1), map(y4, V1))

T := `<,>`(`<|>`("x", "y3", InertForm:-Display(%ex17g6(%ex17f6(x)), inert = false)), M)

``

DocumentTools:-Tabulate(T, fillcolor = (proc (T, i, jj) options operator, arrow; `if`(i = 1, cyan, white) end proc))

 

x

y3

Typesetting:-_Hold([%ex17g6(%ex17f6(x))])

-2

-2

-2

-1

-1

-1

0

0

0

1

1

1

2

2

2

3

3

3

4

4

4

 

 

 

Tabulate(DataFrame(`<|>`(map(y3, V1), map(y4, V1)), columns = [InertForm:-Display(%ex17f6(%ex17g6(x)), inert = false), "y4"], rows = [`$`(-2 .. 4)]))

 

 

Typesetting:-_Hold([%ex17f6(%ex17g6(x))])

y4

-2

-2

-2

-1

-1

-1

0

0

0

1

1

1

2

2

2

3

3

3

4

4

4

 

 

InverseNum_ac.mw

First 124 125 126 127 128 129 130 Last Page 126 of 336