tomleslie

13841 Reputation

20 Badges

15 years, 1 days

MaplePrimes Activity


These are replies submitted by tomleslie

@charlie_fcl 

the parallel and serial  neutral oprators only work in the context of a ladder network (but I might be worong). Certainly in this context, they work for me - see the final execution group in the attached.

  restart;
  interface(version);
  with(Syrup);
  divider := "
              V 1 0
              R1 1 2
              R2 2 0
             .end":
  Solve(divider, 'returnall');

`Standard Worksheet Interface, Maple 2022.0, Windows 7, March 8 2022 Build ID 1599809`

 

[Draw, Library, Print, Solve, ToModelica, ToSpice, Version]

 

{v[1] = V, v[2] = V*R2/(R1+R2)}, {i[R1] = V/(R1+R2), i[R2] = V/(R1+R2), i[V] = -V/(R1+R2), v[R1] = V*R1/(R1+R2), v[R2] = V*R2/(R1+R2), v[V] = V}

(1)

  bridge := "
            V a 0
            R1 a b
            R2 a c
            R3 b 0
            R4 c 0
            R5 b c
         .end":
  Solve(bridge, 'returnall');

{v[a] = V, v[b] = V*(R1*R4+R2*R4+R2*R5+R4*R5)*R3/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[c] = V*(R1*R3+R1*R5+R2*R3+R3*R5)*R4/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5)}, {i[R1] = V*(R2*R3+R2*R4+R2*R5+R4*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), i[R2] = V*(R1*R3+R1*R4+R1*R5+R3*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), i[R3] = V*(R1*R4+R2*R4+R2*R5+R4*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), i[R4] = V*(R1*R3+R1*R5+R2*R3+R3*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), i[R5] = -V*(R1*R4-R2*R3)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), i[V] = -V*(R1*R3+R1*R4+R1*R5+R2*R3+R2*R4+R2*R5+R3*R5+R4*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[R1] = V*R1*(R2*R3+R2*R4+R2*R5+R4*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[R2] = V*R2*(R1*R3+R1*R4+R1*R5+R3*R5)/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[R3] = V*(R1*R4+R2*R4+R2*R5+R4*R5)*R3/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[R4] = V*(R1*R3+R1*R5+R2*R3+R3*R5)*R4/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[R5] = -V*(R1*R4-R2*R3)*R5/(R1*R2*R3+R1*R2*R4+R1*R2*R5+R1*R3*R4+R1*R4*R5+R2*R3*R4+R2*R3*R5+R3*R4*R5), v[V] = V}

(2)

  Draw([V &// (R1 &+ R2)]);

 

``

 

Download syrup.mw

@charlie_fcl 

You worksheet is shown running in the attached. Can only think of two possibilities

One: bad installation - maybe unisntall and try again? On a Windows system the default location is usually C:\Users\yourUserName\maple\toolbox\Syrup. There should be a file called installer-log.txt in this directory: min only contains two lines

Installing toolbox Syrup into directory C:\Users\TomLeslie\maple\toolbox\Syrup.
Installation of files is complete.

Yours should say something similar (allowing for different filepaths)

Two: something in your maple.ini file may be causing the "global variables assigned error". Suggest you disableany maple.ini file you may be using (just rename it oldmaple.ini or somethiung) and restart Maple

restart

NULL

with(Syrup)

[Draw, Library, Print, Solve, ToModelica, ToSpice, Version]

(1)

NULL

divider := "
              V 1 0
              R1 1 2
              R2 2 0
             .end"

Solve(divider, 'returnall')

{v[1] = V, v[2] = V*R2/(R1+R2)}, {i[R1] = V/(R1+R2), i[R2] = V/(R1+R2), i[V] = -V/(R1+R2), v[R1] = V*R1/(R1+R2), v[R2] = V*R2/(R1+R2), v[V] = V}

(2)

NULL


 

Download maple_syrup_problem2.mw

See the attached.

Maybe a version issue? Please specify which Maple version you are using and upload your worksheet using the big green up-arrow in the Mapleprimes toolbar

  restart;
  with(Student[Calculus1]):
  InversePlot(exp(x), -1 .. 1);

 

 

Download invPlot.mw

 

@ijuptilk 

"scaling" anything, as far as I can tell - you just wnat to control how the tickmarks appear - check out the axis/tickmarks option under plot/options

I have shown a couple of examles in the attached

Scaling2.mw

@weidade37211 

the main reason is the provision of a "reasonably good" initial guess (ie y=1e-04)

Interesting that RootFinding:-NextZero() also finds the same root with little guidance, but takes noticeably longer. See the attached

  restart;
 

  Digits := 30;
  interface(displayprecision);
  with(plots):
  with(Statistics):
  alpha := 10;
  beta := 100000;
  f := unapply(PDF(BetaDistribution(alpha, beta), x),x);
  #f(x);
  #semilogplot(PDF(BetaDistribution(alpha, beta), x), x = 0 .. 1);

Digits := 30

 

-1

 

alpha := 10

 

beta := 100000

 

proc (x) options operator, arrow; piecewise(x < 0, 0, x < 1, x^9*(1-x)^99999/Beta(10, 100000), 0) end proc

(1)

  CodeTools:-Usage(RootFinding:-NextZero( y->evalf( Int(f(x), x = 0 ..y))-0.1,0));
  CodeTools:-Usage(fsolve( evalf( Int(f(x), x = 0 ..y))=0.1, y=1e-04));

memory used=2.11GiB, alloc change=80.46MiB, cpu time=17.10s, real time=16.14s, gc time=2.00s

 

0.622083116140586301765952177818e-4

 

memory used=0.92GiB, alloc change=-1.89MiB, cpu time=5.15s, real time=4.58s, gc time=889.21ms

 

0.622083116140586301765952177817e-4

(2)

 

 

Download getRoot.mw

@ijuptilk 

understand the requirement, and your latest explanation doesn't help.

In the attached, for each value of 'xi', I have plotted the imaginary parts of entries in the associated table of 'p'. It would seem that

  1. As noted before, for some values of 'xi', the associated table of 'p' contains no complex entries
  2. For those values of 'xi' for which the table 'p' does contain complex entries, then the table 'p' always has exactly two complex entries
  3. These two complex entries "appear" to be conjugates

cutPaste7.mw

@ijuptilk 

The worksheet cutpaste6.mw does the calculation you require for 51 values of xi. For each of these 51 values, it returns a table 'p' with 11 entries. Some of these table contain complex entries and some do not.

If xi is in the list

[-10, -9.6000000000, -9.2000000000, -8.8000000000, -8.0000000000, -7.6000000000, -7.2000000000, -6.8000000000, -6.0000000000, -5.6000000000, -5.2000000000, -4.8000000000, -4.4000000000, -4.0000000000, -3.6000000000, -2.8000000000, -2.4000000000, -0.4000000000]

then the associated table for 'p' contains at least one complex entry out of 10

If xi is in the list

[-8.4000000000, -6.4000000000, -3.2000000000, -2.0000000000, -1.6000000000, -1.2000000000, -0.8000000000, 0.0000000000, 0.4000000000, 0.8000000000, 1.2000000000, 1.6000000000, 2.0000000000, 2.4000000000, 2.8000000000, 3.2000000000, 3.6000000000, 4.0000000000, 4.4000000000, 4.8000000000, 5.2000000000, 5.6000000000, 6.0000000000, 6.4000000000, 6.8000000000, 7.2000000000, 7.6000000000, 8.0000000000, 8.4000000000, 8.8000000000, 9.2000000000, 9.6000000000, 10.0000000000]

then the associated table for 'p' contains no complex entries.

As an example the worksheet cutPaste6.mw shows that for xi=-0.4, the table of values for 'p' consists of

table([1 = -10.6007308700 - 23.3886061400*I, 2 = -10.6007308700 + 23.3886061400*I, 3 = -6.9133740120, 4 = 6.3026023660, 5 = 2.0333066090, 6 = 1.0785020780, 7 = 0.6802764902, 9 = 0.3472324856, 8 = 0.4715142468, 11 = 0.2117250312, 10 = 0.2668566565])

so two entries are complex and nine are not. The imaginary parts of the two complex numbers are - 23.3886061400*I and 23.3886061400*I. Apparently you want to plot these "against" something - but what?

If you cannot specify precisely what you want, I'm not even going to try

@ijuptilk 

for tuition in basic Maple - I suggest checking the page at

https://www.maplesoft.com/documentation_center/

in particular the entries


The command

[ seq( `if`( member( complex(extended_numeric), whattype~({entries(ans[j,5], nolist)})), ans[j,1], NULL), j=1..op([2,1,2], ans))];

can be broken down as follows.

The doCalc() procedure returns the table p() which you requested - if it is called with command

ans:=[doCalc(-0.4)]:

this table will occupy the fourth element of the list ans().

On the other hand if it i called with the command

ans:= Array([seq( [j, doCalc(j)], j=-10..10, 0.4)]):

these tables of p-values will ocuupy the fifth "column" of the array 'ans'. This is the case I am going to discuss in the following

  1. Step 1:  ({entries(ans[j,5], nolist)}. For any value of 'j' (think any value of 'xi') this ectract the corresponing entries f the table() named 'p' in doCalc and (for conveinience) converts these values to a set
  2. Step 2: : whattype~({entries(ans[j,5], nolist)}): this determines the datatype of the entries in the set of values in the table 'p'. The way this data is produced, there are only two possibilities - either the entry is a "simple floating point number, in which case the corresponding value from whattype() will be 'float' or the data is a complex number, in wihc case the corresponding value from whattype() fill be complex(extended_numeric), indicating that the entry is a complex number. Since the operation is applied to a set (see 1 above) the return value from whattype~() will also be a set. MAthematical sets cannot contain duplicate entries so teh only three possibilities for the set returned by this command are
    1. {float} no complex entries are in the table 'p'
    2. {complex(extended_neumeric)}: all entries in the table 'p' are complex
    3. {float, complex(extended_numeric)}: some entries in the table 'p are simple floats, and some are complex
  3. Step 3: member( complex(extended_numeric), whattype~({entries(ans[j,5], nolist)}): this determines whether the datatype complex(extended_numeric) ever occurs in the table of p-values
  4. Step 4: `if`( member( complex(extended_numeric), whattype~({entries(ans[j,5], nolist)})), ans[j,1], NULL): if a complex value does occur anywhere then output the corresponding value of ans[j,1] which is the value of 'xi'
  5. The seq() wrapper: this just applies the process defined in (1)-(4) above, to all entries inthe returned array

Since

member( complex(extended_numeric), whattype~({entries(ans[j,5], nolist)}))

returns entries which contain complex values in the table 'p', then the negation of this condition, ie

not member( complex(extended_numeric), whattype~({entries(ans[j,5], nolist)}))

returns entries which do not contain complex vslues in the table 'p'. Looks like I was wrong in my original statement that all xi-values < -3.6 have an associated 'p-table' with complex entries!. As the associated demonstrates xi=-8.4 and xi=-6.4 do not have complex values in the associated p-table

cutPaste6.mw

@ijuptilk 

way to do this is just to return the table 'p' for each xi-value, and then run a type check on its entries, as in the attached, where the last execution group returns the list beow.

[-10, -9.6000000000, -9.2000000000, -8.8000000000, -8.0000000000, -7.6000000000, -7.2000000000, -6.8000000000, -6.0000000000, -5.6000000000, -5.2000000000, -4.8000000000, -4.4000000000, -4.0000000000, -3.6000000000, -2.8000000000, -2.4000000000, -0.4000000000]

Looking at this list it would seem (you might want to check!)  that

  1. xi has to be negative
  2. larger negative values (ie <-3.6) always return complex values
  3. smaller negative values( is -3.6<xi<0) may or may not return complex values - seems a bit 'random' in this range
  4. positve xi-values never return complex values

cutPaste5.mw

@ijuptilk 

You plot for t =1..10 with size of 0.1.

means you want one hundred curves on one graph! This will be illegible! Combined with the variation in xi-values (of which there are about 50), you could end up witth a one graph with 5000 curves on it - get real!

In the attached I have generated curves of v_sol for t=1, t=5, t=10 - if you want to change this feel free!

Now depending on the value of 'xi' the vertical scale on the plots of v_sol can vary from around +/--10^-8 to +/-10^+12, so plotting them all on the same graph would be pretty pointless. So in the attached I have given three differenet v_sol plots - xi=-10..-8.6, xi=-0.8..0.8 and xi=8.6..10 (more-or-less!).

NB this worksheet now takes a couple of minutes to compute on my machine (and won't display inline on this site - probably a size issue)
cutPaste4.mw

@Injective 

original question states that the tangent point is [11, -12], so I was just looking for a convenient way to specify/vary the plotting ranges around this point so that an acceptable plot showing the tangency would be obvious.

With the tangency point at [11,-12], one way to specify desirable plotting ranges is 11-r..11+r, -12-r..-12+r where 'r' is a supplied (preferably smallish) number. The fact that I defined the tangency point using pt:=[11, 12], just means that these ranges change to pt[1]-r..pt[1]+r, pt[2]-r..pt[2]+r

You can try varying the value or 'r' in my original response - this will essentially act as a 'zoom' control, so you can decide for yourself at what "scale" the plot is acceptable.

One problem is that over wider plotting ranges, the function

exp(t^2+10*u-1)

varies (a lot) while the function

 -121+22*t+10*u

only varies a little. In my opinion this made the resulting plot difficult to interpret, because the tangency was obscured. This is a question of  "aesthetics" and is just my opinion - yours may differ.

An alternative would be to adopt the approach given by Acer where the ranges of 'u' and 't' are increased but the 'view' option is used to restrict (ie 'zoom') the plot in the 'z' direction. Both my and Acer's plots are correct - you have to decide which one you prefer

@ijuptilk

you think that you are going to get exavt cancellation of imaginary parts in  floating-pointcalculation you are in dreamland, so some combination of Re(), fnormal() or simplify(..., zero) is probaby going to be necessary. Before I even attempt this, you are going to have to be much clearee on what you want.

Taks v_sol as an example

  1. This is a function of 'z' and 't' - so do you wnat it evaluated a a specific value of 't' and plotted over a range of z-values, thus producing a single curve. If so what value of 't'?
  2. Do you want it evaluated for several values of 't' and plotted over a range of z-values, thus producing mulitple curves in a single 2D plot. If so what are the t-values?
  3. Do you want it plotted over a range of both 't' and 'z', ie a 3D plot, if so what is the range for 't'?

I have a limited amount of time to waste on this so be specific

@ijuptilk 

the plot within the procedure and return it as shown in the attached for theta_init: this was a bad example for me to pick because it seems that this does not depend on 'xi', so when computing

seq( [j, doCalc(j)], j=-10..10, 0.4)]

one gets ~50 identical plots - but the principle is the same. I did consider doing the same with v_sol, but this generates complex values and I have no idea how you plan to handle these for plotting purposes
cutPaste3.mw

@ijuptilk 

use the procedure doCalc() which I provided in my previous answer? You think I write this stuff for you to ignore?

It is trivial to adjust this to generate the values you require - see attached.

  restart;
  doCalc:= proc( xi )
                 uses ArrayTools, Student:-Calculus1, LinearAlgebra,
                      ListTools, RootFinding, ListTools:
                 local gamma1:= .1093,
                       alpha3:= -0.1104e-2,
                       k__1:= 6*10^(-12),
                       d:= 0.2e-3,
                       theta0:= 0.1e-3,
                       eta__1:= 0.240e-1,
                       alpha:= 1-alpha3^2/(gamma1*eta__1),
                       c:= alpha3*xi*alpha/(eta__1*(4*k__1*q^2/d^2-alpha3*xi/eta__1)),
                       theta_init:= theta0*sin(Pi*z/d),
                       n:= 10,
                       g, f, b1, b2, qstar, OddAsymptotes, ModifiedOddAsym,
                       qstarTemporary, indexOfqstar2, qstar2, AreThereComplexRoots,
                       soln1, soln2, qcomplex1, qcomplex2, gg, qq, m, pp, j, i,
                       AllAsymptotes;

                 g:= q-(1-alpha)*tan(q)-c*tan(q):
                 f:= subs(q = x+I*y, g):
                 b1:= evalc(Re(f)) = 0:
                 b2:= evalc(Im(f)) = 0:
                 qstar:= (fsolve(1/c = 0, q = 0 .. infinity)):
                 OddAsymptotes:= Vector[row]([seq(evalf(1/2*(2*j + 1)*Pi), j = 0 .. n)]);
                 ModifiedOddAsym:= abs(`-`~(OddAsymptotes, qstar));
                 qstarTemporary:= min(ModifiedOddAsym);
                 indexOfqstar2:= SearchAll(qstarTemporary, ModifiedOddAsym);
                 qstar2:= OddAsymptotes(indexOfqstar2);
                 AreThereComplexRoots:= type(true, 'truefalse');
                 try
                      soln1:= fsolve({b1, b2}, {x = min(qstar2, qstar) .. max(qstar2, qstar), y = 0 .. infinity});
                      soln2:= fsolve({b1, b2}, {x = min(qstar2, qstar) .. max(qstar2, qstar), y = -infinity .. 0});
                      qcomplex1:= subs(soln1, x+I*y);
                      qcomplex2:= subs(soln2, x+I*y);
                 catch:
                       AreThereComplexRoots:= type(FAIL, 'truefalse');
                 end try;
                 OddAsymptotes:= Vector[row]([seq(evalf((1/2)*(2*j+1)*Pi), j = 0 .. n)]);
                 AllAsymptotes:= sort(Vector[row]([OddAsymptotes, qstar]));
                 if   AreThereComplexRoots
                 then gg:= [ qcomplex1,
                             qcomplex2,
                             op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1])),
                             seq(op(Roots(g, q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)
                          ];
                 elif not AreThereComplexRoots
                 then gg:= [ op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1])),
                             seq(op(Roots(g, q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)
                           ];
                 end if:
                 qq:= MakeUnique(gg):
                 m:= numelems(qq):
                 return min( seq( Re(gamma1*alpha/(4*k__1*qq[i]^2/d^2-alpha3*xi/eta__1)), i=1..m) );

            end proc:

#
# Generate OP's new data set
#
 
  [seq( [0.4*i, doCalc(0.4*i)], i=-2..5)];

[[-.8, -5.065576388], [-.4, -10.60073087], [0., .1673358931], [.4, .1976007899], [.8, .1912238737], [1.2, .1852464118], [1.6, .1796319481], [2.0, .1743483388]]

(1)

 

Download cutPaste2.mw

If you really want to know what is wrong with yur latest worksheet,examine the execution group

OddAsymptotes := Vector[row]([seq(evalf((1/2)*(2*j+1)*Pi), j = 0 .. n)]); 
AllAsymptotes := seq(sort(Vector[row]([OddAsymptotes, qstar[i]])),i=1..n);
if AreThereComplexRoots then
gg := seq([qcomplex1, qcomplex2, op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g[j], q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)], j=1..n);
elif not AreThereComplexRoots then
whattype(AllAsymptotes[1]);
numelems(AllAsymptotes[1]); 
gg := seq([op(Roots(g[i], q = 0.1e-3 .. AllAsymptotes[1])), seq(op(Roots(g[i], q = AllAsymptotes[i] .. AllAsymptotes[i+1])), i = 1 .. n)], j=1..n);
end if;

The command allAsymptotes generates a  a length=5 sequence of seven vectors

AllAsymptotes := Vector[row](7, [1.5707963270, 4.7123889810, 7.8315600850, 7.8539816350, 10.9955742900, 14.1371669400, 17.2787596000]),
                 Vector[row](7, [1.5707963270, 4.7123889810, 5.5377492410, 7.8539816350, 10.9955742900, 14.1371669400, 17.2787596000]),
                 Vector[row](7, [0, 1.5707963270, 4.7123889810, 7.8539816350, 10.9955742900, 14.1371669400, 17.2787596000]),
                 Vector[row](7, [0, 1.5707963270, 4.7123889810, 7.8539816350, 10.9955742900, 14.1371669400, 17.2787596000]),
                 Vector[row](7, [0, 1.5707963270, 4.7123889810, 7.8539816350, 10.9955742900, 14.1371669400, 17.2787596000])

so when you use a command such as

op(Roots(g, q = 0.1e-3 .. AllAsymptotes[1]))

you are asking for roots in the range

q = 0.1e-3 .. Vector[row](7, [1.5707963270, 4.7123889810, 7.8315600850, 7.8539816350, 10.9955742900, 14.1371669400, 17.2787596000])

which is obviously not a meaningful way to define a range

try the commands implicitplot() and implicitplot3d()

First 19 20 21 22 23 24 25 Last Page 21 of 207