MaplePrimes Questions

This is a very basic question and apologize for not being able to figure it out myself.     I would like to define a function that I can evaluate with a complicated argument.    For example for a simple function, the following works well

f:=x->x^2+x^3;

This allows me to plot f(x) or f(exp(-r)), etc.    

However the following syntax does not work in the same way.

g:=x->diff(f(x),x);

I can plot g(x) correctly, but g(exp(-r))  cannot be plotted or evaluated.    The error message is 

Error, (in g) invalid input: diff received exp(-r), which is not valid for its 2nd argument
Thanks in advance for your suggestions.

Hi guys,

an error appeared in solving a set of equations and plotting the solution, I dont know how to handle it!!

Thanks for your help

Best

 

problem.mw

please help me

 

 

restart:

Similar*solution

Similar*solution

(1)

eq11 := (10-9*lambda1)*n*diff(f(eta),eta,eta,eta)*(-diff(f(eta),eta,eta))^(n-1)-m*diff(f(eta),eta)^2+M^2*diff(f(eta),eta)+(m*(2*n-1)+1)/(n+1)*f(eta)*diff(f(eta),eta,eta)=0;

(10-9*lambda1)*n*(diff(diff(diff(f(eta), eta), eta), eta))*(-(diff(diff(f(eta), eta), eta)))^(n-1)-m*(diff(f(eta), eta))^2+M^2*(diff(f(eta), eta))+(m*(2*n-1)+1)*f(eta)*(diff(diff(f(eta), eta), eta))/(n+1) = 0

(2)

eq21 := (10-9*lambda1)*n*diff(theta(eta),eta,eta)*(-diff(theta(eta),eta))^(n-1)+(m*(2*n-1)+1)/(n+1)*f(eta)*diff(theta(eta),eta)-m*diff(f(eta), eta)*theta(eta)=0;

(10-9*lambda1)*n*(diff(diff(theta(eta), eta), eta))*(-(diff(theta(eta), eta)))^(n-1)+(m*(2*n-1)+1)*f(eta)*(diff(theta(eta), eta))/(n+1)-m*(diff(f(eta), eta))*theta(eta) = 0

(3)

bc21:= f(0)=0, D(f)(0)=1+alpha*(D@@2)(f)(0), D(f)(N)=0, theta(0)=1+b*D(theta)(0), theta(N)=0;

f(0) = 0, (D(f))(0) = 1+alpha*((D@@2)(f))(0), (D(f))(N) = 0, theta(0) = 1+b*(D(theta))(0), theta(N) = 0

(4)

 

n:=1.2: b:=0: M:=0: alpha:=0:

N:=6:

 

m:=0.8:

A11:=dsolve({eq11,eq21,bc21},numeric,continuation=lambda1,maxmesh=15000, output=array([seq( i, i=0..N,0.01 )])):

Error, (in unknown) unable to store '-HFloat(1.03827200589718e-4)+HFloat(7.543487679217342e-5)*I' when datatype=float[8]

 

m:=1.2:

A12:=dsolve({eq11,eq21,bc21},numeric,continuation=lambda1,maxmesh=15000, output=array([seq( i, i=0..N,0.01 )])):

Error, (in unknown) unable to store '-HFloat(1.239112373179345e-4)+HFloat(9.002678360924433e-5)*I' when datatype=float[8]

 

m:=2:

A13:=dsolve({eq11,eq21,bc21},numeric,continuation=lambda1,maxmesh=15000, output=array([seq( i, i=0..N,0.01 )])):

Error, (in unknown) unable to store '-HFloat(5.684098069533373e-5)+HFloat(4.129738980869168e-5)*I' when datatype=float[8]

 

 

 

with(plots):

p1:=odeplot(A11, [[eta,f(eta),color=red,linestyle=2]],0..N):
p2:=odeplot(A12, [[eta,f(eta),color=blue,linestyle=2]],0..N):
p3:=odeplot(A13, [[eta,f(eta),color=green,linestyle=2]],0..N):

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

 

display({p1,p2,p3}, axes=boxed,  title=`velerature Profiles:`);

Error, (in plots:-display) expecting plot structures but received: {p1, p2, p3}

 

 

 

for j from 1 to 100*(N-1) do eta[j]:=A11[2,1][j,1] end do:

for j from 1 to 100*(N-1) do vel1[j]:=A11[2,1][j,2] end do:

for j from 1 to 100*(N-1) do vel2[j]:=A12[2,1][j,2] end do:

for j from 1 to 100*(N-1) do vel3[j]:=A13[2,1][j,2] end do:

 

with(LinearAlgebra):
E1:= <<seq(eta[j], j=1..100*(N-1) )>|<seq(vel1[j], j=1..100*(N-1) )>|<seq(vel2[j], j=1..100*(N-1) )>|<seq(vel3[j], j=1..100*(N-1))>>;

_rtable[18446746174193268126]

(5)

 

#ExportMatrix("F:/D/Drive D/Local/Rashad/Paper 9/vel1.txt", E1, format = rectangular):

 

NULL

with(plots):

p1:=odeplot(A11, [[eta,theta(eta), color=red,linestyle=2]],0..N):
p2:=odeplot(A12, [[eta,theta(eta), color=blue,linestyle=2]],0..N):
p3:=odeplot(A13, [[eta,theta(eta), color=green,linestyle=2]],0..N):

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

 

 

display({p1,p2,p3}, axes=boxed,  title=`temperature Profiles:`);

Error, (in plots:-display) expecting plot structures but received: {p1, p2, p3}

 

 

``

"[[eta,F(eta),(&DifferentialD;)/(&DifferentialD;eta) F(eta),((&DifferentialD;)^2)/(&DifferentialD;eta^2) F(eta),Theta(eta),(&DifferentialD;)/(&DifferentialD;eta) Theta(eta),f(eta),(&DifferentialD;)/(&DifferentialD;eta) f(eta),((&DifferentialD;)^2)/(&DifferentialD;eta^2) f(eta),theta(eta),(&DifferentialD;)/(&DifferentialD;eta) theta(eta)]]"

for j from 1 to 100*(N-1) do eta[j]:=A11[2,1][j,1] end do:

for j from 1 to 100*(N-1) do temp1[j]:=A11[2,1][j,5] end do:

for j from 1 to 100*(N-1) do temp2[j]:=A12[2,1][j,5] end do:

for j from 1 to 100*(N-1) do temp3[j]:=A13[2,1][j,5] end do:

 

with(LinearAlgebra):
E2:= <<seq(eta[j], j=1..100*(N-1) )>|<seq(temp1[j], j=1..100*(N-1) )>|<seq(temp2[j], j=1..100*(N-1) )>|<seq(temp3[j], j=1..100*(N-1))>>;

_rtable[18446746174193227646]

(6)

#ExportMatrix("F:/D/Drive D/Local/Rashad/Paper 9/temp1.txt", E2, format = rectangular):

 

 

NULL

Download text.mw

When a real matrix have repeated eigenvalue (i.e. multiplicity >1) and the matrix is not the identity matrix, then it is called defective eigenvalue. 

For example if the eigenvalue is repeated 2 times, there will be only one eigevector associated with it.

There is an algorithm to generate another (linearly independent) eigenvector from this same eigenvalue called the defective eigenvalue method.

My question is: Does Maple have support for finding such additional eigenvectors?  The standard Eigenvectors does not seem to do this. Here is an example.

restart;
A :=Matrix([[1,-2],[2,5]]);
(eigen_values, eigen_vectors) := LinearAlgebra:-Eigenvectors(A);

By hand, using the defective eigenvalue method it is possible find second eigenvector for this eigenvalue, which is linearly independent of the one returned by Maple. Such as 

The method to find these additional eigenvector is described in number of places such as 

https://en.wikipedia.org/wiki/Defective_matrix

And the pdf at the bottom show a more detailed example.

I can code this method by hand to find complete set of L.I. eigenvectors for this defective eigenvalue.  

But before doing that, I thought to ask if Maple have buildin support for this, such as a single command to do this or some package.

I looked at help for LinearAlgebra and I am still not able to see anything, It only says this:

With an eigenvalue of multiplicity  k>1 , there may be fewer than  k linearly independent eigenvectors. In this case, the matrix is called defective.  By design, the returned matrix always has full column dimension.  Therefore, in the defective case, some of the columns that are returned are zero.  Thus, they are not eigenvectors.  With the option, output=list, only eigenvectors are returned.  For more information, see LinearAlgebra[JordanForm] and LinearAlgebra[SchurForm].
 

This PDF also describes using Maple, how to do it for one example

https://wps.prenhall.com/wps/media/objects/884/905485/chapt5/proj5.4/proj5-4.pdf

This PDF also describes how to do it by hand without using Maple, starting at end of page 3

http://www.math.utah.edu/~zwick/Classes/Fall2013_2280/Lectures/Lecture23_with_Examples.pdf

It is not too hard to code this method in Maple. But if Maple allready can do it, using some command, it will be better ofcourse.

 

To practice more in documentmode
Given  f := x^2 + y^2 + z^2 = 1  
Asked: 
surfacelevel on level 1  and surfacelevel upon wich the point (sqrt(3), 3, -2) is located.


1) x^2 + y^2 + z^2 = 1   : what solid ( a sphere with radius 1)  and  plot 
2) surfacelevel (solid sphere)   for point  (sqrt(3), 3, -2) and plot
3) Plot together 

Doing this calculation solely with contextpanel..no that's not always possible as it seems by trying to plot a sphere. 

restart;

with(plots);

a:=0.2; b:=0.2; c:=5.7;

ode1:=diff(x(t),t)=-y(t)-z(t);

ode2:=diff(y(t),t)=x(t)+a*y(t);

ode3:=diff(z(t),t)=b+z(t)*(x(t)-c);

ic1:=x(0)=-0.7;

ic2:=y(0)=-0.7;

ic3:=z(0)=1;

sol:=dsolve({ode1,ode2,ode3,ic1,ic2,ic3},{x(t),y(t),z(t)},numeric,method=classical[rk4],stepsize=0.10,output=listprocedure);
b:=rhs(sol[2]);

c:=rhs(sol[3]);

d:=rhs(sol[4]);

animate (pointplot3d, [ [b(t),c(t),d(t)], symbol=box, color=blue],t=15..100,
background = odeplot(sol, [x(t),y(t),z(t)],t=15..100,numpoints=7000),frames=20);

 

UPD
And "Error, (in plots/animate) incorrect first argument" BUT if i use classic functions (sin,cos,sqrt) instead of b,c,d - all is well.

 

For example [sin(t),cos(t),t/10]

For example [b(t),c(t),d(t)]
Error, (in plots/animate) incorrect first argument

Using latest Physics, I found case where it is not giving the Latex.

Please see attached worksheet.  This is on windows 10, Maple 2020.1.1

 

restart;

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 804 and is the same as the version installed in this computer, created 2020, September 7, 12:31 hours Pacific Time.`

ode:=diff(y(t),t) = -2*arctan(y(t))/(1+y(t)^2);

diff(y(t), t) = -2*arctan(y(t))/(1+y(t)^2)

sol:=dsolve(ode)

t+Intat((1/2)*(_a^2+1)/arctan(_a), _a = y(t))+_C1 = 0

Physics:-Latex(sol)

Error, (in unknown) invalid range for string subscript

latex(sol)

t+\int ^{y \left( t \right) }\!{\frac {{{\it \_a}}^{2}+1}{2\,\arctan
 \left( {\it \_a} \right) }}{d{\it \_a}}+{\it \_C1}=0

 


By trial and error, I found that the error was introduced in Physics 797. Since in Physics 796 it did work.

Here is screen shot

Download latex_issue_11.mw

If I call for the metric (27.27) in Stephani et al. in the Physics package, I expected the null tetrad employed to compute say the Weyl scalars would be the one given in conjunction with (27.27) (equation (27.22) in Stephani et al.). But, Weyl[scalars] returned long expressions for each of the five scalars, whereas with respect to the null tetrad in Stephani et al one expects the first two (or last two) scalars to be zero since the null vector k in their tetrad is the multiple pnd of Weyl. e_[nullvectors] and Setup(tetradmetric=null) followed by e_[ ] seem to output the same null tetrad, which does not appear to be that of Stephani et al. I assume this null tetrad is the null tetrad associated to the orthonomral tetrad that e_[ ]  returns if one hasn't used Setup(tetradmetric=null). How does Maple select this default orthonormal tetrad? What is the best way to set the null tetrad of Stephani et al as the null tetrad to compute Weyl[scalars]?

Here is a simpler example. Calling [27, 37, 1]. Stephani et al give the null tetrad in terms of the spacetime coordinates along with the metric in their equaiton (27.37). After using Setup(tetradmetic=null), e_[ ] returns a tetrad that might, I suppose, be that of Stephani et al. in disguise. Specifically, the tetrad vector defining the null congruence should have only a component with respect to the coordinate r, yet the Maple output gives expressions for the components with respct to the u and r coordinates for both the k and l elements of the null tetrad (while the expressions for the complex element m is exactly what one would expect). As in the previous example, all Weyl scalars are given by nontrivial expressions, even though two of them should be zero (since k is a multiple pnd). So is it the case that the experssions in the Maple output where one expects zero are in fact zero in disguise? The experssions are complicated enough that it is not obvious.  I have uploaded the Maple document for these calculations. SKMHH27_37.mw

I want to series expand the HeunB function. But I am facing some problems with this. please help. Here is the given HeunB function. 

HB1 := HeunB(5/2, -5^(1/4)*(2*M - R)/sqrt((2*M - R)*(4*M - R)), (17*sqrt(5))/10, (3*5^(3/4)*(2*M - R))/(2*sqrt((2*M - R)*(4*M - R))), 5^(1/4)*sqrt((2*M - R)*(4*M - R))*r^2/(2*(2*M - R)*R^2))

 

Here M, R are arbitrary constants.

I can use a whole package in a procedure or a command from a package. 
Writing your own code needs sometimes external code from outside a procedure used ( a package..what else more?)
This i don't find back in the Maple helpfiles easily using external code in procedure  
 

 This old example uses display3d naming what is the same as display ( there is no display3d command in Maple ) 
It gives the error 

diskmethod(f,0,2,10,fig);
Error, (in with) package plots does not export display3d

The disk methode calculates 
V = int(Pi*f(x)^2, x = a .. b)

 The Code for diskmethoddisplay

diskmethod:=proc(f,a,b,N,figure::evaln)
  local X,Y,s,x,dX,i,disk;
  with(plots,display3d);
  X:=array(0..N);Y:=array(1..N);disk:=array(1..N);
  dX:=evalf((b-a)/N);
  X[0]:=a;s:=0;
  for i to N do
    X[i]:=a+i*dX; Y[i]:=evalf(f(X[i]));
    s:=s+evalf(Pi*Y[i]^2*dX);
    disk[i]:=plot3d([x,Y[i]*cos(theta),Y[i]*sin(theta)],
                x=X[i-1]..X[i],theta=0..2*Pi,grid=[2,51]):

  end do;
  figure:= display3d({seq(disk[i],i=1..N)},
            axes=box,projection=0.8,orientation=[-60,70]);
  print(`The approximate volume using`,N,`disks is V =`, s);
end proc:

 

Can anyone help me to draw a zoom picture of any plotted function as shown in the picture??

would like to show a list system one by one and ask question and wait for answer and then plot graph and ask question and wait for answer and then show next system ask question and contiune this for loop

but my script show all system at once but can not one by one and no pop up dialog and no wait for answer

how to do?

 

restart:
interface(prettyprint=2):
with(ListTools):
with(StringTools):
with(ExcelTools):
with(SumTools):
with(Maplets[Elements]):
count := 1:

RR := Import("C:\\Users\\ohungyeeel\\Documents\\EquationsLists.xls", "Candidate", "A1:Q65535"):

for mm from 2 to 20 do

try:
if RR[count,13] = "Complex" or RR[count,13] = "Beautiful system but no result" then
dummy := 0:
else
print(RR[count,1],RR[count,2]):
sol := solve(RR[count,2]):
print("Source:",RR[count,3]):
print("Solution:",sol):

choosesystem := Maplet(InputDialog['ID1']("Choose system?", 'Yes1' = Shutdown(['Yes']), 'No1' = Shutdown(['No']))):
Maplets[Display](maplet):

if choosesystem = "Yes" then
RR[count,15] := "SystemChosenAndSolutionCorrect":
else
RR[count,15] := "NotChosenAndSolutionWrong":
end if:

plot(sol):

choosesystem := Maplet(InputDialog['ID1']("Like and it works?", 'Yes1' = Shutdown(['Yes']), 'No1' = Shutdown(['No']))):
Maplets[Display](maplet):

if choosesystem = "Yes" then
RR[count,16] := "Best":
else
RR[count,16] := "NotSelected":
end if:

end if:

catch:
print("error at ",RR[count,1],RR[count,2]):
end try:

count := count + 1:
od:
Export(RR, "C:\\Users\\ohungyeeel\\Documents\\EquationsLists10092020.xls", "Candidate", "A1"):

eq1 := diff(f(eta), eta, eta, eta, eta)+(2*f(eta)*(diff(f(eta), eta, eta, eta))+2*g(eta)*(diff(g(eta), eta)))*(1-phi)^2.5*(1-phi+phi*rhos/rhof)-sigmanf*M*(diff(f(eta), eta, eta))*(1-phi)^2.5/sigmaf = 0

eq2 := diff(g(eta), eta, eta)-(1-phi)^2.5*(1-phi+phi*rhos/rhof)*(2*(diff(f(eta), eta))*g(eta)-2*(diff(g(eta), eta))*f(eta))-sigmanf*M*g(eta)*(1-phi)^2.5/sigmaf = 0

eq3 := k[nf]*(diff(theta(eta), eta, eta))/(Pr*k[f])+((1-phi+phi*rhos*cps/(rhof*cpf))*2)*f(eta)*(diff(theta(eta), eta))-4*lambda*(1-phi+phi*rhos*cps/(rhof*cpf))*(f(eta)^2*(diff(theta(eta), eta, eta))+f(eta)*(diff(f(eta), eta))*(diff(theta(eta), eta)))+sigmanf*M*Ec*((diff(f(eta), eta))^2+g(eta)^2)/sigmaf = 0

eq4 := (1-phi)^2.5*(diff(chi(eta), `$`(eta, 2)))+2*Sc*f(eta)*(diff(chi(eta), eta))-sigma*Sc*(1+delta*theta(eta))^n*exp(-E/(1+delta*theta(eta)))*chi(eta) = 0

Boundary Conditions

f(0) = 0, (D(f))(0) = A1+gamma1*((D@@2)(f))(0), f(10) = 0, (D(f))(10) = 0, g(0) = 1+gamma2*(D(g))(0), g(10) = 0, theta(0) = 1+gamma3*(D(theta))(0), theta(10) = 0, chi(0) = 1, chi(10) = 0

Parameters

lambda = 0.1e-1, sigma = .1, Ec = .2, E = .1, M = 5, delta = .1, n = .1, Sc = 3, A1 = .5, gamma1 = .5, gamma2 = .5, gamma3 = .5, Pr = 6.2, phi = 0.1e-1, rhos = 5.06*10^3, rhof = 997, cps = 397.21, cpf = 4179, k[nf] = .6358521729, k[f] = .613, sigmanf = 0.5654049962e-5, sigmaf = 5.5*10^(-6)

 

 

Here are the inputs and output:

Why is it not possible to simplify the meter and the second (which are units).  If I do "simplify(pmin), the unit MeV becomes J and that is not what I want.  Simply said, is Maplesoft planning to include particle physics where c = h = 1 in the future version of the package "Physics"?

Until that happens, does someone knows how to give the answer in MeV/c.  The preceding problem was asking the mass of a particle in MeV/c^2.

Thank you in advance for your trouble.

Mario Lemelin

Geometry := 2;
if Geometry = 1 then
    f_obj := 4.5;
    f_fluo := 125;
    f_TIE := 45;
    d_sample := f_obj;
    d_max := 250;
    d_cam := f_TIE;
    d_interlens := d_max - d_cam;
end if;
if Geometry = 2 then
    f_obj := 4.5;
    f_fluo := 125;
    f_TIE := 45;
    d_sample := 4.6;
    d_max := 250;
    d_interlens := d_max - d_cam;
end if;
                               2

                              4.5

                              125

                               45

                              4.6

                              250

                          250 - d_cam

TIE := (((((Distance(d_cam)) . (Lens(f_TIE))) . (Distance(d_interlens))) . (Lens(f_obj))) . (Distance(d_sample))) . (Vector(2, [distance, angle]));
           Vector[column](%id = 18446746239510517390)

d_cam_solved := fsolve(coeff(TIE[1], angle, 1), d_cam, d_cam = 20 .. 100);
Error, `,` unexpected

Hello, if I set d_sample to 4.6 then I get "Error, ',' unexpected when I try to find a solution using fsolve. However if I set it to 4.5 then the fsolve computes no problem and I get a solution. Does somebody know if this means fsolve has no solution or have I made a mistake somewhere else? Thanks

First 502 503 504 505 506 507 508 Last Page 504 of 2428