MaplePrimes Questions

I can't understand this behavior. Any idea why it happens?

Solve is able to solve equation   f(y)=x+A for y, but can't solve   f(y)=x for y.

This is unexpected for me. I do not see why it can solve it when RHS is x+A but not when RHS is just x.


 

21040

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1745. The version installed in this computer is 1744 created 2024, April 17, 19:33 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib\`

restart;

21040

sol:=int(1/sqrt(sin(y)),y);
solve(sol=x,y)

(sin(y)+1)^(1/2)*(-2*sin(y)+2)^(1/2)*(-sin(y))^(1/2)*EllipticF((sin(y)+1)^(1/2), (1/2)*2^(1/2))/(cos(y)*sin(y)^(1/2))

Warning, solutions may have been lost

sol:=int(1/sqrt(sin(y)),y);
solve(sol=x+b,y):
{%}; #to eliminate duplicates

(sin(y)+1)^(1/2)*(-2*sin(y)+2)^(1/2)*(-sin(y))^(1/2)*EllipticF((sin(y)+1)^(1/2), (1/2)*2^(1/2))/(cos(y)*sin(y)^(1/2))

{arctan(JacobiSN(((1/2)*I)*2^(1/2)*(x+b), (1/2)*2^(1/2))^2-1, -(1/2)*JacobiSN(((1/2)*I)*2^(1/2)*(x+b), (1/2)*2^(1/2))*(4-2*JacobiSN(((1/2)*I)*2^(1/2)*(x+b), (1/2)*2^(1/2))^2)^(1/2)*2^(1/2)), arctan(JacobiSN(((1/2)*I)*2^(1/2)*(x+b), (1/2)*2^(1/2))^2-1, (1/2)*JacobiSN(((1/2)*I)*2^(1/2)*(x+b), (1/2)*2^(1/2))*(4-2*JacobiSN(((1/2)*I)*2^(1/2)*(x+b), (1/2)*2^(1/2))^2)^(1/2)*2^(1/2))}

 


I can trick it to solve  f(y)=x for y  by asking it to solve f(y)=x+A for y and then set A=0 in the solution. But one should not have to do this. Is this a bug or Am I missing something?

Download why_solve_when_adding_term_only_may_22_2024.mw

Dear Colleague. 

I am trying to improve the results of abs(res[i] - exy) in the following codes.

restart;
Digits := 30:

# Define the function
f := proc(n)
    -0.5*y[n] + 0.5*sin(x[n] - Pi)
end proc:

# Define equations
e1 := y[n+2] = 2*h*delta[n] + y[n] - h^2*(-2*sin(u)*f(n)*u^2 - 2*sin(u)*f(n+2)*u^2 + 2*sin(2*u)*f(n+1)*u^2 + 2*cos(u)*f(n)*u - 2*cos(u)*f(n+2)*u + 2*cos(2*u)*f(n+1)*u - 2*cos(2*u)*f(n)*u - 2*sin(u)*f(n) + 2*sin(u)*f(n+2) + sin(2*u)*f(n) - sin(2*u)*f(n+2) - 2*f(n+1)*u + 2*f(n+2)*u)/((2*sin(u) - sin(2*u))*u^2):
e2 := y[n+1] = h*delta[n] + y[n] - (1/2)*h^2*(-sin(u)*f(n)*u^2 - sin(u)*f(n+2)*u^2 + sin(2*u)*f(n+1)*u^2 + 2*cos(u)*f(n)*u - 2*cos(u)*f(n+2)*u + 2*cos(2*u)*f(n+1)*u - 2*cos(2*u)*f(n)*u + 4*sin(u)*f(n+1) - 4*sin(u)*f(n) - 2*sin(2*u)*f(n+1) + 2*sin(2*u)*f(n) - 2*f(n+1)*u + 2*f(n+2)*u)/((2*sin(u) - sin(2*u))*u^2):
e3 := h*delta[n+2] = h*delta[n] + h^2*(2*sin(u)*f(n)*u + 2*sin(u)*f(n+2)*u - 2*sin(2*u)*f(n+1)*u - 2*cos(2*u)*f(n+1) + cos(2*u)*f(n) + cos(2*u)*f(n+2) + 2*f(n+1) - f(n) - f(n+2))/(u*(2*sin(u) - sin(2*u))):

with(LinearAlgebra):
epsilon := 10^(-10):
inx := 0:
ind := 1:
iny := 0:
h := 0.01:
n := 0:
omega := 1:
u := omega * h:
tol := 1e-4:
N := solve(h * p = 8 * Pi, p):

err := Vector(round(N)):
exy_lst := Vector(round(N)):

c := 1:
for j from 0 to 2 do
    t[j] := inx + j * h:
end do:

vars := y[n+1], y[n+2], delta[n+2]:

step := [seq(eval(x, x = c * h), c = 1 .. N)]:
printf("%6s%15s%15s%16s%15s%15s%15s\n", "h", "Num.y", "Num.z", "Ex.y", "Ex.z", "Error y", "Error z");

st := time():
for k from 1 to N / 2 do
    par1 := x[0] = t[0], x[1] = t[1], x[2] = t[2]:
    par2 := y[n] = iny, delta[n] = ind:    
    
    res := eval(<vars>, fsolve(eval({e1, e2, e3}, [par1, par2]), {vars}));

    for i from 1 to 2 do
        exy := eval(sin(c * h)):
        exz := eval(cos(c * h)):
        printf("%6.5f%17.9f%15.9f%15.9f%15.9f%13.5g%15.5g\n", h * c, res[i], res[i+1], exy, exz, abs(res[i] - exy), abs(res[i+1] - exz));
        
        err[c] := abs(evalf(res[i] - exy));
        if Norm(err) <= tol then 
            h := 0.1 * h * (c + 1) * (tol/Norm(err))^(0.2);
        else 
            break
        end if;
        exy_lst[c] := exy;
        numerical_y1[c] := res[i];
        c := c + 1;
    end do;
    iny := res[2];
    ind := res[3];
    inx := t[2];
    for j from 0 to 2 do
        t[j] := inx + j * h;
    end do;
end do:
v := time() - st;
v / 4;
printf("Maximum error is %.13g\n", max(err));
NFE = evalf((N / 4 * 3) + 1);

# Get array of numerical and exact solutions for y1
numerical_array_y1 := [seq(numerical_y1[i], i = 1 .. N)]:
exact_array_y1 := [seq(exy_lst[i], i = 1 .. N)]:

# Get array of time steps
time_t := [seq(step[i], i = 1 .. N)]:

# Display graphs for y1
with(plots):
numerical_plot_y1 := plot(time_t, numerical_array_y1, style = point, symbol = asterisk, color = blue, symbolsize = 20, legend = ["TFIBF"]);
exact_plot_y1 := plot(time_t, exact_array_y1, style = point, symbol = box, color = red, symbolsize = 20, legend = ["EXACT"]);

display({numerical_plot_y1, exact_plot_y1});
Error_plot_y1 := plot(time_t, err, style = line, symbol = box, tickmarks = [piticks, decimalticks], color = navy, labels = [`h=Pi/8`, typeset(`Absolute Errors`)]);

I am suspecting that I didnt update the new h properly (I may be wrong, though). Please kindly help modify the code to allow the values of abs(res[i] - exy) to about 10^(-11). Thank you and best regards.

I am trying to solve the following recursion for any n, given a constant c. Here is my code for it:

c := 2:

A[i] := rsolve({a(0) = 1/n, a(i) = ((n - i + 1)/(n - i) + 1/(c*(n - i)))*a(i - 1)}, a);

total := evala(Simplify(sum(eval(A[i], i=k), k=0..n-1)));
evalf(eval(total, n = 6));

For c = 1, I get a valid (and correct) output, however for c = 2 for example, rsolve is returning A[i] = -GAMMA(-n)*GAMMA(-n + i - 1/2)/(GAMMA(-n - 1/2)*GAMMA(-n + i + 1)), which does not make sense when n is an integer. Is there something I am doing wrong here? Not sure why this is happening. Thanks!

Include print level in procedure
In the procedure code printlevel is not accepted
-enviroment variable
-interface variable 
error message : Error, (in interface) unknown interface variable, printlevel

More convenient in my opinion is to include on the printlevel depth in the procedure call?

restart;

fac := proc(n::integer)
    local previous_printlevel, result;
    previous_printlevel := interface('printlevel');  # Correct way to get the current printlevel
    interface('printlevel' = 3);  # Correct way to set the printlevel

    # De recursieve berekening
    if n = 0 then
        result := 1;  # Basisgeval
    else
        result := n * fac(n - 1);  # Recursieve aanroep
    end if;

    interface('printlevel' = previous_printlevel);  # Restore the original printlevel
    return result;
end proc;

fac(5);

proc (n::integer) local previous_printlevel, result; previous_printlevel := interface('printlevel'); interface('printlevel' = 3); if n = 0 then result := 1 else result := n*fac(n-1) end if; interface('printlevel' = previous_printlevel); return result end proc

 

Error, (in interface) unknown interface variable, printlevel

 
 

 

Download MP_vraag_printlevel_in_procedure_-lukt_niet.mw

Hello.

I am very new to Maple. Many this are great, but I do not understand how maple deals with, especially, radiological units. In particular regarding joules [J] wich Maple seems to have alt least three types:

1) J - in relation to work

2) J(radiation) in relation to Gy (Gray) J/kg

3) J(dose_equivalent_index) in relation to Sv also J/kg

Why does Maple distinguish between these "joules"? As a phycisist they are all (well maby not entirely for Sv) equal to me. How can I make Maple treat them all at the "same joule"?

I have tried the following first:

with(Units[Standard]) and

with(Units[Natural])

Best,

Carsten

Let S1: x^2 + (y - 2)^2 + (z + 1)^2 = 29 be a sphere and two points A(0, 0, 4), B(6, -2, 6); the line d passing through point C(4, -8, 4) and have direction v=(1, -1, 2). Find the point M such that M lies on the sphere S1, the angle AMB equals to 90 degree and distance from M to the line d is minimum

If I understand correctly, both of 

int(RETURN(is(y::positive)), y = 0 .. x) assuming 0 <= x, x < 1;
int(RETURN(coulditbe(y = 1)), y = 0 .. x) assuming 0 < x, x < 1;

should output `not`(true). However, Maple simply returns true for the second one. 
Isn't this result incorrect? Or am I missing something?

I would like to remove isomorphs from some graphs. That is to filter out non-isomorphic graphs.

graph_list := [GraphTheory:-CompleteGraph(3), GraphTheory:-PathGraph(3),Graph({{a,b},{b,c},{c,a}})]:

# Create a table to store non-isomorphic graphs
non_isomorphic_graphs := table():

# Counter for indexing the table
counter := 1:

# Iterate over each graph and check if it is isomorphic to any of the stored graphs
for g in graph_list do
    is_isomorphic := false:
    for key in indices(non_isomorphic_graphs,'nolist') do
        if GraphTheory:-IsIsomorphic(g, non_isomorphic_graphs[key]) then
            is_isomorphic := true:
            break:
        end if:
    end do:
    if not is_isomorphic then
        non_isomorphic_graphs[counter] := g:
        counter := counter + 1:
    end if:
end do:
op(non_isomorphic_graphs)
DrawGraph~(non_isomorphic_graphs,  layoutoptions = [neutral_color = "pink", initial = spring])

 

A canonical form is a labeled graph Canon(G) that is isomorphic to G, such that every graph that is isomorphic to G has the same canonical form as G. I noticed that Maple has a function called CanonicalGraph. Can this function achieve the effect I want? I can easily achieve this by combining the  canonical form and property of sets  in  Sage.

graph_list = [Graph([(0, "a"), ("a", 2), (2, 0)]),graphs.PathGraph(3), graphs.CompleteGraph(3)]
non_isomorphic_graphs_labels = {g.canonical_label().copy(immutable=True) for g in graph_list}

 

 

An underlying motivation:My collaborators and I designed generation rules (algorithms) for 1-planar 4-trees;see https://arxiv.org/abs/2404.15663. Since the generating process is based on 1-planar embeddings, it will ultimately require filtering non-isomorphic graphs among a list of embeddings. I would be especially delighted to see that someone implement our algorithm in the future. Currently, I am stuck on handling some labeling details. It is somewhat similar to generating Apollonian networks (planar 3-trees). However, since its simplicial vertices are only two, the growth rate will not be too fast as the number of vertices increases.

I need to evaluate a variable inside the function definition in the moment it is defined and not every time it is called. Is there a way around?

a:=3;
f := x-> a*x;
f(t);

a:=4;
f(t);

I want the function "f" to be 3*x even if "a" is modified after the declaration. In Mathematica I am used to the so called immediate assignmet(=) and delayed assignment(:=) for which I cannot find an equivalent command in Maple. 

Any help is appreciated!

im trying to write differential quadrature method i have successfully  generated system of equations using code but now im stuck with rk4 method to solve these equation in a loop kindly give me suggestions or modify the code

restart

with(orthopoly)

N := 5

5

(1)

P := proc (n, x) options operator, arrow; orthopoly[P](n, 2*x-1) end proc

P_N := simplify(P(N, x))

252*x^5-630*x^4+560*x^3-210*x^2+30*x-1

(2)

localroots := fsolve(P_N = 0, x, complex)

HFloat(0.04691007703066799), HFloat(0.23076534494715836), HFloat(0.4999999999999997), HFloat(0.7692346550528439), HFloat(0.9530899229693298)

(3)

for i to N do assign(x[i] = localroots[i]) end do

PRime := diff(P_N, x)

1260*x^4-2520*x^3+1680*x^2-420*x+30

(4)

for i to N do for j to N do if i <> j then a[i, j] := (eval(PRime, x = x[i]))/((x[i]-x[j])*(eval(PRime, x = x[j]))) else a[i, j] := (1-2*x[i])/(2*x[i]*(x[i]-1)) end if end do end do

u := proc (i) local u_x, expr, j; u_x := add(a[i, j]*u[j], j = 1 .. N); expr := -u[i]*u_x+x[i]; expr end proc; odes := [seq(u(i, [seq(u[j], j = 1 .. N)]), i = 1 .. N)]; for i to N do assign(o[i] = odes[i]) end do; for i to N do printf("u_%d = %s\n", i, convert(u(i), string)) end do

u_1 = -u[1]*(-10.1340811913091*u[1]+15.4039041703445*u[2]-8.08708750877537*u[3]+3.92079823166652*u[4]-1.10353370192667*u[5])+.046910077030668
u_2 = -u[2]*(-1.92051204726391*u[1]-1.51670643433575*u[2]+4.80550130432862*u[3]-1.85711605328765*u[4]+.488833230558754*u[5])+.230765344947158
u_3 = -u[3]*(.602336319455661*u[1]-2.87077648466948*u[2]-1.11022302462516e-015*u[3]+2.87077648466942*u[4]-.602336319455684*u[5])+.5
u_4 = -u[4]*(-.488833230558737*u[1]+1.85711605328767*u[2]-4.8055013043286*u[3]+1.51670643433578*u[4]+1.92051204726404*u[5])+.769234655052844
u_5 = -u[5]*(1.1035337019266*u[1]-3.92079823166643*u[2]+8.08708750877511*u[3]-15.4039041703442*u[4]+10.1340811913086*u[5])+.95308992296933

 

initial_conditions := [0.1e-1, 0.2e-1, 0.3e-1, 0.4e-1, 0.5e-1]

for i to N do printf("Initial condition for u_%d: u_%d(0) = %f\n", i, i, initial_conditions[i]) end do

Initial condition for u_1: u_1(0) = 0.010000
Initial condition for u_2: u_2(0) = 0.020000
Initial condition for u_3: u_3(0) = 0.030000
Initial condition for u_4: u_4(0) = 0.040000
Initial condition for u_5: u_5(0) = 0.050000

 

dt := .1

tf := 1

"local o_old;  o_old := Vector(n);    #` Loop to initialize o[i]old values`  for i from 1 to n do      o_old[i] := initial_conditions[i];      printf("Initial condition for u_%d: u_%d(0) = %f\\n", i, i, initial_conditions[i]);  end do:    time := t0;  while time < tf do  for i from 1 to n do      k[1, i] := dt * o[i](time,o_old[i]);   for i from 1 to n do  k[2,i]:=dt*o[i](time + dt/(2), o_old[i]+   (k[1, i])/(2));  end do:  for i from 1 to n do  k[3,i]:=dt*o[i](time+ o_old[i]+ (  k[1, i])/(2));  end do:  for i from 1 to n do  k[4,i]:=dt*o[i](time+dt,o_old[i]+k[1,i]);  end do:  for i from 1 to n do    0 _new[i]:=o_old[i]+(k[1,i]+2 *k[2,i]+2*k[3,i]+k[4,i]);  end do:  time := time + dt;     end do;      "

Error, illegal use of an object as a name

"local o_old;  o_old := Vector(n);    #` Loop to initialize o[i]old values`  for i from 1 to n do   o_old[i] := initial_conditions[i];   printf("Initial condition for u_%d: u_%d(0) = %f\\n", i, i, initial_conditions[i]);  end do:    time := t0;  while time < tf do  for i from 1 to n do   k[1, i] := dt * o[i](time,o_old[i]);  end do:  for i from 1 to n do  k[2,i]:=dt*o[i](time + dt/2, o_old[i]+ (k[1, i])/2);  end do:  for i from 1 to n do  k[3,i]:=dt*o[i](time+ o_old[i]+ (  k[1, i])/2);  end do:  for i from 1 to n do  k[4,i]:=dt*o[i](time+dt,o_old[i]+k[1,i]);  end do:  for i from 1 to n do  0 _new[i]:=o_old[i]+(k[1,i]+2 *k[2,i]+2*k[3,i]+k[4,i]);  end do:  time := time + dt;   end do;      "

 
 

NULL

Download dq_code.mw

I have a Prime Version Abo. On my iPhone works everyrhing fine. But on IPad there is a Limit of 5 step by step solutions. Same AppleID. What's the Problem?

Can the display of an object o in Maple, i.e.
> o;
                                                      display of the object
be controlled in a standard Maple worksheet, e.g. with Typesetting or something similar?

Hello, 

I have come across a problem in Maple, when I try plotting af slope field from my differential equation. 

I have tried different ways of defining the ODE, but when I use it in the command of "linjeelementer" (Danish for line elements - It's a command that's part of a package called "With (Gym)" in Maple, it gives me the error: Error, (in DEtools/DEplot/CheckDE) - Derivatives must be given explicitly. 

I don't understand what derivatives I must "give explicitly"?

Translation of the relevant sentences if anyone needs it when looking at the screenshot:

"I need to draw a slope field for the differential equation along with the solution curve for the population growth in India after 1960.

I define the differential equation:
ODE := -0.000032229*y^2 + 0.065843*y - 15.103"

"I am drawing the slope field for the differential equation along with the solution curve for the population growth in India after 1960, i.e., the solution curve that passes through the point (0,449):I am drawing a slope field for the differential equation along with the solution curve for the population growth in India after 1960, i.e., the solution curve that passes through the point (0,449):
linjeelementer(ODE, y(t), t = 0 .. 350, y = 0 .. 2000)"

Is there a way to change the font on the help pages?               

restart;
with(geometry);
with(plots);
_EnvHorizomtalName = 'x';
_EnvVerticalName = 'y';
_local(D);
line(delta, y = 1/3*x - 2, [x, y]);
line(deltap, y = (-1)/4*x + 1, [x, y]);
line(D, y = 3*x - 5, [x, y]);
point(S, 3, 0);
omega := Pi/3;
intersection(P, delta, D);
intersection(Pp, deltap, D);
projection(H, S, delta);
projection(K, S, deltap);
projection(M, S, D);
circle(c1, [H, K, M], 'centername' = O1);
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])];
               [                /[             [9  -13     ]  
plots:-display [plots:-textplot |[[3, 0, "S"], [-, ---, "P"], 
               [                \[             [8   8      ]  

  [33  -9     ]  [52  4      ]  [9  2     ]]  
  [--, --, "H"], [--, --, "K"], [-, -, "M"]], 
  [10  10     ]  [17  17     ]  [5  5     ]]  

                                                  \              
  font = [times, bold, 16], align = [above, right]|, geometry:-d\
                                                  /              

  raw ([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])];
  display*[textplot*([[3, 0, "S"], [9/8, -13/8, "P"], [33/10, -9/10, "H"], [52/17, 4/17, "K"], [9/5, 2/5, "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])]
Why the program will not run; Thank tou.

1 2 3 4 5 6 7 Last Page 1 of 2323