Carl Love

Carl Love

27579 Reputation

25 Badges

12 years, 57 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Define the function with unapply:

f:= unapply(a*x, x)

A synonym for unapply is MakeFunction.

I assume that you're using 2D Input which you've converted to 1D for posting here. If so, then you need to remove any space characters you have after displaytextplot, and draw. Also, the arguments to display need to be in parentheses. If I change your display command to

display(
    textplot(
       [
           [coordinates(S)[], "S"], [coordinates(P)[], "P"], [coordinates(H)[], "H"], 
           [coordinates(K)[], "K"], [coordinates(M)[], "M"]
       ], font = [times, bold, 16], align = [above, right]
    ), 
    draw([
        delta(color = blue), deltap(color = blue), D(color = red), c1(color = black),
        S(color = black, symbol = solidcircle, symbolsize = 16),
        P(color = black, symbol = solidcircle, symbolsize = 16)
    ]), 
    scaling = constrained, axes = none, view = [-15 .. 15, -15 .. 15]
);

 then I get this plot (for which you'll likely want to change some of the sizes):

The simplify command doesn't work on equations (except in the sense that it's mapped to the left and right sides independently). In common mathematical usage, as taught in secondary-school algebra, "simplification" is only performed on expressions, not equations.

The Python code shown in your forum link handles the minutiae of setting up grids/meshes for 3D plots and converting spherical and cylindrical coordinates to rectangular. This is unnecessary in Maple; the plot3d command handles that in the background.

(* Original Python code:

from matplotlib import pyplot as plt
from math import sqrt, pi, cos, sin
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

t_grid = np.linspace(-1 - sqrt(7), -1 + sqrt(7), 50)
s_grid = np.linspace(-1, 1, 50)
T, S = np.meshgrid(t_grid, s_grid)
theta_fun = lambda t, s: 0.2 * pi * (t + 1 + sqrt(7)) / sqrt(7) - 0.4 * pi + 0.1
phi_fun = lambda t, s: pi * s / (4 * sqrt(2)) * sqrt(max(2 - t ** 2 / abs(t - 3), 0))
for k in range(1, 16):
  phi0 = 0.4 * pi * k
  r = 14 - 0.8 * k
  x_fun = lambda t, s: r * cos(phi0 + phi_fun(t, s)) * cos(theta_fun(t, s))
  y_fun = lambda t, s: r * sin(phi0 + phi_fun(t, s)) * cos(theta_fun(t, s))
  z_fun = lambda t, s: r * sin(theta_fun(t, s))
  X = np.array(list(map(x_fun, T.flatten(), S.flatten()))).reshape((50, 50))
  Y = np.array(list(map(y_fun, T.flatten(), S.flatten()))).reshape((50, 50))
  Z = np.array(list(map(z_fun, T.flatten(), S.flatten()))).reshape((50, 50))
  ax.plot_surface(X, Y, Z, cmap='Reds')
z = np.linspace(-25, -10, 50)
p = np.linspace(0, 2 * pi, 50)
Z, P = np.meshgrid(z, p)
X = np.cos(P)
Y = np.sin(P)
ax.plot_surface(X, Y, Z, cmap='Greens')
ax.set_box_aspect(aspect=(1, 1, 1.5))
*)

The original author plotted the petals using a nonstandard form of spherical coordinates that has the cos(theta) and sin(theta) exchanged, where theta is the altitude angle. I adjusted this to standard spherical coordinates by replacing theta with Pi/2 - theta. The original stem was done using standard cylindrical coordinates.

I don't know the exact details of the Python coloring function cmap. I made an approximation using plot option colorscheme and the ColorTools package.

For the lightmodel, I simply chose what looked best to me from the very limited choices (five) Maple offers. I chose an orientation that looked good to me. 

My algebraic formulas are mathematically equivalent to the Python; however, I simplified them, so they're not syntactically identical. If Python has some difference between math.sin and numpy.sin (likewise for cos), I don't know what it is. The original author used both (perhaps unintentionally).

Surprisingly, Maple has no plot option equivalent to aspect, so I used plottools:-scale, which will do essentially the same thing provided that the options axes= none and scaling= constrained are used and that one doesn't care about the actual numerical values stored in the plot.

#Maple translation:
cmap:= C-> colorscheme= ([ColorTools:-Lighten, ColorTools:-Darken] @@~ 2)(C):
aspect:= (S::And(list(realcons), 3 &under nops))-> (P::specfunc(PLOT3D))-> 
    plots:-display(plottools:-scale(P, S[]), 'axes'= 'none', 'scaling'= 'constrained')
:
k:= [$1..16]:
(aspect([1, 1, 3/2]) @ plots:-display)(
    plot3d(
        `[]`~(
            14 -~ 4/5*~k, 
            Pi*~(2/5*~k +~ s*sqrt(max(2 - t^2/abs(t-3), 0)/32)),
            (Pi*(7 - 2/sqrt(7)*(t+1)) - 1)/10
        ),
        t= -1-sqrt(7)..-1+sqrt(7), s= -1..1, coords= spherical, cmap("Red")
    ),
    plot3d(1, theta= 0..2*Pi, z= -25..-10, coords= cylindrical, cmap("Green")),
    style= surface, lightmodel= light4, orientation= [49, 52, 27]
);

Your system is far more than "a little" complicated. I think that there's no hope of solving this (with Maple or anything else). Maple will likely continue working on it until it runs out of memory, and then crash.

Yes, it's reasonable for it to run for days, weeks, etc., on such a system.

No, there's no way that multi-core processing can help with this.

I believe that both of those answers would be true for any mathematical software.

For what its worth, you can easily (nearly instatntaneously) eliminate 4 of the variables. The complexity of the remaining two equations might help you appreciate why this is unsolvable.

(Sols, Eqs):= eliminate({eq||(1..6)}, {u,v,w,x, y})[]:
print~(Sols): print~(Eqs=~0): 

 

I believe that this simple procedure handles all the cases presented so far, requiring no input other than the equation itself. It also accepts and gracefully handles expressions

  • implicitly equated to 0,
  • with only 1 term,
  • with multiple unknown dependent functions (such as would appear in any system of DEs), 
  • with no unknown dependent functions, or
  • with no diff (such as may appear in a system of DAEs).
LeftRight:= proc(Q::{`=`(algebraic), algebraic})
local
    _0, 
    (L,R):= selectremove(hastype, _0 + `if`(Q::`=`, (lhs-rhs)(Q), Q), 'typefunc'(name, Not(mathfunc)))
;
    eval(`if`(L=0, R=0, L = -R), _0= 0)           
end proc
:
test_cases := <
   diff(u(x,t),t,t) + 3 + 2*diff(u(x,t),t) + 4*t + x^2 + x^3/3 
       + diff(u(x,t),t,x,x) + diff(u(x,t),x,x,x,x) = x*t^2,
   y(x) + diff(y(x),x) + cos(x) + g(y(x)) + diff(f(x),x) + 1/x = sin(x),
   diff(f(x),x) + 1/x = sin(x),
   y(x) + x,
   x*diff(y(x),x) + x = y(x) + diff(y(x),x$2),
   x^2 + 1/y(x) + diff(y(x),x) + sin(x) = y(x)^2,
   1 + x,
   diff(y(x),x)= 0,
   diff(y(x),x$2) = y(x) - x,
   sin(x)+y(x)=0
>:
<test_cases | <seq(`&nbsp;`, numelems(test_cases))> | LeftRight~(test_cases)>;

 

Here is a set of procedures that do what your procedure was expected to do, and do it in any base, not just base-10. For pedagogical reasons, I have not used any package commands. All commands that I use (except ifactors) are simple integer arithmetic. I did this for pedagogical reasons; I don't have anything against  the NumberTheory package. Many of my procedures duplicate functionality from NumberTheory. And their code is so arithmetically simple that I think you'll be able to learn from them. All of these procedures run in time equal to or slightly less than their NumberTheory counterparts.

Also, it seems that RepeatDecimal subpackage of NumberTheory is limited to base-10.

restart:

interface(prompt= "")
:

(*
P_log(N,p) returns (e, N/p^e) where e is the largest exponent such that p^e divides N.
*)
P_log:= proc(N::posint, p::And(posint, Not(1))) local e:= 0, n, q:= N;    
    while irem((n:= q), p, 'q') = 0 do e++ od;
    (e,n)
end proc
:
(*
Totient(m) returns the number of elements in the multiplicative group mod m.
This is also called "Euler's totient" or "Euler's phi".
*)
Totient:= (m::posint)-> local p; mul(p[1]^(p[2]-1)*(p[1]-1), p= ifactors(m)[2])
:
(*
Base(N,R) returns a list of minimal length d of the base-R (or radix-R) digits of N in order from
most-significant to least-significant digit.
*)
Base:= (N::nonnegint, R::And(posint, Not(1)), d::posint)->
local n:= N, D:= R^max(d, 1 + ilog[R](n)); [do iquo(n, (D/= R), 'n') until D=1]
:
(*
P_factors(n) returns a list of the distinct prime factors of n.
*)
P_factors:= (n::integer)-> index~(ifactors(n)[2], 1)
:
(*
M_Order(X,m) returns the smallest T>0 such that X^T mod m = 1, a.k.a., the multiplicative
order of X (mod m).
For convenience, I allow modulus m=1 and return 0 in any such case.
*)
M_Order:= proc(X::posint, m::And(posint, satisfies(m-> igcd(m,X)=1)))
local p, T:= Totient(m), q, x:= irem(X,m);
    for p in P_factors(T) do while irem(T,p,'q') = 0 and x&^q mod m = 1 do T:= q od od;
    `if`(m=1, 0, T)
end proc
:
(*
periode(r,R) returns [q, nops(dL), dL] where
   q is the number of leading non-repeating digits after the radix point in the radix-R
   representation of rational number r,
   and
   dL is the list of repeating digits in radix-R representation.

   "Radix" is a more-formal word for "base", as in "base-10 arithmetic".
   The radix R defaults to 10.
*)
periode:= proc(r::{integer,fraction}, R::And(posint, Not(1)):= 10)
local b:= denom(r), f, i, p, q:= 0, M;
    for f in P_factors(R) do (i,b):= P_log(b,f); q:= max(q,i) od;
    [q, (p:= M_Order(R,b)), Base(abs(numer(frac(r*R^q)))*(R^p-1)/b, R, p)]
end proc
:

#Test cases:
periode(2/3);

[0, 1, [6]]

periode(2/35);

[1, 6, [5, 7, 1, 4, 2, 8]]

periode(3/140);

[2, 6, [1, 4, 2, 8, 5, 7]]

periode(3/5, 2);

[0, 4, [1, 0, 0, 1]]

periode(1/13);

[0, 6, [0, 7, 6, 9, 2, 3]]

#Preben's example:
CodeTools:-Usage(periode(1007/200035));

memory used=2.29MiB, alloc change=0 bytes, cpu time=0ns, real time=4.00ms, gc time=0ns

[1, 1818, [0, 5, 0, 3, 4, 1, 1, 9, 0, 2, 9, 1, 6, 9, 8, 9, 5, 2, 6, 8, 3, 2, 8, 0, 4, 2, 5, 9, 2, 5, 4, 6, 3, 0, 4, 3, 9, 6, 7, 3, 0, 5, 7, 2, 1, 4, 9, 8, 7, 3, 7, 7, 2, 0, 8, 9, 8, 8, 4, 2, 7, 0, 2, 5, 2, 7, 0, 5, 7, 7, 6, 4, 8, 9, 1, 1, 4, 4, 0, 4, 9, 7, 9, 1, 2, 8, 6, 5, 2, 4, 8, 5, 8, 1, 4, 9, 8, 2, 3, 7, 8, 0, 8, 3, 8, 3, 5, 3, 2, 8, 8, 1, 7, 4, 5, 6, 9, 4, 5, 0, 3, 4, 6, 1, 8, 9, 4, 1, 6, 8, 5, 2, 0, 5, 0, 8, 9, 1, 0, 9, 4, 0, 5, 8, 5, 3, 9, 7, 5, 5, 5, 4, 2, 7, 8, 0, 0, 1, 3, 4, 9, 7, 6, 3, 7, 9, 1, 3, 3, 6, 5, 1, 6, 1, 0, 9, 6, 8, 0, 8, 0, 5, 8, 5, 8, 9, 7, 4, 6, 7, 9, 4, 3, 1, 0, 9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 0, 4, 5, 3, 4, 2, 0, 6, 5, 1, 3, 8, 6, 0, 0, 7, 4, 4, 8, 6, 9, 6, 4, 7, 8, 1, 1, 6, 3, 2, 9, 6, 4, 2, 3, 1, 2, 5, 9, 5, 2, 9, 5, 8, 2, 3, 2, 3, 0, 9, 3, 4, 5, 8, 6, 4, 4, 7, 3, 7, 1, 7, 0, 9, 9, 5, 0, 7, 5, 8, 6, 1, 7, 2, 4, 1, 9, 8, 2, 6, 5, 3, 0, 3, 5, 7, 1, 8, 7, 4, 9, 2, 1, 8, 8, 8, 6, 6, 9, 4, 8, 2, 8, 4, 0, 5, 0, 2, 9, 1, 1, 9, 9, 0, 4, 0, 1, 6, 7, 9, 7, 0, 6, 0, 5, 1, 4, 4, 0, 9, 9, 7, 8, 2, 5, 3, 8, 0, 5, 5, 8, 4, 0, 2, 2, 7, 9, 6, 0, 1, 0, 6, 9, 8, 1, 2, 7, 8, 2, 7, 6, 3, 0, 1, 6, 4, 7, 2, 1, 1, 7, 3, 7, 9, 4, 5, 8, 5, 9, 4, 7, 4, 5, 9, 1, 9, 4, 6, 4, 0, 9, 3, 7, 8, 3, 5, 8, 7, 8, 7, 2, 1, 2, 2, 3, 7, 8, 5, 8, 3, 7, 4, 7, 8, 4, 4, 1, 2, 7, 2, 7, 7, 7, 2, 6, 3, 9, 7, 8, 8, 0, 3, 7, 0, 9, 3, 5, 0, 8, 6, 3, 5, 9, 8, 8, 7, 0, 1, 9, 7, 7, 1, 5, 3, 9, 9, 8]]

 

Download RationalPeriod.mw

Your problem comes from using the default equality operator = to check the mathematical equality of algebraic expressions, but = only checks whether the expressions are syntactically identical in their unsimplified form. That's a much stronger form of equality than mathematical equality. Use the command is to check mathematical equality. Your code should include something to do if is returns FAIL, which means that it couldn't determine mathematical equality. Here's a revision of your procedure:

restart:

CauchyRiemann:= proc(expr::algebraic, z::name:= ':-z')
local
    x, y,
    (u,v):= op(evalc([Re,Im](eval(expr, z= x+I*y)))),
    (u_x, u_y, v_x, v_y):= op(diff~([u,u,v,v], [x,y,x,y])),
    (flag1, flag2):= op(is~([u_x, u_y] =~ [v_y, -v_x]) assuming additionally, (x,y)::~real)
;  
    print~([
        'f(z)'=expr, ``,
        'u(x,y)'=u, 'u[x](x,y)'=u_x, 'u[y](x,y)'=u_y, ``,
        'v(x,y)'=v, 'v[x](x,y)'=v_x, 'v[y](x,y)'=v_y, ``,
    
        if flag1 then 'u[x]=v[y]', u_x=v_y
        elif not flag1 then 'u[x]<>v[y]', u_x<>v_y
        else `Couldn't determine whether ` || ('u[x]=v[y]')
        fi,

        if flag2 then 'u[y] = -v[x]', u_y = -v_x
        elif not flag2 then 'u[y] <> -v[x]', u_y <> -v_x
        else `Couldn't determine whether ` || ('u[y] = -v[x]')
        fi,
        ``,
        if flag1 and flag2 then
           `Fullfill the Cauchy-Riemann Equations`,
           `The derivative is:`='u[x]+I*v[y]', 'diff(f(z),z)'=u_x+I*v_y
        else
           `Cauchy-Riemann ?`
        fi,
        ``
    ]);
    flag1 and flag2
end proc:
        
f(z):=1/(z+2):
CauchyRiemann(f(z));

f(z) = 1/(z+2)

``

u(x, y) = (x+2)/((x+2)^2+y^2)

u[x](x, y) = 1/((x+2)^2+y^2)-(x+2)*(2*x+4)/((x+2)^2+y^2)^2

u[y](x, y) = -2*(x+2)*y/((x+2)^2+y^2)^2

``

v(x, y) = -y/((x+2)^2+y^2)

v[x](x, y) = y*(2*x+4)/((x+2)^2+y^2)^2

v[y](x, y) = -1/((x+2)^2+y^2)+2*y^2/((x+2)^2+y^2)^2

``

u[x] = v[y]

1/((x+2)^2+y^2)-(x+2)*(2*x+4)/((x+2)^2+y^2)^2 = -1/((x+2)^2+y^2)+2*y^2/((x+2)^2+y^2)^2

u[y] = -v[x]

-2*(x+2)*y/((x+2)^2+y^2)^2 = -y*(2*x+4)/((x+2)^2+y^2)^2

``

`Fullfill the Cauchy-Riemann Equations`

`The derivative is:` = u[x]+I*v[y]

diff(f(z), z) = 1/((x+2)^2+y^2)-(x+2)*(2*x+4)/((x+2)^2+y^2)^2+I*(-1/((x+2)^2+y^2)+2*y^2/((x+2)^2+y^2)^2)

``

true

 

Download CauchyRiemann.mw

Use explicit multiplication symbols:

PDE :=
    diff(G(a, H, phi, PI), a)*(aH) + diff(G(a, H, phi, PI), H)*(k/a^2 - kappa^2/2*PI^2/a^6)
   + diff(G(a, H, phi, PI), phi)*(PI/a^3)
   = diff(G(a, H, phi, PI), PI)*(a^3*diff(V(phi), phi))
;

pdsolve(PDE, G);

[This Answer is similar to @Kitonum's, but I wrote it independently before seeing his. I first solve for the four angles given the constrsaints, then I construct the points and plot.]

The Answer by @C_R shows a self-intersecting quadrilateral. However, it's possible to satisfy all the constraints with a simple convex planar quadrilateral:

restart
:
#Divide all distances by 10. Express each in both directions:
(ab, bc, cd, da):= ((ba, cb, dc, ad):= (17, 17, 29, 18))
:
#one side of Law of Cosines:
LoC:= (a::symbol, b::symbol, c::symbol)-> 
    eval(cat(a,b)^2 + cat(b,c)^2 - 2*cat(a,b)*cat(b,c)*cos(b)):

angs:= fsolve(
    {
        #law of cosines viewing diagonal ac as a side of triangles abc and adc:
        LoC(a,b,c) = LoC(a,d,c),
        #law of cosines viewing diagonal bd as a side of triangles bcd and abd:
        LoC(b,c,d) = LoC(b,a,d),
        #law of cosines for equality of diagonals:
        LoC(a,b,c) = LoC(d,c,b),
        #sum of interior angles:
        a+b+c+d = 2*Pi
    },
    {(a,b,c,d)=~ 0..Pi}
);
  angs := {a = 1.879417129, b = 1.962935269, c = 1.228331866, d = 1.212501044}

#Construct it: Arbitrarily put A at origin and B directly to the right of A:
A:= [0,0]:  B:= A +~ [ab,0]:  
C:= B +~ bc*~(cos,sin)(eval(Pi-b, angs)); 
`&D;`:= A +~ da*~(cos,sin)(eval(a, angs));
                C := [23.49681980, 15.70959364]
                D := [-5.467408027, 17.14956120]
plots:-display(
    plot([[A,B,C,`&D;`,A], [A,C], [B,`&D;`]], thickness= 3, color= [red, blue$2]),
    plots:-textplot(
        [
            [A[], "A", align= {below, left}], 
            [B[], "B", align= {below, right}],
            [C[], "C", align= {above, right}],
            [`&D;`[], "D", align= {above, left}]
        ], font= [HELVETICA, BOLD, 16]
    ),
    axes= none, scaling= constrained
);

#Verify constraints:
dist:= (P,Q)-> sqrt(add((P-~Q)^~2)):
dist(A,B);
                               17
dist(B,C);
                          16.99999999
dist(C,`&D;`);
                          29.00000001
dist(A,`&D;`);
                          18.00000000
dist(A,C);
                          28.26467536
dist(B,`&D;`);
                          28.26467536

 

This can be applied to any equation, and is often very useful. In this case, it returns exactly what you want.

numer((lhs-rhs)(eq)) = 0

It just seems like luck or happenstance to me that using x as the 2nd argument and 1 as the 3rd did what you wanted.

This works:

factor(%, indets(%, sqrt));

The answer is awkward IMO, because a denominator is introduced, but it is correct.

The second argument to solve should be a list of the three variables that you want to solve for. By passing a set of six variables, you're giving solve the freedom to choose to do the thing that you don't want it to do.

By solving each of the equations for one of the variables, you can make direct plots, which are usually better than implicit plots (especially in 3D). Also, note the compact entry method for matrices and vectors.

restart:

interface(prompt= ""):

LA:= LinearAlgebra:  SLA:= Student:-LinearAlgebra:

`&/`:= (b,A)-> LA:-LinearSolve(A,b):

(A,b):= (<1, 1; 12, 16>, <10, 136>);

A, b := Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = 12, (2, 2) = 16}), Vector(2, {(1) = 10, (2) = 136})

sol:= b &/ A;

Vector(2, {(1) = 6, (2) = 4})

Eqs:= [seq](A.<x,y> -~ b);

[x+y-10, 12*x+16*y-136]

SLA:-LinearSystemPlot(Eqs, axes= normal);

solve~(Eqs, y);

[-x+10, -(3/4)*x+17/2]

plot(
    solve~(Eqs, y), x= sol[1]-1 .. sol[1]+1,
    color= [red, blue], thickness= 2, labels= ["x", "y"],
    legend= Eqs, title= "Plot of Linear System"
);

(A,b):= (<2, -1, 1; 0, 1, 3; 0, 0, 1>, <-5, 7, 2>);

A, b := Matrix(3, 3, {(1, 1) = 2, (1, 2) = -1, (1, 3) = 1, (2, 1) = 0, (2, 2) = 1, (2, 3) = 3, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1}), Vector(3, {(1) = -5, (2) = 7, (3) = 2})

sol:= b &/ A;

Vector(3, {(1) = -3, (2) = 1, (3) = 2})

Eqs:= [seq](A.<x,y,w> =~ b);

[2*x-y+w = -5, y+3*w = 7, w = 2]

plots:-display(
    plot3d~(
        solve~(Eqs, w), x= sol[1]-1 .. sol[1]+1, y= sol[2]-1 .. sol[2]+1,
        color=~ [red, blue, green], style= surface,
        transparency=~ [.4, .4, 0]
    ),
    title= "#D Plot of Linear System"
);

 

Download LinearSystemPlots.mw

In the specification of the ODEs, you need to change all occurences of the form

Theta(t)[k]  to Theta[k](t),

diff(Theta(t), t)[k]  to diff(Theta[k](t), t),

etc.

Initial conditions need to be specified like

Theta[k](0) = 7  and  D(Theta[k])(0) = 5.

In other words, use D instead of diff for initial conditions.

First 7 8 9 10 11 12 13 Last Page 9 of 392