vv

13992 Reputation

20 Badges

10 years, 40 days

MaplePrimes Activity


These are answers submitted by vv

The system is not compatible. Execute in your worksheet:

solve({A[1], A[2], A[3], A[4], A[5]}, [a, b, c, d, e, f]);
    [[a = 2+b, b = b, c = -2*b, d = -6+4*b, e = -4*b+3, f = -1+3*b]]
subs(%[], A[6]);
    43 = 51

eqx:=diff(f(b),b,b) = -(1/2)*(6*(diff(f(b), b))*f(b)-8*b*(diff(f(b), b))-2*f(b)+diff(f(b),b)+2)*(diff(f(b),b))/((-b+f(b))*(-1+f(b))):

ic:=f(3/8)=0, D(f)(3/8)=d:

s:=dsolve({eqx,ic},numeric,parameters=[d]):

pp:=proc(u)
  s(parameters=[d=u]);
  abs( eval(f(b),s(1/2)) - 1/2)
end:

N:=100000: V:=Vector(N/10, i-> pp(2.4+i/N)):

min(V):min[index](V):
s(parameters=[2.4+%/N]);
#  [d = 2.485270000]
s(3/8);
# [b = .375000000000000, f(b) = 0., diff(f(b), b) = 2.485270000]
s(1/2);
#[b = .500000000000000, f(b) = .499859411261823, diff(f(b), b) = 1.00693188008423]
plots[odeplot](s,3/8..1/2);



The ODE may be expressed wrt f''(b) by:

eq:=diff(f(b), b, b) = (1/2)*((-8*b+6*f(b)+1)*(diff(f(b), b))^2+(-2*f(b)+2)*(diff(f(b), b))+2*b-2*f(b))/(f(b)*(b-f(b)));

Note that at both boundary values, the denominator is 0 (!).

Let's try using parameters for an IC problem:
b0:=(3/8+1/2)/2:
ss:=dsolve({eq, f(b0)=A, D(f)(b0)=B}, numeric, parameters=[A,B]):
pp:=proc(u,v)
ss(parameters=[A=u,B=v]);
abs(eval(f(b),ss(3/8)) - 0) + abs( eval(f(b),ss(1/2)) - 1/2)
end:

We want to minimize pp in order to be as close as possible to your conditions.
Here only a crude attempt is made:

M:=Matrix(37, (i,j) -> pp(i/100,j/100)):
min[index](M);min(M);
 
                            37, 37
                  0.44450458358379435

ss(parameters=[A=0.37,B=0.37]);
ss(3/8);
  [b = .375000000000000, f(b) = .362588443481166, diff(f(b), b) = -0.179678246588966e-1]
ss(1/2);
  [b = .500000000000000, f(b) = .418083859897371, diff(f(b), b) = 1.17994432455953]

So, it seems that it's not possible to satisfy acceptably your IC.

 

 

 

Executing
eval(L);
in your document ==>
table([c1 = .5*L, c2 = .5*L])

So, you have defined somewhere a hidden infinite recursive definition for L.

That is why I always prefer a clean worksheet mode (with 1D math if possible)
such that everything is visible!

Edit.

Ok, looking closer, the recursive definition is not hidden. It appears at the beginning of the document:

L[c1] := 0.5*L;
L[c2] := 0.5*L;

So, just change:

L[c1] := 0.5*K;
L[c2] := 0.5*K;
and it works

 

 

Maple computes correctly the integral in [0,1] and [1,2], but not in [0,2]. It's a pity.

J:=Int(floor(x^2), x = 0..2);
IntegrationTools:-Split(J,1): value(%);
       5-sqrt(2)-sqrt(3)


They are mathematically equivalent, but `simplify/D` does not implement this. But,

e1 := (D[1]@D[1])(f)(x);
convert(e1,diff): convert(%,D): lprint(%);
    ((D@@2)(f))(x)

p1:=plot3d([[x,y,-y^2],[x,y,x^2]], x=0..1,y=0..x):
p2:=plot3d([[1,y,z]], z=-y^2..1,y=0..1,transparency=0.5):
p3:=plot3d([[x,0,z]], x=0..1,z=0..x^2,transparency=0.5):
p4:=plot3d([[x,x,z]], x=0..1,z=-x^2..x^2,transparency=0.5):
plots[display](p1,p2,p3,p4,labels=["x","y","z"]);

# less memory used

myPDF := (v,t) -> piecewise(t < 0, 0, t < v, 1/v, 0):
myD:= Distribution(PDF = curry(myPDF, 1)):  #v=1
Mean(myD);
    1/2

J:=Int( exp(-I*k*x)/cosh(x), x=-infinity..infinity):
value(IntegrationTools:-Change(J,exp(x)=t));

1. Due to the wonderful 2D math, a variable named _ appeared. This must be corrected.

2. The equation for solve is too complicated to be solved symbolically.

3. For fsolve you must have numerical values for parameters.

PW1:=proc(e::specfunc(anything,piecewise))
local f, o:=op(e);
f:=proc()
  if   nargs=3 then '`if`'(args)
  elif nargs=2 then '`if`'(args,0)
  else '`if`'(args[1],args[2],f(args[3..-1])) fi
end;
f(o)
end:

PW:=e->subsindets(e, specfunc(anything, piecewise), PW1):
####################

PW(piecewise(x<1, 10, x<2, 20, x<3, 30));
   
`if`(x < 1, 10, `if`(x < 2, 20, `if`(x < 3, 30, 0)))

f:=piecewise(x < 0, piecewise(y < 0, 0, 1), piecewise(y < 0, 1, 0)):
PW(f);
    `if`(x < 0, `if`(y < 0, 0, 1), `if`(y < 0, 1, 0))

L:=(u,v)->u(v(f_(x,t)))-v(u(f_(x,t))):
alias(``=f_(x,t));
#########################
v:=f->diff(f,x):
w:=f->x*diff(f,t):
L(v,w);
   

u:=f->x*t*diff(f,x,t):
L(u,w):  simplify(%);

   

I was curious to see how much the compiler can help in such problems.

It seems that in Carl's version (which is very fast) the compiler is not very useful.
I used practically my original version, made compilable.

Here it is:

Tri1:=proc(n::integer,V::Vector(datatype= float[8]),
     X::Vector(datatype= float[8]),Y::Vector(datatype= float[8]),
     Ax::float[8],Ay::float[8],Bx::float[8],By::float[8],Cx::float[8],Cy::float[8])
   local k::integer,a::float[8],b::float[8];
   for k to n do
     a:=V[k]; b:=V[n+k];
     if a+b>1 then a:=1-a;b:=1-b fi;
     X[k]:=Ax+(Bx-Ax)*a+(Cx-Ax)*b;
     Y[k]:=Ay+(By-Ay)*a+(Cy-Ay)*b
   od;  
end:

CTri1:=Compiler:-Compile(Tri1):


Tri:=proc(n,Ax,Ay,Bx,By,Cx,Cy)

local
  V:=LinearAlgebra:-RandomVector(2*n, generator= 0..1., datatype= float[8]),
  X:=Vector(n,datatype= float[8]), Y:=Vector(n,datatype= float[8]);
global Ctri1;
  CTri1(n,V,X,Y,Ax,Ay,Bx,By,Cx,Cy);
X,Y
end:
####
Ax:=-1: Ay:=0:  # Triangle T = ABC
Bx:=0:  By:=4:
Cx:=2:  Cy:=1:
n:=6000:           # number of random points
T:=CodeTools:-Usage(Tri(n,Ax,Ay,Bx,By,Cx,Cy),iterations=100):
memory used=195.55KiB, alloc change=18.38MiB, cpu time=940.00us, real time=920.00us, gc time=0ns

Compare with Carl's version (not compiled)

T:= CodeTools:-Usage(SampleTriangle([[-1,0],[0,4],[2,1]], 6000), iterations=100):
memory used=0.86MiB, alloc change=8.21MiB, cpu time=24.18ms, real time=6.52ms, gc time=1.25ms

Note that I have used iterations=100, otherwise the timing was not stable enough.





 

The definition is simple and clearly presented in the help page.

HeunT is the solution of the differential equation (depending on three parameters):

 

f(0)=1,  f'(0)=0

 

It is an entire function. For other properties:

FunctionAdvisor(HeunT);

First 107 108 109 110 111 112 113 Last Page 109 of 120