dharr

Dr. David Harrington

8205 Reputation

22 Badges

20 years, 335 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

Another 2-D math problem. There needs to be a multiplication between the c^2 and the parenthesis. Then it easily plots, and fsolve gives the two solutions, which are obviously x=+/-R.

y(x)2.mw

The companion matrix can be used - for monic polynomials. The determinant is not unique and may not be the one you want.
 

with(LinearAlgebra):

p:=w^2 + u*w + v; #monic polynomial

u*w+w^2+v

(1)

w*IdentityMatrix(degree(p,w))-CompanionMatrix(p,w);

Matrix([[w, v], [-1, w+u]])

(2)

 


 

Download Companion.mw

There is no exact solution to the accuracy that Maple usually works at. You need to find a close "near enough" solution, which means you can't use fsolve. The easiest way is to minimize a sum of squares as in the worksheet below.
 

eqs := {(2^2/a^2+2^2/c^2-2*(2*2)*cos(x)/(a*c))/sin(x)^2 = 1/2.2393^2, (2^2/a^2+4^2/c^2+4*(2*2)*cos(x)/(a*c))/sin(x)^2 = 1/1.5968^2, (1^2/a^2+sin(x)^2/b^2+2^2/c^2+(2*2)*cos(x)/(a*c))/sin(x)^2 = 1/2.7896^2, 1/sin(x)^2*(2^2*sin(x)^2/b^2) = 1/2.8650^2};

{(4/a^2+4/c^2-8*cos(x)/(a*c))/sin(x)^2 = .1994230893, (4/a^2+16/c^2+16*cos(x)/(a*c))/sin(x)^2 = .3921922000, (1/a^2+sin(x)^2/b^2+4/c^2+4*cos(x)/(a*c))/sin(x)^2 = .1285038476, 4/b^2 = .1218290191}

(1)

Move the sin(x)^2 over to the right hand side

eqs2:=eqs*~sin(x)^2;

{4*sin(x)^2/b^2 = .1218290191*sin(x)^2, 4/a^2+4/c^2-8*cos(x)/(a*c) = .1994230893*sin(x)^2, 4/a^2+16/c^2+16*cos(x)/(a*c) = .3921922000*sin(x)^2, 1/a^2+sin(x)^2/b^2+4/c^2+4*cos(x)/(a*c) = .1285038476*sin(x)^2}

(2)

Sunm of squares of differences to minimize

S:=add((lhs(eq)-rhs(eq))^2,eq in eqs2);

(4*sin(x)^2/b^2-.1218290191*sin(x)^2)^2+(4/a^2+4/c^2-8*cos(x)/(a*c)-.1994230893*sin(x)^2)^2+(4/a^2+16/c^2+16*cos(x)/(a*c)-.3921922000*sin(x)^2)^2+(1/a^2+sin(x)^2/b^2+4/c^2+4*cos(x)/(a*c)-.1285038476*sin(x)^2)^2

(3)

Minimise subject to some constraints

Optimization:-Minimize(S,{a>=0,b>=0,c>=0,x>=0,x<=Pi});

[0.162642134569434096e-11, [a = HFloat(8.902766366460824), b = HFloat(5.7300076115735505), c = HFloat(6.416618564610261), x = HFloat(1.8419029174006967)]]

(4)

Gives a close solution, but not the one you wanted (though b is right). Probably there are several close solutions; it will be hard to decide - perhaps there are several combinations of a and c and x that work

 


 

Download Crystal.mw

In general fsolve only returns one answer. If you want others, you can specify a range to look for roots in, e..g, x=187.5..188.5 or give an initial guess, e.g, x=188. See the help for fsolve

Using fsolve to find the number of terms at which the error is 0.3 won't work because the error for an integer number of terms won't exactly be 0.3, so there is no solution. You know that the error must decrease so it is efficient to just add an extra term on and then recalculate the error in a loop.

The integration method _d01akc works well for these sorts of integrals.

restart;

f:=x->x;
y:=(n,x)->exp(-x/2)*sin(n*Pi*x);
w:=(x)->exp(x);

proc (x) options operator, arrow; x end proc

 

proc (n, x) options operator, arrow; exp(-(1/2)*x)*sin(n*Pi*x) end proc

 

proc (x) options operator, arrow; exp(x) end proc

(1)

Note the normalizing integral is always 1/2:

d:=int(w(x)*y(n,x)^2,x=0..1) assuming n::posint;

1/2

(2)

And we can get a general formula for the coefficients

int(w(x)*f(x)*y(n,x),x=0..1)/d assuming n::posint;
c:=unapply(%,n);

-8*n*Pi*(4*Pi^2*exp(1/2)*(-1)^n*n^2+3*(-1)^(1+n)*exp(1/2)+4)/(16*Pi^4*n^4+8*Pi^2*n^2+1)

 

proc (n) options operator, arrow; -8*n*Pi*(4*Pi^2*exp(1/2)*(-1)^n*n^2+3*(-1)^(n+1)*exp(1/2)+4)/(16*Pi^4*n^4+8*Pi^2*n^2+1) end proc

(3)

Fourierf:=0:Lerror:=infinity:
for n while Lerror>0.3 do
  Fourierf:=Fourierf+c(n)*y(n,x);
  Lerror:=evalf(sqrt(Int((f(x)-Fourierf)^2*w(x),x=0..1,method='_d01akc'))); #edit: test after adding term
  print(n,Lerror);
od:

1, .5894736138

 

2, .4627928802

 

3, .3943241015

 

4, .3483437147

 

5, .3156572254

 

6, .2905059507

(4)

 

 

Download Eigenfn_error.mw

In Maple 2015.2 evalf(Int(...)) quickly returns the answer you give.


q:=sin(omega*(T0-T)+Phi);

sin(omega*(T0-T)+Phi)

(1)

map(expand,q);algsubs(T0*omega+Phi=c,%);expand(%);subs(c=T0*omega+Phi,%);

sin(-T*omega+T0*omega+Phi)

 

-sin(T*omega-c)

 

-sin(omega*T)*cos(c)+cos(omega*T)*sin(c)

 

-sin(omega*T)*cos(T0*omega+Phi)+cos(omega*T)*sin(T0*omega+Phi)

(2)

 

 

 

 

Bits:-GetBits(19,-1..0,bits=8);

0, 0, 0, 1, 0, 0, 1, 1

Bits:-GetBits(-(19+1),-1..0,bits=8);

1, 1, 1, 0, 1, 1, 0, 0  #ones complement

Bits:-GetBits(-19,-1..0,bits=8);

1, 1, 1, 0, 1, 1, 0, 1  #twos complement

Since you know an eigenvalue of (square) M is 1, then

NullSpace(M-1*IdentityMatrix(RowDimension(M)));

returns the set of eigenvector(s) corresponding to eigenvalue 1.

map(x->add(i,i in Bits:-Split(x)),mylist);

or even simpler in Maple 2015 (wthout the hyperlink formatting):

map(add@Bits:-Split,mylist);

In Maple 2015:

f:=x->x^2;g:=x->x^3;
A:=Array([f,g]);
A(1)(m);

gives m^2

which I think is what you want.

The code works for me in Maple 2015 in 1-D math. It seems you have a space between print and ( which is interpreted as multiplication - remove it and it should work.

Use shift-enter to make a new line in the same execution group. (In more recent versions, the error message gives you this advice).

Following the observation from @tomleslie, you can just divide your equation through by x to get x^3+x*z+y and then implicitplot gives you what you want. 

implicitplot is confused by filled=true; wants a closed curve then filledregion=true

Perhaps you want

eq:=x^(1/2)+y^(1/2)=2;
solve(eq,y);
plot(%,x=0..1,filled=true);

 

x^(1/2)+y^(1/2) = 2

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



 

First 69 70 71 72 73 74 75 Last Page 71 of 81