MaplePrimes Questions

Good day sirs, I write a system of DAE but giving me this code "(The use of global variables in numerical ODE problems is deprecated, and will be removed in a future release. Use the 'parameters' argument instead (see ?dsolve,numeric,parameters)". The code is attached below.

Thanking you in anticipating for your help.

Help!!!!.mw

Hello, I was given the problem "Set N:=100. (i) Form four lists L[1], L[3], L[5], L[7] where L[r] contains all primes 2< p < N such that p mod 8 = r ." and came up with the following code:

N := 100;
List1 := [];
List3 := [];
List5 := [];
List7 := [];
for p from 2 to N do
    if isprime(p) and p mod 8 = 1 then List1 := [op(List1), p]; end if;
    if isprime(p) and p mod 8 = 3 then
        List3 := [op(List3), p];
    end if;
    if isprime(p) and p mod 8 = 5 then
        List5 := [op(List5), p];
    end if;
    if isprime(p) and p mod 8 = 7 then
        List7 := [op(List7), p];
    end if;
end do;
List1;
List3;
List5;
List7;
 

this gave me the answer I wanted, however using the above code I have to answer this second question: 

In the notation of Problem 1, make a procedure with input = arbitrary  positive integer N and output = the list [nops(L[1]), nops(L[3]), nops(L[5]), nops(L[7])]. Do some experiments to see for which (if any) r, L[r] is largest. 

I am unsure of how to create a procedure out of the code I already have. I created this: 
 

restart;
F := proc(n)

local N, p, List1, List3, List5, List7;

List1 := [];

List3 := [];

List5 := [];

List7 := [];

for p from N do

if isprime(p) and p mod 8 = 1 then List1 := [op(List1), p]; end if;

if isprime(p) and p mod 8 = 3 then List3 := [op(List3), p]; end if;

if isprime(p) and p mod 8 = 5 then List5 := [op(List5), p]; end if;

if isprime(p) and p mod 8 = 7 then List7 := [op(List7), p]; end if;

return [nops(List1), nops(List3), nops(List5), nops(List7)];

end do;

end proc;

 

however, when I input F(100) or any other value of N, I am receiving the error message "Error, (in F) initial value in for loop must be numeric or character"

 

Any ideas on how to improve my program to get the output I desire?

thank you 

 

 

 


 

restart;

with(PDEtools):

with(plot):

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received plot

 

A1:=Matrix([[phi,(chi),conjugate(phi),conjugate(chi)],
          [chi,(phi),conjugate(chi),conjugate(phi)],
          [lambda*phi,-(lambda)*(chi),
           conjugate(lambda)*conjugate(phi),-conjugate(lambda)*conjugate(chi)],
          [lambda*chi,-(lambda)*(phi),
           conjugate(lambda)*conjugate(chi),-conjugate(lambda)*conjugate(phi)]]);

A1 := Matrix(4, 4, {(1, 1) = phi, (1, 2) = chi, (1, 3) = conjugate(phi), (1, 4) = conjugate(chi), (2, 1) = chi, (2, 2) = phi, (2, 3) = conjugate(chi), (2, 4) = conjugate(phi), (3, 1) = lambda*phi, (3, 2) = -lambda*chi, (3, 3) = conjugate(lambda)*conjugate(phi), (3, 4) = -conjugate(lambda)*conjugate(chi), (4, 1) = lambda*chi, (4, 2) = -lambda*phi, (4, 3) = conjugate(lambda)*conjugate(chi), (4, 4) = -conjugate(lambda)*conjugate(phi)})

(1)

d1 := LinearAlgebra:-Determinant(A1):

d1; length(%);

conjugate(lambda)^2*conjugate(phi)^2*chi^2-conjugate(lambda)^2*conjugate(phi)^2*phi^2-conjugate(lambda)^2*conjugate(chi)^2*chi^2+conjugate(lambda)^2*conjugate(chi)^2*phi^2+2*conjugate(lambda)*conjugate(phi)^2*chi^2*lambda+2*conjugate(lambda)*conjugate(phi)^2*lambda*phi^2-8*conjugate(lambda)*conjugate(phi)*conjugate(chi)*chi*lambda*phi+2*conjugate(lambda)*conjugate(chi)^2*chi^2*lambda+2*conjugate(lambda)*conjugate(chi)^2*lambda*phi^2+conjugate(phi)^2*chi^2*lambda^2-conjugate(phi)^2*lambda^2*phi^2-conjugate(chi)^2*chi^2*lambda^2+conjugate(chi)^2*lambda^2*phi^2

 

705

(2)

den:=simplify(d1,size); length(%);

-(-(conjugate(chi)-conjugate(phi))*(chi+phi)*conjugate(lambda)+lambda*(conjugate(chi)+conjugate(phi))*(chi-phi))*(-(conjugate(chi)+conjugate(phi))*(chi-phi)*conjugate(lambda)+lambda*(conjugate(chi)-conjugate(phi))*(chi+phi))

 

333

(3)

 

con1:=phi=exp(I*lambda*(x-t/(4*lambda^2)-w^2)):con2:=chi=exp(-I*lambda*(x-t/(4*lambda^2)-w^2)):

 

den1:=simplify(dsubs({con1,con2},den));

4*conjugate(lambda)^2*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2-4*conjugate(lambda)^2*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2+8*conjugate(lambda)*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*lambda+8*conjugate(lambda)*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*lambda+4*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*lambda^2-4*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*lambda^2-16*conjugate(lambda)*lambda

(4)

plot3d(subs(Re(lambda)=1, Im(lambda)=.2, w=1, rhs(den1)),x=-6..6, t=-6..6)

Warning, inserted missing semicolon at end of statement

 

Error, invalid input: rhs received 4*conjugate(lambda)^2*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2-4*conjugate(lambda)^2*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2+8*conjugate(lambda)*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda+t)/lambda)^2*lambda+8*conjugate(lambda)*cos((1/4)*(-4*w^2*lambda^2+4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*x+t)/lambda)*lambda-t)/lambda)^2*lambda+4*cos((1/4)*(4*w^2*lambda^2-4*x*lambda^2+conjugate((4*lambda^2*w^2-4*lambda^2*...

 

NULL

``

 

``


 

Download 23May(1).mw

Seems to make no difference with or without RETURN() for the procedure ?

 

vraag_op_forum_gesteld_over_boek_vb_binomium.mw

 

For to know what each graph is standing for in the plot legenda

Could not yet get it  in y , y' , y '' , to 5th derative 

Better is perhaps to have vertical table with the names and function expression together , but that could be difficult betounes_ex_set_task_4def.mw  

 

f := x -> exp(-x)*sin(x); intvx:= 0..3;
f := proc (x) options operator, arrow; exp(-x)*sin(x) end proc
intvx := 0 .. 3

 

And this one below ( i prefer this one ) , but got in worksheet now the one above
Probably a option issue ?

 

 

f := x -> exp(-x)*sin(x); intvx:= 0..3;

proc (x) options operator, arrow; exp(-x)*sin(x) end proc


 

2 determinants equal, solve for the unknowns in one determinant/Linear Algebra

Hi guys, thank you for reading my question.

A is one determinant "Matrix(2, 3, [[1, 2, 3], [3, 1, 2]])".B is" Matrix(2, 3, [[1, x, 3], [y, 1, z]])"

I wrote 2 matrice in the maple

As I try to solve the unknowns,I wrote:

A:= B, solve(x, y, z) It doesn't work

I switch another phrase,

A = B;solve(B:x,y,z)    It doesn't work as well

Could you help me with it ?

Thank you

 

 

Dear All.

Please kindly help to correct the attached code on discretization of fourth order PDE using method of line.
Thank you and kind regards.

restart

``

``

Discretization of parabolic equation with method of line

diff(u(x, t), t) = -2*(diff(diff(u(x, t), x), x))-(diff(diff(diff(diff(u(x, t), x), x), x), x))-u(x, t)*(diff(u(x, t), x))

u(x, t)

u(x, t)

u(x, 0) = 0.3e-1*sin(x)

8

``

``

``

Convert the BC to finite difference

(1/2)*(u[m+1](t)-u[m-1](t))/h

(u[m-1](t)-2*u[m](t)+u[m+1](t))/h^2

(u[m-2](t)-4*u[m-1](t)+6*u[m](t)-4*u[m+1](t)+u[m+2](t))/h^4

````

Convert the governing equation to finite difference form

Error, invalid input: diff received 2*h, which is not valid for its 2nd argument

Error, invalid input: diff received 2*h, which is not valid for its 2nd argument

Error, invalid input: LinearAlgebra:-GenerateMatrix expects its 1st argument, eqns, to be of type ({list, set})({`=`, algebraic}), but received eqs

A

``


 

Download Discretization_of_PDE_Order_4.mw

restart;

ii := 50;

seq(ii, ii = 0 .. 5);

evalf(int(ii, ii = 0 .. 5))

 

For sequence the syntax is correct i.e the output is 0,1,2,3,4,5. is ii inside sequence command takes the value 5 assigned it then changes when ii ranges from 0 to 5?

restart;

ii:=50:
seq(ii)

output: 50

restart;

ii:=50:

seq(seq(ii),ii=1..5)

expected answer: 50,50,50,50,50

obtained: 1,2,3,4,5

please explain how seq command works

 

Trebuchet, Phase I, 2020-05-27 Ki restart; with(RealDomain); with(SolveTools); assume(h < r1); additionally(h < r2); [Im, Re, ^, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, cos, cosh, cot, coth, csc, csch, eval, exp, expand, limit, ln, log, sec, sech, signum, simplify, sin, sinh, solve, sqrt, surd, tan, tanh ] [AbstractRootOfSolution, Basis, CancelInverses, Combine, Complexity, Engine, GreaterComplexity, Identity, Inequality, Linear, Parametric, Polynomial, PolynomialSystem, RationalCoefficients, SemiAlgebraic, SortByComplexity] hz1 := g*(r3*m3*cos(phi1(t))-r1*m2*sin(phi2(t))/sin(phi2(t)-phi1(t)))/theta3; whattype(phi1(t)); whattype(phi2(t)); / r1 m2 sin(phi2(t)) \ g |r3 m3 cos(phi1(t)) + -----------------------| \ sin(-phi2(t) + phi1(t))/ hz1 := ------------------------------------------------ theta3 function function hz2 := phi1(t)+arcsin((h+r1*sin(phi1(t)))/r2); /h + r1 sin(phi1(t))\ hz2 := phi1(t) + arcsin|-------------------| \ r2 / subs(phi2 = hz2, hz1); / / | | 1 | | ------ |g |r3 m3 cos(phi1(t)) theta3 | | | | \ \ // /h + r1 sin(phi1(t))\\ \ \\ r1 m2 sin||phi1(t) + arcsin|-------------------||(t)| || \\ \ r2 // / || + ----------------------------------------------------------|| / / /h + r1 sin(phi1(t))\\ \|| sin|-|phi1(t) + arcsin|-------------------||(t) + phi1(t)||| \ \ \ r2 // /// deq := diff(phi1(t), t, t)-% = 0; / / / 2 \ | | | d | 1 | | deq := |---- phi1(t)| - ------ |g |r3 m3 cos(phi1(t)) | 2 | theta3 | | \ dt / | | \ \ / /h + r1 sin(phi1(t))\ \ \ r1 m2 sin|phi1(t)(t) + arcsin|-------------------|(t)| | \ \ r2 / / | + -----------------------------------------------------------| / /h + r1 sin(phi1(t))\ \| sin|-phi1(t)(t) - arcsin|-------------------|(t) + phi1(t)|| \ \ r2 / // \ | | | = 0 | | / ics := phi1(0) = -arcsin(h/r1), (D(phi1))(0) = 0; /h \ ics := phi1(0) = -arcsin|--|, D(phi1)(0) = 0 \r1/ dsolve({deq, ics}, phi1(t)); dsolve(deq); deq_numeric := subs(r1 = 8, r2 = 8, r3 = 1, h = 5, m2 = 1, m3 = 20, theta3 = 20, deq); / | / d / d \\ 1 | |--- |--- phi1(t)|| - -- g |20 cos(phi1(t)) \ dt \ dt // 20 | | \ / /5 \ \ \ 8 sin|phi1(t)(t) + arcsin|- + sin(phi1(t))|(t)| | \ \8 / / | + --------------------------------------------------------| = 0 / /5 \ \| sin|-phi1(t)(t) - arcsin|- + sin(phi1(t))|(t) + phi1(t)|| \ \8 / // ics_numeric := phi1(0) = 0, (D(phi1))(0) = -.63; ics_numeric := phi1(0) = 0, D(phi1)(0) = -0.63 hz1 := dsolve({ics, deq_numeric}, phi1(t), numeric); Error, (in dsolve/numeric/process_input) unknown arcsin(5/8+sin(phi1(t))) present in ODE system is not a specified dependent variable or evaluatable procedure sin(-phi1(t)-arcsin((h+r1*sin(phi1(t)))/r2)); / /h + r1 sin(phi1(t))\\ -sin|phi1(t) + arcsin|-------------------|| \ \ r2 //

How to convert expression below to LaTex:  $\lim _{x \rightarrow 2} \frac{2}{x+3}$

And How to convert expression below to LaTex:  $\int_{2}^{3} \frac{1}{x^{2}+2} d x$

file test: newLaTex.mw

ode3 := diff(P(t), t) = 0.2*P(t) - 300;
                        d                       
              

ICs := [[0, 1300], [0, 1800]];
DEplot(ode3, p(t), p = -50 .. 2000, t = 0 .. 2000, ICs, arrows = LINE, color = RED, linecolor = BLUE, title = "Solution Curves ode3");
Error, (in DEtools/DEplot) invalid variable in specification of independent variable range
 

I want to plot y=sec(x) and x=-pi/4, x= pi/4. I also want the bounded region shaded. I have been able to graph sec(x) but I can't figure out how to get the two vertical lines and the bounded region shaded.

Hi there!

Essentially, sum(sqrt(-2),x=2..1) is, as it should be, 0. My issue is, that e.g. sum(sqrt(-2),x=2..0) or sum(sqrt(-2),x=2..-1)  are declared by Maple as -I*sqrt(2) and -(2*I)*sqrt(2), which, to my knowledge, is not true, and should be 0 as well. I need those results for a rather complicated algorithm to be 0, otherwise it doesn't work.

NEUZMinus:= proc(Unten, Oben, f,G,Liste,n)::real;
  #Unten:= Untere Intervallgrenze; Oben:= Obere Intervallgrenze; g:= zu integrierende Funktion;
  #G:= Gewicht; n:= Hinzuzufügende Knoten;
 
  Basenwechsel:=proc(Dividend, m);
 
  print(Anfang,Dividend,p[m]);
  Koeffizient:=quo(Dividend, p[m],x);

  Rest:=rem(Dividend, p[m],x);
 
  if m=0 then
    Basenwechsel:=[Koeffizient];
  else

    Basenwechsel:=[Koeffizient,op(Basenwechsel(Rest,m-1))];
   
  end if;
 
  end proc;
p[-1]:=0;
p[0]:=1;
for i from 1 to max(n,numelems(Liste)) do
  p[i]:=x^i-add(int(x^i*p[j]*diff(G,x),x=Unten..Oben)*p[j]/int(p[j]^2*diff(G,x),x=Unten..Oben),j=0..i-1);
  print(p[i]);
c[i-1]:=lcoeff(p[i],x)/lcoeff(p[i-1],x);
d[i-1]:=coeff(p[i],x,(i-1))/coeff(p[i-1],x,(i-1));
if i <> 1 then
  e[i-1]:=coeff(p[i]-(c[i-1]*x+d[i-1])*p[i-1],x,i-2)/coeff(p[i-2],x,i-2);
else
  e[i-1]:=1;
end if;
end do;
print(Liste[1],numelems(Liste));
Hn:=mul(x-Liste[i],i=1..numelems(Liste));
print(Hn);
 Koeffizienten:=Basenwechsel(Hn,numelems(Liste));
print(Koeffizienten);
for j from 0 to numelems(Liste)-1 do
  a[s][j][j]:=1;
end do;
for s from 1 to numelems(Liste)-1 do
  a[s][0]:=[1];
  a[s][1]:=[-e[s]*c[0]/c[s],d[0]-d[s]*c[0]/c[s],c[0]/c[s]];
  for j from 2 to numelems(Liste)-1 do
    print(1);
    a[s][j][abs(s-j)]:=sum(-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1],i=abs(s-j)..min(abs(s-j),s+j-2));
    print(2);
    a[s][j][abs(s-j)+1]:=sum(d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i],i=abs(s-j)+1..min(abs(s-j)+1,s+j-1)+sum(-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1],         i=abs(s-j)+1..min(abs(s-j)+1,s+j-2));
    print(3);
    for i from abs(s-j)+2 to s+j-2 do
      a[s][j][i]:=c[j-1]*a[s][j-1][i-1]/c[i-1]+(d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i]-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1]+e[j-1]*a[s][j-2][i];

      print(4);
    end do;
    a[s][j][s+j-1]:=sum(c[j-1]*a[s][j-1][i-1]/c[i-1],i=max(s-j+2,s+j-1)..s+j-1)+sum((d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i],i=max(s-j+1,s+j-1));
    print(5);
    a[s][j][s+j]:=sum(c[j-1]*a[s][j-1][i-1]/c[i-1],i=max(s-j+2,s+j)..s+j);
    print(6);
  end do;
end do
 

end proc

 

In the case of

a[s][j][abs(s-j)+1]:=sum(d[j-1]-c[j-1]*d[i]/c[i])*a[s][j-1][i],i=abs(s-j)+1..min(abs(s-j)+1,s+j-1)+sum(-c[j-1]*e[i+1]*a[s][j-1][i+1]/c[i+1],         i=abs(s-j)+1..min(abs(s-j)+1,s+j-2));

 
 
for example, the
i=abs(s-j)+1..min(abs(s-j)+1,s+j-2) clause in the end checks, wether the term should be added or not. I basically just need a way to tell Maple wether to add a term or not, depending on wether abs(s-j)+1 is not greater than s+j-2 in this case, without using if-clauses if possible. The problem here is, that min(abs(s-j)+1,s+j-2) can become 0, Maple then tries to calculate something instead of returning 0, and then complains when something inside the term is not properly defined (c[j-1] can become c[-1] for example when j=0) and aborts the entire procedure. How can I tell it to just assign 0?
 
 
 
 
 

I'm having problems with Multiplying Complex Numbers in Maple 2019.

Thanks in Advance.

Example 2: Multiplying Complex Numbers

 

(2-i)(4+3*i)

(3+2*i)(3-2*i)

4*i(-1+5*i)

(3+2*i)^2

2-i(4+3*i)

 

3+2*i(3-2*i)

 

4*i(-1+5*i)

 

(3+2*i)^2

(1.1)

``


 

Download Multiplying_Complex_num.mw

First 547 548 549 550 551 552 553 Last Page 549 of 2426