vv

14122 Reputation

20 Badges

10 years, 203 days

MaplePrimes Activity


These are answers submitted by vv

f := (x-2)^2+1:
ff := f(x);
    (x(x)-2)^2+1

So, ff is a mathematical nonsense but syntactically correct.
Because  const(x)  simplifies to  const  we have e.g.
eval(ff, x=12);
    101

So, actually ff will work in numerical computations if eval is used.

Minimize(g, {x >= -2, x <= 2});
gives a syntax error. Use:

Minimize(g, -2..1);
         
[2., Vector[column](1, [1.])]


About the piecewise stuff.

The Optimization package assumes that the objective function and constraints are twice continuously differentiable.
You cannot expect correct results if they are not so.
 

Use

A:=ImportMatrix("yourpath\\-Validierung-Stahl-AI-.txt");

and you will have a 1214 x 1356  Matrix.

It's a specially cooked system.

 

restart;

sys:={
21000 = ((10/1000)/60)*4181*983*(x-y),
H = -((10/1000)/60)*4181*ln(1-((x-y)/(x-40))),
H = 124+102*ln(x-40)+(7+2*ln(x-40)) };

{21000 = (4109923/6000)*x-(4109923/6000)*y, H = -(4181/6000)*ln(1-(x-y)/(x-40)), H = 131+104*ln(x-40)}

(1)

evalf[1000]( fsolve(sys, {x,y,H}, {x=50..100,y=30..100,H=400..500} )   );

{H = 486.9792717948501357867918018059386067855156547114174326869481418810967243566285398975787784552235204706669347559475195400290118640303716801287372634993661346148619910232495800569296330392394830627549743601915872902357242427148731055409553705001658423528217321565927918891190491572966479397271232198426513612569355038417041808873881442623841262343853418832298327693593790610240451083265130917877844785166083247626127110701898215838963336513184408835894194697247808253085787062731557015693465725077077852896999228843274976631083570662482036300138497124715790019203338925750433405104219573337388245857036034857797986214888125128213468426540193206945839888044251684815660805344557214322036920099275934107239459489909624991382336777779198068497280647366466732283885118035797277802575588920390167295368604982886417919721008912823848353938665076022764471765288194352037535498835268165004232995241166817494393305369865683989720565493276815812710671414695060596389471870171101177308498370799633961387014797870, x = 70.65750866865388962274962328977939489377294903091858411945917234945764190715981783600325358893585110961932863462405500054380580852731304211782069883061069513954397685796059926183531905585579097223962590053390294660021611110475792368859465250322207982971943756610525306678494949905387521858682023969792135750167009335860887007621303198544321368035359069175536312026362350448543477228656103669649753257153387272484737179648441014252898713320281206372610926492497110938583549273159942143012717266939216706865489265272371561718110362755576369288566379279748261854103496737662967801146998815897672787725783471077732933162054089997390996937068458728288379330756605842335927722582205633540658909087373621564984005454626854462329726540402400771083530825578130314424765827873541484037247233111699579267679369342370990364580403457147196305388562501611449040359242137916479015561482141032930179069021129023984141254333721654117596419374749676562545752857082962606395129368846731712926167576535994552285681007055, y = 40.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000958347308577476849155817266967208600479833803954882640800358625509636683984970528639967775046602065201922053597715478431016498682880079609787467682537323162308315760688601560985179585421913717270699604525982018646370272917837250840635796722371496634076989812851876433207535565380863444548970077618286474517739106107056439827996365038277140944772163420380808436265855437736016956601251559483196367236991702787708084161571078609077635832578435472524929603687671421461968192303179415316459681254027553729208024619289830444214278717989841247739063311010334060299714878719957897139070573801145583905093544680767085382367073228848646299934993482758918092665796726848329309766789651450780060432670622190}

(2)

evalf(%);

{H = 486.9792718, x = 70.65750867, y = 40.00000000}

(3)

 

The exact answer should be Pr(infinity), where

Pr := proc(n::posint) local k; 
add((2/3)^k/3*`if`(is(sin(k)<=1/2),1,0),k=0..n)
end: 

which of course cannot be computed by Maple.
Maple answers:
Pr(13); evalf(%);
    
2839595/4782969
     0.5936887736
which is an approximation (not too good).

evalf[50](Pr(300));
    .59502775989667091140797025425657732088366035178640


 

 

You cannot because the function is not periodic (for any values of the parameters).

findOrderOf:= proc(g::posint, p::prime)
  local G,i;
  G:=1;
  for i from 1 to p-1 do
    G:=g*G mod p;
    if(G = 1) then return i end if;
  end do;  
end proc;

Maple has it builtin:  NumberTheory:-MultiplicativeOrder

You should read showstat(NumberTheory:-MultiplicativeOrder)
and try to understand the algorithm for an efficient implementation.

 

f := n -> sum(i^3, i=1..n);

But note that f(...) will fail if i is assigned, so a better definition is:

f := n -> sum('i'^3, 'i'=1..n);

 

solve(y>0);

or

Y:=numer(y)*denom(y);
SolveTools:-SemiAlgebraic([Y>0]);

obtain the answer in a few seconds (Maple 2017).

But there are 56 regions and it depends on your final aim to use them.

Edit. You may try to change the order of the variables and hope for simpler regions.

The Maple implementation NumberTheory:-Totient is of course faster (for large numbers), but the simplest one is probably:

eulerphi:=(n::posint) -> add(`if`(igcd(k,n)=1,1,0),k=1..n);

 

Should be

solve(SysEqE,{diff(phi[1](t),t),diff(phi[3](t),t)});

op(0,a);

But you should try to see how this appeared, because it is a nonsense (probably from a programming error).

I don't think it has a special name; it is a multiplication by a diagonal matrix.

But are you sure it is useful? AFAIK the eigenvector algorithms always do a row (or column) normalization.

Use
evalc(Re(expr));

 

restart;

eq1 := diff(u1(x), x, x)+diff(u2(x), x)+int(2*x*s*(u1(s)-3*u2(s)), s = 0 .. 1) = 6*x^2+3*x*(1/10)+8;
eq2 := diff(u1(x), x)+diff(u2(x), x, x)+int((3*(s^2+2*x))*(u1(s)-2*u2(s)), s = 0 .. 1) = 21*x+4/5;
bcs := u1(0)+(D(u1))(0) = 1, u2(0)+(D(u2))(0) = 1, u1(1)+(D(u1))(1) = 10, u2(1)+(D(u2))(1) = 7;

EQ1 := diff(u1(x), x, x)+diff(u2(x), x)+a*x = 6*x^2+3*x*(1/10)+8;
EQ2 := diff(u1(x), x)+diff(u2(x), x, x)+b*x+c = 21*x+4/5;

diff(diff(u1(x), x), x)+diff(u2(x), x)+int(2*x*s*(u1(s)-3*u2(s)), s = 0 .. 1) = 6*x^2+(3/10)*x+8

 

diff(u1(x), x)+diff(diff(u2(x), x), x)+int(3*(s^2+2*x)*(u1(s)-2*u2(s)), s = 0 .. 1) = 21*x+4/5

 

u1(0)+(D(u1))(0) = 1, u2(0)+(D(u2))(0) = 1, u1(1)+(D(u1))(1) = 10, u2(1)+(D(u2))(1) = 7

 

diff(diff(u1(x), x), x)+diff(u2(x), x)+a*x = 6*x^2+(3/10)*x+8

 

diff(u1(x), x)+diff(diff(u2(x), x), x)+b*x+c = 21*x+4/5

(1)

sol:=dsolve({EQ1,EQ2},{u1(x),u2(x)}):

U1:=unapply( eval(u1(x),sol),x):
U2:=unapply( eval(u2(x),sol),x):

sys:=eval([(lhs-rhs)(eq1),(lhs-rhs)(eq2),bcs],[u1=U1,u2=U2]):

map(coeffs,sys,x):

consts:=solve(%):

SOL:=simplify(eval(sol,consts));

{u1(x) = (-55897*exp(1-x)+27844*exp(2-x)+35538*exp(1+x)+(229194*x^2+1583820*x-1422696)*exp(1)+(-45192*x^2-385320*x+335340)*exp(2)-300822*x^2-1458780*x-55263*exp(x)+1319226)/(-49980*exp(2)+232200*exp(1)-250080), u2(x) = (-55897*exp(1-x)+27844*exp(2-x)-35538*exp(1+x)+(464400*x^3-681738*x^2+1399212*x-1095936)*exp(1)+(-99960*x^3+160164*x^2-309456*x+259476)*exp(2)-500160*x^3+669894*x^2-1398996*x+55263*exp(x)+1038390)/(-49980*exp(2)+232200*exp(1)-250080)}

(2)

U1:=unapply( eval(u1(x),SOL),x):             # Check
U2:=unapply( eval(u2(x),SOL),x):             #
simplify(eval({eq1,eq2,bcs},[u1=U1,u2=U2])); #

{1 = 1, 7 = 7, 10 = 10, 21*x+4/5 = 21*x+4/5, 6*x^2+(3/10)*x+8 = 6*x^2+(3/10)*x+8}

(3)

 


Download sysode-int.mw

 

n is supposed to be a positive integer.

We compute the indefinite integral.

 

 

J:=n -> Int((2*cos(Pi*x*n/T)^2-1)*sin(Pi*x*n/T)*cos(Pi*x*n/T)/(sin(Pi*x/T)*cos(Pi*x/T)), x);

proc (n) options operator, arrow; Int((2*cos(Pi*x*n/T)^2-1)*sin(Pi*x*n/T)*cos(Pi*x*n/T)/(sin(Pi*x/T)*cos(Pi*x/T)), x) end proc

(1)

value(combine(J(n+1)-J(n)));

(1/2)*T*sin(2*Pi*x*(2*n+1)/T)/(Pi*(2*n+1))

(2)

K:=unapply(%,n);

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

(3)

J(n)=value(J(1))+Sum(K(k),k=1..n-1);  # Answer

Int((2*cos(Pi*x*n/T)^2-1)*sin(Pi*x*n/T)*cos(Pi*x*n/T)/(sin(Pi*x/T)*cos(Pi*x/T)), x) = -x+2*T*((1/2)*cos(Pi*x/T)*sin(Pi*x/T)+(1/2)*Pi*x/T)/Pi+Sum((1/2)*T*sin(2*Pi*x*(2*k+1)/T)/(Pi*(2*k+1)), k = 1 .. n-1)

(4)

value(%);  # Version of the answer

int((2*cos(Pi*x*n/T)^2-1)*sin(Pi*x*n/T)*cos(Pi*x*n/T)/(sin(Pi*x/T)*cos(Pi*x/T)), x) = -x+2*T*((1/2)*cos(Pi*x/T)*sin(Pi*x/T)+(1/2)*Pi*x/T)/Pi+((1/8)*I)*T*(exp((2*I)*Pi*x*(2*n+1)/T)*LerchPhi(exp((4*I)*Pi*x/T), 1, n+1/2)-exp((6*I)*Pi*x/T)*LerchPhi(exp((4*I)*Pi*x/T), 1, 3/2)+exp(-(6*I)*Pi*x/T)*LerchPhi(exp(-(4*I)*Pi*x/T), 1, 3/2)-LerchPhi(exp(-(4*I)*Pi*x/T), 1, n+1/2)*exp(-(2*I)*Pi*x*(2*n+1)/T))/Pi

(5)

simplify(diff( (lhs-rhs)(%), x)); # Check

0

(6)
First 77 78 79 80 81 82 83 Last Page 79 of 121