acer

32385 Reputation

29 Badges

19 years, 335 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You could try something with the Explore command, to give you an idea of how the parameters affect the polar plot.

Eg,

Explore(plots:-polarplot(a+b*sin(x), x=0..T, title=evalf[3](a+b*sin(x)),
                         gridlines=true, coordinateview=[-3..3,0..2*Pi]),
        parameters=[a=-1.0..1.0, b=-2.0..2.0, T=0..2*Pi],
        initialvalues=[T=2*Pi]);

polarplot_explored.mw

Suppose that Maple is installed at a base location which is also the value of the Linux environment variable MAPLE. In that case the command-line interface can be launched on Linux in a terminal by issuing the command,

  $MAPLE/bin/maple

where that is the name of the bash script which launches the cmaple interface.

That script accepts several options, most of which can be listed by passing the -h option.

What hardware does your device have? I mean, which CPU chipset? Which OS distribution and version? Tell us how it goes.

 

There is no version of Maple which can read and write a proper video file format (eg. mpeg-2, etc).

 

Here is one way.  Note that in Maple 2018 the double-braces are not rendered around Unit calls.

restart

with(Units:-Simple)

with(InertForm)

m__fuel := 10*Unit('kg'/'s')

10*Units:-Unit(kg/s)

h__steam := 100*Unit('kJ'/'kg')

100*Units:-Unit(kJ/kg)

P__steam := `%*`(m__fuel, h__steam)

`%*`(10*Units:-Unit(kg/s), 100*Units:-Unit(kJ/kg))

Display(P__steam, inert = false)

0, "%1 is not a command in the %2 package", _Hold, Typesetting

Value(P__steam)

1000000*Units:-Unit(W)

 

Download inertform.mw

A list is not a mutable structure. When evaluation of a list entails a change in the evaluated value of an entry then a copy is made (and the address changes).

A Vector (or Matrix, Array, ie. rtable) is a mutable structure. In order for in-place semantics to work for rtables via procedure calls they are not copied under eval. Thus a procedure receives the very same rtable, when it is passed in as argument to the procedure call and evaluated up front. And so the desire for in-place semantics is one reason that rtables are not copied under eval.

Another reason is efficiency: the term "rtable" stands for "rectangular table", where hardware numeric entries (or the references to symbolic DAG entries) are stored contiguously in memory. It's a great benefit that passing the data of a float[8] rtable to an external routine only needs to pass the reference to its beginning. Full copying under normal evaluation rules for procedure calls would be a performance damper.

The functionality to force an evaluation throughout all entries of an rtable is provided by the rtable_eval command. Below you can see that command producing a copy.

restart;

g := r -> k*r;

proc (r) options operator, arrow; k*r end proc

g1 := g([x,y]);

k*[x, y]

g2 := g(<x,y>);

Vector(2, {(1) = k*x, (2) = k*y})

k := 1;

1

g1;

[x, y]

g2;

Vector(2, {(1) = k*x, (2) = k*y})

lprint(eval(g1,1));

k*[x, y]

lprint(eval(g1));

[x, y]

lprint(eval(g2,1));

Vector[column](2,{1 = k*x, 2 = k*y},datatype = anything,storage = rectangular,
order = Fortran_order,shape = [])

lprint(eval(g2));

Vector[column](2,{1 = k*x, 2 = k*y},datatype = anything,storage = rectangular,

order = Fortran_order,shape = [])

lprint(rtable_eval(g2));

Vector[column](2,{1 = x, 2 = y},datatype = anything,storage = rectangular,order
= Fortran_order,shape = [])

H1:=eval(g1);
H1[1]:=2;
g1;

[x, y]

[2, y]

[x, y]

H2:=eval(g2);
H2[1]:=55;
g2;

Vector(2, {(1) = k*x, (2) = k*y})

H2[1] := 55

Vector[column](%id = 18446884262579183854)

H3:=rtable_eval(g2);
H3[1]:=77;
g2;

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

H3[1] := 77

Vector[column](%id = 18446884262579183854)

 

Download list_rtable.mw

note: When doing such examinations it can sometimes be useful to utilize lprint and eval(...,1), so as not to be misled by evaluation occuring only during printing.

Access to individual rtable entries, via indexing, does entail full evaluation. This is natural, for programmatic purpose.

restart;

V := <k^2, sin(k)>;

Vector(2, {(1) = k^2, (2) = sin(k)})

k := 1.2;

1.2

V;

Vector(2, {(1) = k^2, (2) = sin(k)})

lprint(eval(V));

Vector[column](2,{1 = k^2, 2 = sin(k)},datatype = anything,storage =

rectangular,order = Fortran_order,shape = [])

V[1];
V[2];

1.44

.9320390860

Download rtableentryeval.mw

While assignment to an entry of a list "works" (up to the 100th entry, by default), it is not true in-place semantics. The underlying list is actually replaced by a full copy whenever this occurs. This is thus a very inefficient programming practice, and should be avoided.

Here's a little more related to list evaluation,

restart;

f := proc(x) addressof(x); end proc:

L:=[1,2,k];

[1, 2, k]

addressof(L);

18446883949991687742

addressof(eval(L,1));

18446883949991687742

addressof(eval(L));

18446883949991687742

f(L);

18446883949991687742

k := 1;

1

addressof(L); # !!

18446883949981400014

addressof(eval(L,1));  # !!

18446883949991687742

addressof(eval(L));

18446883949981400014

f(L);

18446883949981400014

Download list_eval.mw

You could start by reading the Programming Guide, (in particular chapter 9, Object Oriented Programming) and the help pages related to objects and modules.

See also the help pages for Topics:
  object
  object,create
  object,methods

The most up-to-date version of the Programming Guide is included in the latest release of Maple. A (possibly older) version of chapter 9 is online here.

plot3d(piecewise(x^2+y^2<=1,0,undefined), y=-1..1, x=-1..1,
       lightmodel=none,
       image=cat(kernelopts(homedir),"/mapleprimes/","penny.png"));

For this example we can discern the greatest argument in a call to F, and isolate for that up front.

restart;

term := (r+1)*(r+2)*(r+3)*(r+4)*F(r+4)*(k-r+1)*F(k-r+1):

H := isolate(sum(term, r=0..k-1)
             +eval(term, r=k)=c, F(k+4));

F(k+4) = (c-(sum((r+1)*(r+2)*(r+3)*(r+4)*F(r+4)*(k-r+1)*F(k-r+1), r = 0 .. k-1)))/((k+1)*(k+2)*(k+3)*(k+4)*F(1))

Q := unapply(H, k):

Q(0);

F(4) = (1/24)*c/F(1)

Q(1);

F(5) = (1/120)*(c-48*F(4)*F(2))/F(1)

Q(2);

F(6) = (1/360)*(c-72*F(4)*F(3)-240*F(5)*F(2))/F(1)

 

Download gen.mw

Try it like this instead, in your Maple 2018,

restart;

with(DEtools):

rho := 0.1:
w0 := 2:
sys := a->[diff(x(t),t) = y(t),diff(y(t),t) = -2*rho*y(t) - w0^2*(x(t)+a)]:
P:=a->DEplot(sys(a), [x(t),y(t)], t = 0 .. 20-2*a, x=-2..2, y=-1.9..1.7,
             [[x(0) = cos(a)-a, y(0) = sin(a)]], scene = [x(t),y(t)],
             linecolor=blue, numpoints=1000):

plots:-animate(P, [a], a=-0.7..1.4, frames=25, size=[600,300]);

 

Download animate_size.mw

That sizing is respected by the right-click context-menu export to .gif on my Maple 2018.2.

Alternatively, if you have already created the animation, you can resize it like so,

PA:=plots:-animate(P, [a], a=-0.7..1.4, frames=25):
plots:-display(PA, size=[600,300], insequence=true);

Did you forget to first load the CurveFitting package? Try executing this command first,

   with(CurveFitting):

Alternatively, you can call it by its so-called long-form name CurveFitting:-PolynomialInterpolation.

restart;

xdat:=[[0,3],[1,0],[2,4],[3,4],[4,-1],[6,4],[7,0],[9,2],[10,10]];

[[0, 3], [1, 0], [2, 4], [3, 4], [4, -1], [6, 4], [7, 0], [9, 2], [10, 10]]

with(CurveFitting):

PolynomialInterpolation(xdat,x);

-(197/181440)*x^8+(361/9072)*x^7-(52681/90720)*x^6+(24331/5670)*x^5-(3053693/181440)*x^4+(301219/9072)*x^3-(136243/5040)*x^2+(4927/1260)*x+3

restart;

xdat:=[[0,3],[1,0],[2,4],[3,4],[4,-1],[6,4],[7,0],[9,2],[10,10]];

[[0, 3], [1, 0], [2, 4], [3, 4], [4, -1], [6, 4], [7, 0], [9, 2], [10, 10]]

CurveFitting:-PolynomialInterpolation(xdat,x);

-(197/181440)*x^8+(361/9072)*x^7-(52681/90720)*x^6+(24331/5670)*x^5-(3053693/181440)*x^4+(301219/9072)*x^3-(136243/5040)*x^2+(4927/1260)*x+3

 

Download PolyInterp.mw

You claim that a call to EigValsVecsC executes properly when called from withing Visual Studio. So then the function LAPACKE_dsyev is being found at run time. Whence is it be found, by Visual Studio?

That missing function's name is from a suite for calling Fortran LAPACK from C. How is Visual Studio linking to a .dll that contains that function? Presumably operators.dll is being built in Visual Studio by being linked against some LAPACKe .dll(s). But only you can tell us how you set up that project.

When you try to call EigValsVecsC using Maple's define_external then it's not going to know where to find the .dll that contains that auxillary LAPACKe function LAPACKE_dsyev. Why/How should it know, if you haven't put it in a directory that is in the runtime path?

You could try adding the relevant LAPACKe .dlls (that contain LAPACKE_dsyev and any supporting functions) to the runtime path. You may need to try a few variations on that, since Maple's directory for executables and .dlls contains it own MKL LAPACK .dlls (but not LAPACKe, if I recall).

[edit] Perhaps you could provide a detailed description of what you're trying to achieve?

 

 

I'm not sure how exacty you want it to look. But here's a start.

insert_pictures_ac.mw

Below I first inline and attach a worksheet that does this in a very simple way.

Then at the end I attach another worksheet whose Startup Code contains a rough version of a package that provides some more automatic support for such things (eg. some Units support, convert/combine/evalc/Re/Im/etc, and a few context-menu items). Sorry, it's got an accidental quirk in its static evalf export that makes it a bit awkward to work with float values -- I ought to fix that.

Sorry that the 2D Math parser is so picky about brackets around floats and negative values for the infix `&angle;` operator. You can find that on the "Operators" palette, by the way (and you can add it to your Favorites palette). There's a bit of GUI weirdness around.

This first approach below doesn't need any add-on. [edit] Carl Love did something similar once, if I recall, but I cannot find that post at the moment.

restart

I want to calculate the voltage between phase 1 and phase N in an electrical circuit:``

 

The vectorial formula is:

`#mover(mi("U"),mo("&rarr;"))`[L1-N]-`#mover(mi("&Delta;U",mathcolor = "blue"),mo("&rarr;",mathcolor = "blue"))`[L1]+`#mover(mi("&Delta;U",mathcolor = "#339966"),mo("&rarr;",mathcolor = "#339966"))`[N] = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

`#mover(mi("U"),mo("&rarr;"))`[L1-N]-`#mover(mi("&Delta;U",mathcolor = "blue"),mo("&rarr;",mathcolor = "blue"))`[L1]+`#mover(mi("&Delta;U",mathcolor = "#339966"),mo("&rarr;",mathcolor = "#339966"))`[N] = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

 

Voltage drops are calculated with the current multiplied with the resistance: ΔU = I*Z[L]

I*Z[L]

 

i

 

-`#mover(mi("I",mathcolor = "blue"),mo("&rarr;",mathcolor = "blue"))`[L1]*`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L]+`#mover(mi("I",mathcolor = "#339966"),mo("&rarr;",mathcolor = "#339966"))`[N]*`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L]+`#mover(mi("U"),mo("&rarr;"))`[L1-N] = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]``

-`#mover(mi("I",mathcolor = "blue"),mo("&rarr;",mathcolor = "blue"))`[L1]*`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L]+`#mover(mi("I",mathcolor = "#339966"),mo("&rarr;",mathcolor = "#339966"))`[N]*`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L]+`#mover(mi("U"),mo("&rarr;"))`[L1-N] = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

This is a real example with realistic values and angles:

`&angle;` := proc (a, b) polar(a, (1/180)*b*Pi) end proc; ex := proc (v) abs(v), 180*argument(v)/Pi end proc

`#mover(mi("U"),mo("&rarr;"))`[L1-N] := `&angle;`(230.0, 0)

polar(230.0, 0)

`#mover(mi("I",mathcolor = "blue"),mo("&rarr;",mathcolor = "blue"))`[L1] := `&angle;`(20.0, -30)

polar(20.0, -(1/6)*Pi)

`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L] := `&angle;`(0.97e-1, 7.2)

polar(0.97e-1, .1256637062)

`#mover(mi("I",mathcolor = "#339966"),mo("&rarr;",mathcolor = "#339966"))`[N] := `&angle;`(40.0, -120)

polar(40.0, -(2/3)*Pi)

 

The negative angles is because i am using my reference which is in 0°. And are the vector to the right of my reference is the angle negative, and is it on the left of my reference is the angle negative. I dont want to explain the vectorial diagram, because i think it will do more confusion than explaining.

 

NULL

ex(simplify(`&angle;`(230, 0)-`&angle;`(20, -30)*`&angle;`(0.97e-1, 7.2)+`&angle;`(40, -120)*`&angle;`(0.97e-1, 7.2))) = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

(226.7256260, -.7139358882) = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

My question is, if the formula above is possible to solve in maple?

ex(simplify(-`#mover(mi("I",mathcolor = "blue"),mo("&rarr;",mathcolor = "blue"))`[L1]*`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L]+`#mover(mi("I",mathcolor = "#339966"),mo("&rarr;",mathcolor = "#339966"))`[N]*`#mover(mi("Z",mathcolor = "#ff99cc"),mo("&rarr;",mathcolor = "#ff99cc"))`[L]+`#mover(mi("U"),mo("&rarr;"))`[L1-N])) = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

(226.7256260, -.7139358882) = `#mover(mi("U",mathcolor = "red"),mo("&rarr;",mathcolor = "red"))`[L1-N]

``

Download Example_to_Mapleprimes_ac2.mw

And here's the other worksheet I mentioned, using a rough prototype of my "Phasors" package in the Startup Code region. [edit] To utilize this in another worksheet you'd have to copy the Startup Code, since I have not yet made it into a downloadable package from the Maple cloud.

Example_to_Mapleprimes_ac.mw

note: "Phasor" may not be the best term here. "degree-polar" might be better. Are the multiplications in your calculation meant to represent something like a phasor multiplied by a complex value? Or phasor-phasor product?
note: What was the precise result from your calculator?

Your expectation indicates that you have not read and understood the relevant part of the interface help page.

Regarding the errorbreak setting, the help page for topic interface says, "Controls Maple's behavior when an error occurs while reading Maple commands from a file or redirected standard input, as follows:..."

That description does not state that it controls the general flow of an executing worksheet.

Inside the GUI, the setting of interface(errorbreak) affects the behavior during execution of the read command. It controls the error severity level that will stop further reading of the plaintext file's Maple statements.

Let us know if you really need the appearance of the addends to be of the form wf δ θf (...)  etc.  That could be done as a visual effect, since normally some of those terms would automatically simplify (eg. wf*delta*wf automatically simplifies to delta*wf^2). The other terms could be managed using special invocation of the `sort` command. But the squares are trickier.

The addends in ans1 below are mathematically as you asked, if I understand correctly. The precise formatting is also possible -- but it'd be just that, a pretty-printing affect.

restart

c := -(lambda*`&theta;f`+lambda*`&theta;i`+2*wf-2*wi)/lambda^3

d := (lambda*`&theta;f`+2*lambda*`&theta;i`+3*wf-3*wi)/lambda^2:

g := 6*c*x+2*d:

h := delta*g:

expr := expand(g*h)

4*delta*`&theta;f`^2/lambda^2+16*delta*`&theta;i`^2/lambda^2+36*delta*wi^2/lambda^4+36*delta*wf^2/lambda^4+72*delta*x^2*`&theta;f`*`&theta;i`/lambda^4+144*delta*x^2*`&theta;f`*wf/lambda^5-144*delta*x^2*`&theta;f`*wi/lambda^5-72*delta*x*`&theta;f`*`&theta;i`/lambda^3-120*delta*x*`&theta;f`*wf/lambda^4+120*delta*x*`&theta;f`*wi/lambda^4+144*delta*x^2*`&theta;i`*wf/lambda^5-144*delta*x^2*`&theta;i`*wi/lambda^5-168*delta*x*`&theta;i`*wf/lambda^4+168*delta*x*`&theta;i`*wi/lambda^4-288*delta*x^2*wf*wi/lambda^6+288*delta*x*wf*wi/lambda^5+36*delta*x^2*`&theta;f`^2/lambda^4+144*delta*x^2*wi^2/lambda^6+24*delta*`&theta;f`*wf/lambda^3-72*delta*wf*wi/lambda^4-144*delta*x*wi^2/lambda^5+16*delta*`&theta;f`*`&theta;i`/lambda^2-24*delta*x*`&theta;f`^2/lambda^3-48*delta*x*`&theta;i`^2/lambda^3+144*delta*x^2*wf^2/lambda^6+48*delta*`&theta;i`*wf/lambda^3-48*delta*`&theta;i`*wi/lambda^3+36*delta*x^2*`&theta;i`^2/lambda^4-144*delta*x*wf^2/lambda^5-24*delta*`&theta;f`*wi/lambda^3

L := [wi, wf, `&theta;f`, `&theta;i`];

[wi, wf, `&theta;f`, `&theta;i`]

CC := map(proc (p) options operator, arrow; delta*(`*`(op(p))) end proc, C):

ee := expand(expr):

ans1 := thaw(collect(ee, map(rhs, CCC), simplify));

36*delta*wi^2*(lambda^2-4*lambda*x+4*x^2)/lambda^6-72*(lambda^2-4*lambda*x+4*x^2)*delta*wf*wi/lambda^6-24*(lambda^2-5*lambda*x+6*x^2)*delta*`&theta;f`*wi/lambda^5-24*`&theta;i`*(2*lambda^2-7*lambda*x+6*x^2)*wi*delta/lambda^5+36*(lambda^2-4*lambda*x+4*x^2)*wf^2*delta/lambda^6+24*(lambda^2-5*lambda*x+6*x^2)*delta*`&theta;f`*wf/lambda^5+24*`&theta;i`*(2*lambda^2-7*lambda*x+6*x^2)*wf*delta/lambda^5+4*(lambda^2-6*lambda*x+9*x^2)*`&theta;f`^2*delta/lambda^4+8*`&theta;i`*(2*lambda^2-9*lambda*x+9*x^2)*`&theta;f`*delta/lambda^4+4*(4*lambda^2-12*lambda*x+9*x^2)*`&theta;i`^2*delta/lambda^4

simplify(expr-ans1);

0

``

Download Final_objective_orig_ac.mw

 

First 145 146 147 148 149 150 151 Last Page 147 of 336