acer

32348 Reputation

29 Badges

19 years, 329 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Carl Love That is very unfortunate programming of the Java GUI.

(I spend so much time in the commandline interface that I reflexively think of its sane behaviour as "the normal manner".)

I will submit a bug report.

@Carl Love I agree with what you've written, except that I don't see it respecting interface(verboseproc) in the usual manner.

@pik1432 FYI, two solutions for the new system can also be found (quickly) as follows:

RootFinding:-Isolate(evalf[100]((lhs-rhs)~([f1,f2,f3,f4,f5,f6,f7,f8,f9,f10])),
                     [vars[]],maxroots=3,digits=20);

Q_ac_20200811_ac2.mw

You could start by providing us with details of what you did to obtain this.

You can upload and attach a Worksheet to a Comment or Question here. Use the green up-arrow in the Mapleprimes editor.

@Reshu Gupta 

G:=x -> -1.50000000000*x - 0.0170454545454*(x^4 + 17.6721666667*x^2
 - 5.11042142857)*x - 0.0197950153310*exp(-4.47213595500*x)
 + 0.0197950153310*exp(4.47213595500*x)
 + 6.62030572935*10^(-13)*(-92400.*x^4 - 82645.0724484*x^3 + 526680.*x^2
  + 241736.836912*x + 27027.)*exp(-4.47213595500*x + 4.47213595500)
  + 6.62030572935*10^(-13)*(92400.*x^4 - 82645.0724484*x^3 - 526680.*x^2
  + 241736.836912*x - 27027.)*exp(4.47213595500*x + 4.47213595500):
V:=Vector([seq(G(x),x=[seq(-1..1,0.1)])]):
P1:=plot(<<[seq(-1..1,0.1)]>|V>,style=point):
P2:=plot(G,-1..1):
plots:-display(P1,P2);
ExcelTools:-Export(V, "foo.xls");

@nm Debugging your example is easier at first, since one can trace or stopat the signum command, starting with argument  1/sin(x).

That  leads to Re(x) under the assumption. But Re is a kernel builtin, so showstat and stopat appear to be a dead end. However, some kernel builtins will also call back out to Library commands. By setting printlevel:=999: you can tell how the kernel calls back into the Library, for this example, and continue on with Library-side debugging techniques.

It gets a little awkward, as you have to also dispel the chaff after setting printlevel:=1: again. But it's workable.

So, I traced signum to find that Re(x) assuming x::{} returned 0. Then I used higher printlevel to see (fortunately) where the kernel happened to call back into the Library.

Your original question was about why the (accidental) use of assuming {} produced the division by zero error, since you had already corrected your syntax for using `assuming` in prefix form.

But for fun, a few other ways to get the more compact tan form result,

restart;

u1 := -ln(csc(x)-cot(x));

                   u1 := -ln(csc(x) - cot(x))

subs(X=x/2,convert(simplify(convert(subs(x=2*X,u1),tan)),tan));

                            /   /1  \\
                         -ln|tan|- x||
                            \   \2  //

[sin(x)=trigsubs(sin(x),trigidentity="Double Angle")[1]]:
convert(simplify(subs(%,simplify(u1))),tan);


                            /   /1  \\
                         -ln|tan|- x||
                            \   \2  //

[csc(x)=trigsubs(csc(x),trigidentity="Double Angle")[1],
 cot(x)=trigsubs(cot(x),trigidentity="Double Angle")[1]]:
convert(simplify(subs(%,u1)),tan);

                            /   /1  \\
                         -ln|tan|- x||
                            \   \2  //

@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
First 161 162 163 164 165 166 167 Last Page 163 of 592