acer

32333 Reputation

29 Badges

19 years, 319 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@DoingMath2018 You are welcome.

I'm not sure whether there is an example of this in the documentation. I know that Robert Israel has an old note on it here.

I will submit a bug report, suggesting a clarifying example under the plotting Help pages.

@pik1432 I am not sure how you obtained your versions of f9 and f10, but below I have adjusted them. Then I obtain solutions using both the new and the old equations (and check against both for residuals).

I also show how procedures may be constructed from the equations, which each locally raise Digits for their own calculations, which I mentioned earlier.

I also compute an apparant second solution. (One of the solutions is picky about the supplied ranges.)

I don't know precisely why solve is not finding the solution for this reformulation, but I'm not sure that it matters so much as fsolve can be used.

restart;

TrainLoad := -10*10^6*(cos(convert(40*degrees, radians))+I*sin(convert(40*degrees, radians)));
#evalf(TrainLoad, 7);

-10000000*cos((2/9)*Pi)-(10000000*I)*sin((2/9)*Pi)

f10 := imV[t]*(reIx[c1] - reIx[c2]) + reV[t]*(imIx[c1] - imIx[c2]) - 10000000*sin((2*Pi)/9) = 0;

imV[t]*(reIx[c1]-reIx[c2])+reV[t]*(imIx[c1]-imIx[c2])-10000000*sin((2/9)*Pi) = 0

expand(f10);

imV[t]*reIx[c1]-imV[t]*reIx[c2]+reV[t]*imIx[c1]-reV[t]*imIx[c2]-10000000*sin((2/9)*Pi) = 0

f9 := -10000000*cos((2*Pi)/9) + reV[t]*(reIx[c1] - reIx[c2]) - imV[t]*(imIx[c1] - imIx[c2]) = 0;

-10000000*cos((2/9)*Pi)+reV[t]*(reIx[c1]-reIx[c2])-imV[t]*(imIx[c1]-imIx[c2]) = 0

f5 := 1.36*reIx[c2] - 4.44*imIx[c2] + reV[at2] - reV[t] = 0;

1.36*reIx[c2]-4.44*imIx[c2]+reV[at2]-reV[t] = 0

f6 := 4.44*reIx[c2] + 1.36*imIx[c2] + imV[at2] - imV[t] = 0;

4.44*reIx[c2]+1.36*imIx[c2]+imV[at2]-imV[t] = 0

f2 := 0.1515*reIx[c1] + 0.03*imIx[c1] - 0.1515*reIx[c2] - 0.03*imIx[c2] + 2*imV[at1] = 0;

.1515*reIx[c1]+0.3e-1*imIx[c1]-.1515*reIx[c2]-0.3e-1*imIx[c2]+2*imV[at1] = 0

f1 := -55000 + 0.03*reIx[c1] - 0.1515*imIx[c1] - 0.03*reIx[c2] + 0.1515*imIx[c2] + 2*reV[at1] = 0;

-55000+0.3e-1*reIx[c1]-.1515*imIx[c1]-0.3e-1*reIx[c2]+.1515*imIx[c2]+2*reV[at1] = 0

f8 := -2.64*reIx[c1] - 1.12*imIx[c1] - 12.00*reIx[c2] - 3.92*imIx[c2] + imV[at2] - imV[at1] = 0;

-2.64*reIx[c1]-1.12*imIx[c1]-12.00*reIx[c2]-3.92*imIx[c2]+imV[at2]-imV[at1] = 0

f7 := -1.12*reIx[c1] + 2.64*imIx[c1] - 3.92*reIx[c2] + 12.00*imIx[c2] + reV[at2] - reV[at1] = 0;

-1.12*reIx[c1]+2.64*imIx[c1]-3.92*reIx[c2]+12.00*imIx[c2]+reV[at2]-reV[at1] = 0

f3 := 1.6*reIx[c1] - 6.24*imIx[c1] + 1.12*reIx[c2] - 2.64*imIx[c2] + reV[t] - reV[at1] = 0;

1.6*reIx[c1]-6.24*imIx[c1]+1.12*reIx[c2]-2.64*imIx[c2]+reV[t]-reV[at1] = 0

f4 := 6.24*reIx[c1] + 1.6*imIx[c1] + 2.64*reIx[c2] + 1.12*imIx[c2] + imV[t] - imV[at1] = 0;

6.24*reIx[c1]+1.6*imIx[c1]+2.64*reIx[c2]+1.12*imIx[c2]+imV[t]-imV[at1] = 0

vars := {reIx[c1], imIx[c1], reIx[c2], imIx[c2], reV[at1], imV[at1], reV[at2], imV[at2], reV[t], imV[t]};

{imIx[c1], imIx[c2], imV[at1], imV[at2], imV[t], reIx[c1], reIx[c2], reV[at1], reV[at2], reV[t]}

# Digits seems to need to be at least 18 in order
# to find a second solution (and also gives a better first solution).
Digits := 20;

20

# Even correcting defn of f9 and f10 (and expanding them) doesn't
# seem to help `solve`. But `fsolve` can still be used, see below.

sol1:=solve(({f1, f2, f3, f4, f5, f6, f7, f8, f9, f10}), vars);

Warning, solutions may have been lost

f1n2 := (0.03 + I*0.1515)*Ix[c1] - (0.03 + I*0.1515)*Ix[c2] + 2 * V[at1] - 55*10^3 = 0:
f3n4 := (1.6 + I*6.24)*Ix[c1] + (1.12 + I*2.64)*Ix[c2] + V[t] - V[at1] = 0:
f5n6 := (1.36 + I*4.44)*Ix[c2] + V[at2] - V[t] = 0:
f7n8 := (-1.12 - I*2.64)*Ix[c1] + (-3.92 - I*12.00)*Ix[c2] + V[at2] - V[at1] = 0:
f9n10 := V[t] * (Ix[c1] - Ix[c2]) + TrainLoad = 0:

oldvars := {Ix[c1], Ix[c2], V[at1], V[at2], V[t]};
K:=map(var->var=cat(re,var)+I*cat(im,var),oldvars):
evalc(eval(map(eq->[Re(eq),Im(eq)][],{f1n2, f3n4, f5n6, f7n8, f9n10}),K)):
sol2:=eval(K,simplify(fnormal(fsolve(%,complex)),zero));

{Ix[c1], Ix[c2], V[at1], V[at2], V[t]}

{Ix[c1] = 181.28189005805791743+162.01046250921478591*I, Ix[c2] = -81.655484607695036328-76.947655535280817396*I, V[at1] = 27514.157016821884248-23.501877901598220297*I, V[at2] = 27892.767479423787347-644.96659512864599818*I, V[t] = 28123.363610933968927-1112.1657583147938711*I}

evalf[100](eval((lhs-rhs)~({f1n2, f3n4, f5n6, f7n8, f9n10}), sol2)):
max(abs~(evalf[5](%)));

0.21823907687671335089e-12

S[1]:=fsolve([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10],vars,complex);

{imIx[c1] = 162.01046250921478591, imIx[c2] = -76.947655535280817396, imV[at1] = -23.501877901598220297, imV[at2] = -644.96659512864599818, imV[t] = -1112.1657583147938711, reIx[c1] = 181.28189005805791743, reIx[c2] = -81.655484607695036328, reV[at1] = 27514.157016821884248, reV[at2] = 27892.767479423787347, reV[t] = 28123.363610933968927}

evalf[100](eval((lhs-rhs)~({f1, f2, f3, f4, f5, f6, f7, f8, f9, f10}), S[1])):
max(evalf[5](abs~(%)));

0.21757e-12

eval(K,simplify(fnormal(S[1]),zero)):
evalf[100](eval((lhs-rhs)~({f1n2, f3n4, f5n6, f7n8, f9n10}), %)):
max(evalf[5](abs~(%)));

0.21824e-12

S[2]:=fsolve([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10],vars,complex,avoid={S[1]});
evalf[100](eval((lhs-rhs)~({f1, f2, f3, f4, f5, f6, f7, f8, f9, f10}), S[2])):
max(evalf[5](abs~(%)));

{imIx[c1] = -5281.4918969451713544, imIx[c2] = 2424.8308425628567005, imV[at1] = 4.9812524290496869171, imV[at2] = 56.665451734948995089, imV[t] = 1112.1657583147938711, reIx[c1] = 955.22971037032619932-0.46908608509430945230e-33*I, reIx[c2] = -505.01568452829735058+0.21662280789933333333e-33*I, reV[at1] = 26894.342371558787522, reV[at2] = 10829.706661003599220, reV[t] = -623.36361093396892656}

0.22944e-12

# no result (takes long)
#S[3]:=fsolve([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10],vars,complex,avoid={S[1],S[2]}):
#if op(0,eval(S[3],1))=fsolve then print("no additional solution found"); end if;

#
# For fun, use the abs of the lhs-rhs of the new equations.
#
SS[1]:=fsolve(abs~((lhs-rhs)~([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10])));
evalf[100](eval((lhs-rhs)~({f1, f2, f3, f4, f5, f6, f7, f8, f9, f10}), SS[1])):
max(evalf[5](abs~(%)));
SS[2]:=fsolve(abs~((lhs-rhs)~([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10])),vars,avoid={SS[1]});
evalf[100](eval((lhs-rhs)~({f1, f2, f3, f4, f5, f6, f7, f8, f9, f10}), SS[2])):
max(evalf[5](abs~(%)));

{imIx[c1] = 162.01046250921478591, imIx[c2] = -76.947655535280817396, imV[at1] = -23.501877901598220297, imV[at2] = -644.96659512864599818, imV[t] = -1112.1657583147938711, reIx[c1] = 181.28189005805791743, reIx[c2] = -81.655484607695036328, reV[at1] = 27514.157016821884248, reV[at2] = 27892.767479423787347, reV[t] = 28123.363610933968927}

0.21757e-12

{imIx[c1] = -5281.4918969451713544, imIx[c2] = 2424.8308425628567005, imV[at1] = 4.9812524290496869171, imV[at2] = 56.665451734948995089, imV[t] = 1112.1657583147938711, reIx[c1] = 955.22971037032619932, reIx[c2] = -505.01568452829735058, reV[at1] = 26894.342371558787522, reV[at2] = 10829.706661003599220, reV[t] = -623.36361093396892656}

0.22944e-12

# no result
SS[3]:=fsolve(abs~((lhs-rhs)~([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10])),vars,avoid={SS[1],SS[2]}):
if op(0,eval(SS[3],1))=fsolve then print("no additional solution found"); end if;

"no additional solution found"

# Now let's attempt making procedures which (only locally) increase Digits.
#
# Since the procedure raise Digits for the functional evaluations we can
# keep top-level Digits lower (which is used by fsolve for its accuracy
# requirement.

Digits:=10;

10

oldnames:=nprintf~("%a",oldvars);

{`Ix[c1]`, `Ix[c2]`, `V[at1]`, `V[at2]`, `V[t]`}

funcs:=[seq(subs(__dummy=eval((lhs-rhs)(__eq),Equate([oldvars[]],[oldnames[]])),
            proc(`Ix[c1]`,`Ix[c2]`,`V[at1]`,`V[at2]`,`V[t]`)
              Digits:=2*Digits;
              __dummy;
            end proc),
            __eq={f1n2, f3n4, f5n6, f7n8, f9n10})]:

#infolevel[fsolve]:=0;
_EnvTry:=hard:

FS[1]:=fsolve(funcs,[180+I*160..182+I*164, -82-77*I..-80-76*I, 27510-24*I..27520-22*I,
                     27890-650*I..27900-640*I, 28120-1120*I..28130-1110*I],complex):
Equate([oldvars[]], FS[1]);
evalf[100](eval((lhs-rhs)~({f1n2, f3n4, f5n6, f7n8, f9n10}), %)):
max(evalf[5](abs~(%)));

[Ix[c1] = 181.28189005805930+162.01046250921644*I, Ix[c2] = -81.655484607695652-76.947655535281597*I, V[at1] = 27514.157016821884-23.501877901598408*I, V[at2] = 27892.767479423792-644.96659512865114*I, V[t] = 28123.363610933976-1112.1657583148028*I]

0.90855e-7

FS[2]:=fsolve(funcs,complex,avoid={FS[1]});

[955.22971037032620-5281.4918969451714*I, -505.01568452829735+2424.8308425628567*I, 26894.342371558788+4.9812524290496869*I, 10829.706661003599+56.665451734948996*I, -623.36361093396893+1112.1657583147939*I]

# no result (takes long)
#FS[3]:=fsolve(funcs,[(-infinity-infinity*I..infinity+infinity*I)$5],complex,avoid={FS[1],FS[2]}):
#if op(0,eval(FS[3],1))=fsolve then print("no additional solution found"); end if;

#
# This has 20 decimal digits in the result, but is more accurate than the
# than the S[1],SS[1] and S[2],SS[2] results obtained above at Digits=20.

Digits := 20:
AFS[1]:=fsolve(funcs,[180+I*160..182+I*164, -82-77*I..-80-76*I, 27510-24*I..27520-22*I,
              27890-650*I..27900-640*I, 28120-1120*I..28130-1110*I],complex):
Equate([oldvars[]], AFS[1]);
evalf[100](eval((lhs-rhs)~({f1n2, f3n4, f5n6, f7n8, f9n10}), %)):
max(evalf[5](abs~(%)));

AFS[2] := fsolve(funcs,complex,avoid={AFS[1]}):
Equate([oldvars[]], AFS[2]);
evalf[100](eval((lhs-rhs)~({f1n2, f3n4, f5n6, f7n8, f9n10}), %)):
max(evalf[5](abs~(%)));

[Ix[c1] = 181.281890058057917433399027+162.010462509214785906005715*I, Ix[c2] = -81.6554846076950363278550316-76.9476555352808173964757651*I, V[at1] = 27514.1570168218842476437442-23.5018779015982202969522171*I, V[at2] = 27892.7674794237873467298134-644.966595128645998186497765*I, V[t] = 28123.3636109339689265642830-1112.16575831479387114138115*I]

0.13186e-19

[Ix[c1] = 955.229710370326199319138724-5281.49189694517135435254499*I, Ix[c2] = -505.015684528297350584549199+2424.83084256285670047471394*I, V[at1] = 26894.3423715587875215982798+4.98125242904968691720452388*I, V[at2] = 10829.7066610035992203384338+56.6654517349489950911686282*I, V[t] = -623.363610933968926564282995+1112.16575831479387114138115*I]

0.22890e-19

 

Download Q_ac_20200811_ac.mw

Upload and attach your worksheet using the green up-arrow in the Mapleprimes editor.

@Scot Gould He has Maple 18, in which version your call to rand is not supported.

I have changed the "Product" label on your Question from Maple 2018 to Maple 18, since the latter is the version in which your attachments were last saved.

Maple 18 was released in the year 2014, and is four major releases old than Maple 2018.

I have deleted your duplicate Post in which you complain, without example, of the quality of the Maple GUI.

I deleted it because it is no more than a duplicate of this Post.

If you have additional details of your issues and frustrations, then post them here.

Are you using 2D Input mode, in a Document, which is the default for new users the GUI?

If so, have you tried 1D Input (plaintext "Maple Notation") mode, in a Worksheet?

Those can be set as preferences under Tools->Options in the GUI's main menubar. That is,
  1) Tools->Options->Display and toggle the "Input display" combobox entry to "Maple Notation".
  2) Tools->Options->Interface and toggle "Default format for new worksheets" to "Worksheet"

I am just guessing here. Copying input code can be problematic in 2D Input mode, since the GUI's editing facility insists it knows better and can offer only copying what it thinks are parsable portions of a larger 2D Input block. In 1D Input mode it is much more amenable to sub-selecting and copying -- ie. it allows pretty much any subselection from a block of plaintext code.

If you prefer plaintext coding, you could also utilize so-called Code-Edit Regions within a Document. But if you also have issues with Document navigation then 1D Input + Worksheet may be preferable.

The more specifics you can provide about your code editing issues the more we might be able to help.

@Scot Gould I find type realcons to be useful, because it should allow you to know that you can hit the scalar value with evalf and obtain a float.

For example,

type( sqrt(2), realcons );
              true
type( Pi, realcons );
              true

@DoingMath2018 The unevaluation quotes merely delay evaluation, and the quoted expression is not inert. Each full evaluation will strip off a set of uneval quotes. Strip off them all, and you get your original error. It's fragile because several common things induce an evaluation (eg. passing in as argument to a procedure call).

That's why I gave my second example, using %plot to obtain an inert form. The call to %plot can be evaluated, multiple times, without that same problem. When you're ready to produce the actual plot -- following substitutions and manipulations, etc -- then you can utilize the value command on it.

@Scot Gould Yes, failing to hit the upper end-point (due to roundoff error making the last value exceed the bounds) is somewhat understandable. But missing two values is odd.

By the way, I submitted a request this past year for an enhancment to seq. Instead of supplying the float increment as an option I asked to be able to supply the number of values. Eg,
   seq(a..b, number=4);     # or similar syntax
The idea is twofold: 1) To avoid roundoff issues and always hit both end-points, and 2) To avoid fencepost mistakes such as accidentally dividing b-a by N or N+1 instead of N-1, etc.

@DoingMath2018 His 3rd example is in the same vein as my first, using unevaluation (single right-quotes) to delay evalution.

There are many common scenarios in which such a quoted expression gets accidentally evaluated. For example, by passing it around as argument to some procedure call. It can be a somewhat fragile mechanism.

But even if you do not intend on passing the unevaluated call, there are still more graceful mechanisms.

For example, using a procedure.

Or substituting into the arguments of the plot call rather than into an unevaluated plot call. I think that the first of these is less contrived than the second.
  plot(x, eval(x = 0 .. a, [a=3]));
  eval('plot(x, x = 0 .. a)', [a=3]);

@Scot Gould I'm sorry, but I don't understand your comment.

I use ':-size' to try and protect against the case that the user might have assigned some irrelevant value to the global name.

I'm not sure what you are saying about images and global sections.

Note that so-called plot persistence can sometimes have an effect -- if you get rid of a plot's size option then the GUI remembers the old dimensions used to render in that output area. If a new size is not explicitly provided then it can happen that the GUI re-uses the old dimensions. Removing the old output, first, then displaying the new, gets rid of that effect. I'm not sure if you ran into this behavior, but it can be confusing when trying to figure things out.

There is no attachment.

@sunit It's easy enough to make a reusable procedure for it.

You can apply it to each equation, or to a system (set) of them.

question_sunit_ac2.mw

By the way, if you were to go with Kitonum's suggestion to convert to rational, then in general it would be better to substitute using convert(par,rational,exact) instead. (Don't incur possible roundoff error in general, if you don't have to.) I didn't show that way because it produces a result with rationals instead of the short floats, so it doesn't answer the question you actually asked.

@eslamelidy You can use the plots:-display command to combine plots.

x_e_-.008_2_ac.mw

First 161 162 163 164 165 166 167 Last Page 163 of 591