tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

A quoick check suggest that the command

restart;
with(Statistics):
Histogram(Sample(Poisson(200),10000));

works in Maple2015, Maple2016, Maple2017, Maple2018 and fails in Maple2019, Maple2020 and Maple2021

@jrive 

on my original post is shown in the attached. Basically when you compute the desired result from solving the ODE;s (aka the transient analysis), you need to use the simplification

simplify(expand(vcm))

and when you compute the results from the  transfer function (aka the ac analysis) you need to use the simplification

 simplify ( expand( convert( v2, exp)  )  )

The latter has the "extra" part of convert(.., exp) simoly to change the hyperbolix sines and cosines to exponential form before using the same simplify(expand(..)) construct

  restart:
  with(Syrup):
  with(inttrans):
#
# Set up the problem
#
  ckt:= [ vin(5), Rm(1.00000000*10^7), Cm(1.80000000*10^(-11), ic = 0),
          R1(9.00000000*10^6) &// C1(1.50000000*10^(-11), ic = 0),
          R2(1.00000000*10^6) &// C2(1.50000000*10^(-11), ic = 0)
        ]:
  Draw(ckt);

 

#
# Get the voltage across the capacitor by solving
# the odes (basically a transient analysis)
#
  vcm:= eval
        ( v[Cm](t),
          dsolve
          ( Solve
            ( ckt,
              'tran'
            )
          )
        );
  simplify(expand(vcm));

  

(1/3)*exp((100000/459)*(-119+8041^(1/2))*t)*((61/64328)*8041^(1/2)-1/8)*8041^(1/2)-(1/3)*exp(-(100000/459)*(119+8041^(1/2))*t)*(-(61/64328)*8041^(1/2)-1/8)*8041^(1/2)+(91/3)*exp((100000/459)*(-119+8041^(1/2))*t)*((61/64328)*8041^(1/2)-1/8)+(91/3)*exp(-(100000/459)*(119+8041^(1/2))*t)*(-(61/64328)*8041^(1/2)-1/8)+5/2

 

(1/32164)*(-415*8041^(1/2)-40205)*exp((100000/459)*(-119+8041^(1/2))*t)+5/2+(1/32164)*(415*8041^(1/2)-40205)*exp(-(100000/459)*(119+8041^(1/2))*t)

(1)

#
# Get the transfer function to the node '2' (basically
# an ac analysis) then compute the step response, and
# convert the result from hyperbolic trig functions to
# exponentials
#
  v2:= invlaplace
       ( eval
         ( v[2],
           [ Solve
             ( ckt,
               returnall
             )
           ][1]
         )/s,
         s,
         t
        );
  simplify
  ( expand
    ( convert( v2, exp)
    )
  )

5/2-(5/16082)*exp(-(700000/27)*t)*(83*8041^(1/2)*sinh((100000/459)*t*8041^(1/2))+8041*cosh((100000/459)*t*8041^(1/2)))

 

(1/32164)*(-415*8041^(1/2)-40205)*exp((100000/459)*(-119+8041^(1/2))*t)+5/2+(1/32164)*(415*8041^(1/2)-40205)*exp(-(100000/459)*(119+8041^(1/2))*t)

(2)

 

Download ckt2.mw

 

 

 

@vv 

ending lines with a colon character is always a good idea. For your example, the following produces all the roots - although the approach using solve() does take about 100X as long as the NextZero() method I gave in my answer to the original problem


 

  restart;
  t1:=time():
  f:= x->`if`( op(1,x)<0,
               eval(x, indets(x)[]=1),
               op(1,x)
             ):
  s:= evalf~(allvalues~(evalc([solve(  sin(x) - cos(32*x - 1/6*Pi), allsolutions=true)]))):
  sort(f~(s));
  time()-t1;

[.2624151526, .2898423107, .4516480506, .5117310995, .5535175381, .6715402386, .7978598477, .8268311013, .9799540589, 1.015435066, 1.079197326, 1.182321824, 1.205863540, 1.324559486, 1.373787975, 1.385003218, 1.396263401, 1.514553350, 1.537494327, 1.586662957, 1.587686610, 1.777062502, 1.790370034, 1.833991023, 1.967463957, 1.993053514, 2.158000104, 2.196174652, 2.354397867, 2.370775537, 2.490954360, 3.137583529, 3.141592654, 3.402624820, 3.490658505, 3.617633491, 3.654858472, 3.832407567, 3.889024336, 3.929326060, 4.020588302, 4.063210209, 4.222616215, 4.252281690, 4.258617670, 4.318174945, 4.425254183, 4.442656394, 4.509502940, 4.626153004, 4.627937566, 4.633055833, 4.823455392, 4.830620963, 5.013855103, 5.033304698, 5.119570761, 5.204279701, 5.235987757, 5.396845861, 5.444149293, 5.585053607, 5.660387531, 5.845329165]

 

39.110

(1)

  restart;
  with(RootFinding):
  sols:= []:
  tmp:=0:
  t1:=time():
  while true do
        tmp:= NextZero
              (  x -> sin(x) - cos(32*x - 1/6*Pi),
                 tmp
              );
        if   tmp <= evalf(2*Pi) then
             sols:= [sols[], tmp];
        else break;
        fi:
  end do:
  sols;
  time()-t1;

[0.6346651825e-1, .1689028308, .2538660730, .3715862278, .4442656277, .5742696248, .6346651825, .7769530218, .8250647373, .9796364188, 1.015464292, 1.182319815, 1.205863846, 1.385003212, 1.396263401, 1.586662956, 1.587686609, 1.777062511, 1.790370006, 1.967462065, 1.993053403, 2.157861620, 2.195736800, 2.348261175, 2.398420197, 2.538660730, 2.601103594, 2.729060284, 2.803786991, 2.919459839, 3.006470388, 3.109859394, 3.209153785, 3.300258949, 3.411837182, 3.490658503, 3.614520579, 3.681058058, 3.817203976, 3.871457613, 4.019887373, 4.061857168, 4.222570770, 4.252256723, 4.425254167, 4.442656277, 4.627937564, 4.633055832, 4.823455387, 4.830620961, 5.013854942, 5.033304358, 5.204254496, 5.235987755, 5.394654051, 5.438671152, 5.585053606, 5.641354549, 5.775453161, 5.844037947, 5.965852715, 6.046721344, 6.156252270, 6.249404741]

 

.328

(2)

 

Download roots4.mw

@acer 

to get (floating point) values for all roots of the OP's original problem with the attached, but in this instance I prefer the RootFinding() approach of my original answer

  restart;
  f:= x->`if`( op(1,x)<0,
               eval(x, indets(x)[]=1),
               op(1,x)
             ):
  s:= evalf~(allvalues~(evalc([solve( sin(x)-cos(4*x - 1/6*Pi), allsolutions=true)]))):
  sort(f~(s));

[.4188790182, 1.675516082, 1.745329252, 2.932153142, 3.839724355, 4.188790205, 5.445427267, 5.934119457]

(1)

 


 

Download roots3.mw

 

@The function 

is shown in the attached

restart

with(RootFinding)
sols := []
tmp := 0; whie*true

do tmp := NextZero(proc (x) options operator, arrow; sin(x)-cos(4*x-(1/6)*Pi) end proc, tmp); if tmp <= evalf(2*Pi) then sols := [sols[], tmp] else break end if end do

sols

whie*true

 

[.4188790204, 1.675516081, 1.745329251, 2.932153143, 3.839724354, 4.188790204, 5.445427266, 5.934119456]

(1)

 

The first time you tried this, Maple's 2-D input parse didn't like the fact that there was a lot of spaces (and a newline) between NextZero and it's opening parenthesis. 2-D input is very fussy about "whitespace" - one of the reasons I never use it!. I prefere to use 1-D input and control my own code layout (indentation etc)

When you converted back to 1-D input you manage to get a '*' symbol between NextZero and it's opening parenthesis
 

Download roots2.mw

@Muhammad Usman XJTU 

which I will repeat here until you show some sign of understanding it.

ode1 is a first-order equation - so can only support one initial (boundary??!!) condition. Most people would consider this to be an IVP rather than a BVP.

In the above statement - which is the word you don't understand?

Making any attempt to use more than one initial(bounary?) condition will FAIL - so stop trying

As written U() - with () parentheses is a function. which doesn't seem to make any sense!

Did you mean U[] which would be an indexable entity?

@jalal ,

just use a list of lists in the filled=option as in the attached


 

``

P1 := plot(5*sin(3*theta), theta = 0 .. 2*Pi, coords = polar, color = magenta, thickness = 3, filled = [color = green, transparency = .5])

 

P2 := plot(5*cos(3*theta), theta = 0 .. 2*Pi, coords = polar, color = red, thickness = 3, filled = [color = blue, transparency = .5])

 

P3 := plot(5, theta = 0 .. 2*Pi, coords = polar, color = black, thickness = 3, filled = [color = yellow, transparency = .9])

 

plots:-display(P1, P2, P3, axes = none)

 

plots:-animate(plot, [[5*sin(a*theta), 5*cos(a*theta), 5], theta = 0 .. 2*Pi, coords = polar, color = [green, red, black], thickness = 3, filled = [[color = blue, transparency = .5], [color = yellow, transparency = .5], [color = green, transparency = .5]]], a = 2 .. 6)

 

NULL

NULL


 

Download anim3.mw

@The function 

I haven't laughed this much for a long time

@The function 

Over the years I have read many fo Rouben's answers on this site - and learned a lot from them.

You appear to think (assuming you can think?) that applying brainpower is not relevant. Let me inform you

  1. I'm old enough to do simple coordinate transformations using pencil and paper
  2. I'm old enough to do simple coordinate transformations with a slide rule
  3. I'm old enough to do simple coordinate transformations with a calculator
  4. I can fix your problem using Maple
  5. You can't fix it using any of the above, because you cannot perform a simple coordinate transformation
  6. This makes one of us seriously limited intellectually - can you work out who?

@The function 

one of them plots Re(f(x)) versus x together with Im(f(x)) versus x and the other plots Im(f(x)) versus Re(f(x)) - exactly ehat is difficut to understand?

@vv 

till I played around a little more.

The success/failure of the add() command appears to depend on whether or not it was preceded by a seq() command.

Since these two commands *ought* to be independent (compartmentalised?) this is just seriously weird

@vv 

As yu can see from the original worksheet I posted, with compile=false, both add() and seq()  work.

I thing that the source of the error may be due to the fact that one is doing an elementwise add of two-element arrays. Maybe such an operation is not available when "compiled".

@acer 

For the expression 1/sin(x*y), can someone provide me with values for 'x' and 'y' which would make 1/sin(x*y)=0.

Cos if you can't then most of the above is pretty fair crap

Sometimes wetware beats software?

Both Maple and the referenced wikipedia article us the classification produced here

https://www.gap-system.org/

It is relatively simple to generate the numbers of groups of given order, subdivided into Abelian and non-Abelian, as shown in the attached

  restart;
#
# Number of Abelian groups of order up to 31.
# Compare with the equivalent table at
#
# https://en.wikipedia.org/wiki/List_of_small_groups#Small_groups_library
#
# and the integer sequence at
#
# https://oeis.org/A000688
#
  seq(GroupTheory:-NumAbelianGroups(j), j=1..31);
#
# Number of non- Abelian groups of order up to 31.
# Compare with the equivalent table at
#
# https://en.wikipedia.org/wiki/List_of_small_groups#Small_groups_library
#
# and the integer sequence at
#
# https://oeis.org/A060689
#
  seq(GroupTheory:-NumGroups(j)-GroupTheory:-NumAbelianGroups(j), j=1..31);

1, 1, 1, 2, 1, 1, 1, 3, 2, 1, 1, 2, 1, 1, 1, 5, 1, 2, 1, 2, 1, 1, 1, 3, 2, 1, 3, 2, 1, 1, 1

 

0, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 9, 0, 3, 0, 3, 1, 1, 0, 12, 0, 1, 2, 2, 0, 3, 0

(1)

 

Download smallG.mw

First 28 29 30 31 32 33 34 Last Page 30 of 207