dharr

Dr. David Harrington

8507 Reputation

22 Badges

21 years, 42 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

I'm guessing there are further rules to appear?

(I'm a liitle surprised my earlier code https://www.mapleprimes.com/questions/233777-Pythagorean-Puzzle#answer285102 works for these edge cases, since I didn't think about them at the time.)

Building on Joe Riel's solution, here are three solutions with two resistors. In each case one resistor current is 1 A and the other is 0 A. Resistance procedure is in startup code region

restart

with(GraphTheory):

@Joe Riel's solution with the second resistor disconnected

G1 := GraphTheory:-Graph(["gnd", "1", "2", "3"], {[{"1", "gnd"}, 1], [{"2", "3"}, 1]}):

GraphTheory:-SetVertexPositions(G1, [[0, 0], [0, 1], [1, 1], [2, 1]]):

GraphTheory:-DrawGraph(G1);
EquivResistance = Resistance(G1, "1", "gnd")

EquivResistance = 1

If it has to be connected.

G2 := GraphTheory:-Graph(["gnd", "1", "2"], {[{"1", "2"}, 1], [{"1", "gnd"}, 1]}):

GraphTheory:-SetVertexPositions(G2, [[0, 0], [0, 1], [1, 1]]):

GraphTheory:-DrawGraph(G2);
EquivResistance = Resistance(G2, "1", "gnd")

EquivResistance = 1

If it has to be connected both ends

G3 := GraphTheory:-Graph(["gnd", "1", "2", "3"], {[{"1", "2"}, 1], [{"1", "3"}, 0], [{"1", "gnd"}, 1], [{"2", "3"}, 0]}):

GraphTheory:-SetVertexPositions(G3, [[0, 0], [0, 1], [1, 1], [1/2, 1/2]]):

GraphTheory:-DrawGraph(G3);
EquivResistance = Resistance(G3, "1", "gnd")

EquivResistance = 1

NULL

Download OneOhm.mw

Not sure exactly what you want - here is a start.

restart

Use GroupTheory - group is deprecated

with(GroupTheory):

a := Perm([[2, 3, 5], [4, 7, 6]]);

_m486598272

_m486592800

H := Group({a, b});

_m485510144

elems := convert(Elements(H), list);

[_m483701280, _m483705632, _m483706528, _m483707424, _m483708320, _m483709344, _m483710240, _m483711136, _m483712032, _m483712928, _m483713184, _m483714016, _m483714848, _m483715744, _m483716640, _m483718880, _m483719712, _m483720544, _m485479424, _m486592800, _m486598272]

21

Product of all elements of H in the above order

`.`(elems[]);

_m483719712

DrawCayleyTable(H);

NULL

NULL

Download Group.mw

Edit: here some of it in the older group package, if you have Maple earlier than version 17

oldgroup.mw

S := sum(cos(i*x)/cos(x)^i, i = 0 .. n);

cos(x)*sin((n+1)*x)/(sin(x)*cos(x)^(n+1))

``

Download sum.mw

If you export as .rtf, you should be able to open it in Word, in a form that allows it to be modified.

Select all the font files (ctrl-A), and then the right-click menu has install or install for all users. (Double-clicking a single font file will install it.)

Not sure exactly what shape and size you want, but easiest to just declare b as an upper triangular matrix before generating the b[i,j] which go into it.You then get an error because you assigned a non zero entry for the lower triangular part. (Edit: I removed b[j,i]:=b[i,j] to fix that.) Probably you can fix this up to do what you want. (You should avoid using b for more than one purpose.)

bmatrix.mw

Yes, if typesetting is standard then you get the 2D output close to the version you see.

`Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`                         sol := y(x) = -cos(x) + _C1

Note that for the lprinted lines, each line is delimited with backquotes, so you could use this to insert linebreaks.

Well, I would just use view not to see the others, since you end up making another list otherwise. But I fixed your `if`; you want NULL to remove the list element (and there was something strange about the first "abs")

Download plotting.mw

II:=int(q*(ln((-(w+t)^2+(q+p)^2-I*n)/(-(w+t)^2+(q-p)^2-I*n))
    +ln((-(-w+t)^2+(q+p)^2-I*n)/(-(-w+t)^2+(q-p)^2-I*n))), q,'CauchyPrincipalValue'):
simplify(II) assuming positive;

The answer is very long and probably not useful. But don't you want some integration limits?

I modified my earlier version to include the resistances as the edge weights and modified it also to accept non-integer vertex labelling (as often used in SpecialGraphs).

Resistance:=proc(G::Graph,Vin,Vout)
  local dG,VertexIn,VertexOut,nV,nE,currents,voltages,VertexLabels,
    currInOut,nodeeqns,deviceeqns,arcs,k,i,v,x,ans,R,wG;
  uses GraphTheory;
  if IsDirected(G) then error "Must be an undirected graph" end if;
  nV:=NumberOfVertices(G);
  nE:=NumberOfEdges(G);
  # convert unweighted Graph to weighted Graph with unit weights
  if IsWeighted(G) then wG:=CopyGraph(G) else wG:=MakeWeighted(G) end if;
  R:=WeightMatrix(wG);
  # convert to graph with integer vertex names
  VertexLabels:=Vertices(wG);
  wG:=RelabelVertices(wG,[$(1..nV)]);
  if not member(Vin,VertexLabels,'VertexIn') then error "Vin is not a vertex of the Graph" end if;
  if not member(Vout,VertexLabels,'VertexOut') then error "Vout is not a vertex of the Graph" end if;
  if VertexIn=VertexOut then return 0 end if;
  VertexIn,VertexOut:={VertexIn,VertexOut}[]; # want VertexIn<VertexOut
  arcs:=map(convert,Edges(wG),list);
  dG:=Graph(Vertices(wG),arcs); # directed version required for signed incidence matrix
  # Define voltages per node. Current arrow direction for edge {j,k} is j->k (j<k)
  currents:=[seq(i[j],j=1..nE)];
  voltages:=[seq(v[j],j=1..nV)];
  # unit current in and out through VertexIn and VertexOut 
  currInOut:=Vector(nV,0);
  currInOut[VertexIn]:=1;
  currInOut[VertexOut]:=-1;
  # Node equations from incidence matrix - rows are vertices, columns are edges.
  # One of these equations is redundant, but solve can handle that
  nodeeqns:={LinearAlgebra:-GenerateEquations(IncidenceMatrix(dG,reverse),currents,currInOut)[]};
  # Device equations - Ohm's law
  deviceeqns:=table();
  for k to nops(arcs) do
    x:=arcs[k];
    deviceeqns[k]:=v[x[1]]-v[x[2]]=i[k]*R[x[]]
  end do;
  deviceeqns:=convert(deviceeqns,set);
  # Solve the equations
  ans:=solve(nodeeqns union deviceeqns,{currents[],voltages[]});
  eval(v[VertexIn]-v[VertexOut],ans)
end proc:

 

with(GraphTheory):

G:=Graph({[{"000","400"},4],[{"400","450"},5],[{"450","050"},4],[{"050","000"},5],
          [{"003","403"},4],[{"403","453"},5],[{"453","053"},4],[{"053","003"},5],
          [{"000","003"},3],[{"400","403"},3],[{"450","453"},3],[{"050","053"},3]}):

Resistance(G,"000","453"); # body diagonal

156/47

``

 

Download GraphResistance.mw

ODEPlotParams.mw

For each point on the grid it solves the ode, so increasing the grid resolution slows the plot down.

Not sure why, but a change of variables works.
 

restart

ode1 := diff(T__3(t), t, t)+3*(diff(a(t), t))*(diff(T__3(t), t))/a(t)+(2*(diff(a(t), t, t))/a(t)+6*(diff(a(t), t))^2/a(t)^2+(-Omega^2+6)/a(t)^2)*T__3(t)

diff(diff(T__3(t), t), t)+3*(diff(a(t), t))*(diff(T__3(t), t))/a(t)+(2*(diff(diff(a(t), t), t))/a(t)+6*(diff(a(t), t))^2/a(t)^2+(-Omega^2+6)/a(t)^2)*T__3(t)

lower case zeta since Zeta is the zeta function (type it in rather than 2-D pallete that gives Zeta but looks the same)

at := zeta*(1-(1-t/zeta)^2)^(1/2)

zeta*(1-(1-t/zeta)^2)^(1/2)

ode2 := eval(ode1, a(t) = at);

diff(diff(T__3(t), t), t)+3*(1-t/zeta)*(diff(T__3(t), t))/((1-(1-t/zeta)^2)*zeta)+(2*(-(1-t/zeta)^2/((1-(1-t/zeta)^2)^(3/2)*zeta)-1/((1-(1-t/zeta)^2)^(1/2)*zeta))/(zeta*(1-(1-t/zeta)^2)^(1/2))+6*(1-t/zeta)^2/((1-(1-t/zeta)^2)^2*zeta^2)+(-Omega^2+6)/(zeta^2*(1-(1-t/zeta)^2)))*T__3(t)

Change of variables

itr := z = t/zeta-1;

z = t/zeta-1

t = (1+z)*zeta

(diff(diff(T__3(z), z), z))/zeta^2-3*z*(diff(T__3(z), z))/((-z^2+1)*zeta^2)+(2*(-z^2/((-z^2+1)^(3/2)*zeta)-1/((-z^2+1)^(1/2)*zeta))/(zeta*(-z^2+1)^(1/2))+6*z^2/((-z^2+1)^2*zeta^2)+(-Omega^2+6)/(zeta^2*(-z^2+1)))*T__3(z)

sol := dsolve(ode3, T__3(z));

T__3(z) = _C1*LegendreP((-Omega^2+1)^(1/2)-1/2, ((1/2)*I)*15^(1/2), z)/(z^2-1)^(1/4)+_C2*LegendreQ((-Omega^2+1)^(1/2)-1/2, ((1/2)*I)*15^(1/2), z)/(z^2-1)^(1/4)

Change back to t

solt := PDEtools:-dchange(itr, sol, [t], params = {Omega, zeta})

T__3(t) = _C1*LegendreP((-Omega^2+1)^(1/2)-1/2, ((1/2)*I)*15^(1/2), t/zeta-1)/((t/zeta-1)^2-1)^(1/4)+_C2*LegendreQ((-Omega^2+1)^(1/2)-1/2, ((1/2)*I)*15^(1/2), t/zeta-1)/((t/zeta-1)^2-1)^(1/4)

 


 

Download solve3.mw

I'm not sure I understand fully, but the following shows how to get an exponential rise or fall between two values. If you want to upload a worksheet to demonstrate more clearly your problem, use the green up arrow in the editor.
 

restart;

Exponential from max to min or min to max. Assume a form like

y:=a+b*exp(-c*t);

a+b*exp(-c*t)

From max down to min

eqns:=[eval(y,t=0)=ymax,limit(y,t=infinity)=ymin] assuming c::positive;
ans:=solve(eqns,{a,b});
y1:=eval(y,ans);

[a+b = ymax, a = ymin]

{a = ymin, b = -ymin+ymax}

ymin+(-ymin+ymax)*exp(-c*t)

From min up to max

eqns:=[eval(y,t=0)=ymin,limit(y,t=infinity)=ymax] assuming c::positive;
ans:=solve(eqns,{a,b});
y2:=eval(y,ans);

[a+b = ymin, a = ymax]

{a = ymax, b = ymin-ymax}

ymax+(ymin-ymax)*exp(-c*t)

plot(eval([y1,y2],{c=1,ymin=2,ymax=5}),t=0..5,colour=[red,blue]);

 


 

Download exp.mw

display is in the plots package, so you need

plots:-display(pp1) ;

(or use with(plots) at the beginning of your worksheet)

odeplot can handle most sorts of plots for numeric odes.

[worksheet display not working right now]

odeplot.mw

First 45 46 47 48 49 50 51 Last Page 47 of 83