Konstantin@

220 Reputation

9 Badges

17 years, 120 days
Kharkov
PhD in Numerical Optimization.

MaplePrimes Activity


These are questions asked by Konstantin@

I recently encontered a very strange result.

Lets define the procedure:

Fg := proc(x0,y0)
if (x0>=0)and(x0<=3) and (y0<=x0+2) and (y0>=x0-1) and (y0>=0) and (y0 <=3) then
return y0*(3-y0)*x0*(3-x0)*(x0+2-y0)*(y0-x0+1);
else
return 0;
end if:
end proc:

The plot looks like needed:

plot3d('Fg'(x,y), x=0..3, y=0..3);

But integration returns weird result:

evalf(Int('Fg'(x,y), [x=0..1, y=0..2.1]));

7.888753239

evalf(Int('Fg'(x,y), [x=0..1, y=0..2.2]));

Error, (in evalf/int) when calling 'Fg'. Received: 'cannot determine if this expression is true or false: 0 <= x and x <= 3 and y <= x+2 and x-1 <= y and 0 <= y and y <= 3'

Consider substutition with use of a function:

subs(F(x,y)=f(x)+g(y), F(x,y));

As expected, Maple returns the proper answer:

f(x)+g(y)

But 

subs(F(x,y)=f(x)+g(y), F(x,x));

returns 

F(x,x)

How to force Maple recognize F as a function, in order to obtain

f(x)+g(x)

in return?

The functions algsubs, applyrule work in the same way.

I want to calculate the following integral numerically with required precision.

First, the functions are defined:

G1:=-0.9445379894;
f:= (x) -> 0.9/abs(x-0.4)^(1/3)+0.1/abs(x-0.6)^(1/2);
U1 := unapply(-exp(-x)*(evalf(Int(f(t)*exp(t), t = 0 .. x))+G1)/2-exp(x)*(evalf(Int(f(t)*exp(-t), t = 0 .. x))+G1)/2, x);
U:= unapply(-exp(x)/2*(evalf(Int(f(t)*exp(-t),t=0..x))+G1)+exp(-x)/2*(evalf(Int(f(t)*exp(t),t=0..x))+G1), x);

Next, I calculate the integral in numerical form:

evalf(Int(U1(x)^2+U(x)^2-2*f(x)*U(x), x=0..1, digits=4, method = _Gquad));

If I specify digits=4, Maple return the answer -0.4291

If I use digits=5 or larger, Maple return someting like this

Is it possible to increase precision of calculation?


 

 

I try to solve numerically a boundary VP for ODE with different order of discontinuity of right part.

Say, the following BVP is given:

y''(x)+y'(x)+y(x)=F(x)

y(0)=1, y(2)=1

Let's use piecewise right part

F  := piecewise(x<=1, -x, x>1, 2*x+(x-1)^2)

plot(piecewise(x<=1, -x, x>1, 2*x+(x-1)^2), x=0..2,thickness=5)

The function

piecewise(x<=1, 1-x, x>1, (x-1)^2)

plot(piecewise(x<=1, 1-x, x>1, (x-1)^2), x=0..2, color=blue,thickness=5)

as obviuos, satisfies the BVP exclung the point x=1, where its 1st and 2nd derivatives are discontinuos.

Numerical solution

N0:=6:
As:=dsolve([diff(y(x), x$2)+diff(y(x), x)+y(x)=F,  y(0)=1, y(2)=1], y(x), type=numeric, output = Array([seq(2.0*k/N0, k=0..N0)]), 'maxmesh'=500, 'abserr'=1e-3):

provides the solution essentially different to exact one described above:

But if to use the right part

F := piecewise(x<=1, x^2+x+2, x>1, -x^2+x)

plot(piecewise(x<=1, x^2+x+2, x>1, -x^2+x), x=0..2, color=blue,thickness=5)

for which the function

piecewise(x<=1, 1-x+x^2, x>1, -1+3*x-x^2)

plot(piecewise(x<=1, 1-x+x^2, x>1, -1+3*x-x^2), x=0..2, thickness=5)

satisfies the BVP excluding x=1, where this function has discontinuity of 2nd derivative only, the corresponding numerical solution is very similar to this exact solution:

This reason of the difference between these two cases is clear. In the first case both 1st and 2nd derivatives are discontiuos, while in the second one -- 1st derivative is contiuos.

I wonder, if there are numerical methods, implemeted in Maple, for numerical solution of the first type BVP with non-smooth right part?

Dear friends!

Please, suggest me, how to build a plot loocking as the following

plot

where the values on the axis X (1, 5, 10, 50, ...) are categories, not numbers?

1 2 3 4 5 6 Page 3 of 6