## 140 Reputation

9 years, 216 days

## Improving time consuming code...

Maple

Hi

The following code is time consuming. Please improve the code, if it is possible. Thanks for taking your time

restart;

T := time():
M := 50:
Digits := 30:
L := 500:
R := (1/2):
nu := 0.3:
Em := 0.70e11:
N := 1:
Ec := 0.380e12:
E:= Em*(1-(y/h+1/2)^N)+Ec*(y/h+1/2)^N:
X :=(int(E*(z+(1/2)*R), [z = y-(1/2)*R .. 0, y = -(1/2)*R .. (1/2)*R]))/(int(E, [z = y-(1/2)*R .. 0, y = -(1/2)*R .. (1/2)*R])):
beta := Pi^2/L^2:
G := E/(2*(1+nu)):
phi := add(b[n]*y^n, n = 0 .. M):
Eq := diff(phi, y\$2)+(diff(E, y))*(diff(phi, y))/E+((diff(E, y\$2))/E-((diff(E, y))/E)^2)*phi-2*beta*(1+nu)*(phi-1):
st := [seq(coeftayl(Eq, y = 0, j), j = 0 .. M-2)]:
for k to M-1 do
b[k+1] := solve(st[k], b[k+1])
end do:
phi := subs(y = y-X, phi):
phi := subs(solve({eval(phi, y = -(1/2)*R+X), subs(y = f, phi)}, {b[0], b[1]}), phi):
f := piecewise(`and`(z >= -R, z <= 0), z+(1/2)*R+X, -z+(1/2)*R+X):
Digits := 4:
int(phi*G, [z = y-(1/2)*R .. 0, y = -(1/2)*R .. (1/2)*R], numeric)+int(phi*G, [z = 0 .. -y+(1/2)*R, y = -(1/2)*R .. (1/2)*R], numeric);

Time = Time()-T;

Note that the calculation of the integration requires alot of time. Both returns a similar result (calculation of an integration is sufficient)

## Reducing Run-time for solving a nonlinea...

Maple

Hi

I want to employ FDM to solve nonlinear ODE. Since large expressions in terms of s[1] are generated, the program lose its efficiency for N>6 (It requires long run-time). Please amend the program, if it is possible to reach more precision for N>10. Moreover, is there a Maple command to dsolve this ode?

Thanks alot

restart;

sy := 2400.:

Hp := 0.1e9:

P := -900.:

a := 20.:

c := 21.:

N := 6:

s[0] := P:

h := (c-a)/N:

Et := (r*(diff(sr(r), r))-sy)/Hp:

Er := (sy-r*(diff(sr(r), r)))/Hp:

ode := simplify(Er-Et-r*(diff(Et, r))*(1+(diff(Et, r))*r/(2+4*Et))):

ode:=subs(diff(sr(r), r, r) = (s[k+1]-2*s[k]+s[k-1])/h^2, diff(sr(r), r) = (s[k+1]-s[k-1])/(2*h), r = h*k+a, ode):

for k to N-1 do

s[k+1] := solve(ode, s[k+1])[1]

end do:

s[1] := fsolve(s[N] = -200., s[1] = -900 .. -100);

plots[pointplot]([seq([h*k+a, s[k]], k = 0 .. N)]);

## Analytical integration bug...

Maple 2016

Hi

I use Maple 2016.

The following command calculates semicircle perimeter, but it returns infinity.

`assuming`([int(sqrt(1+(diff(sqrt(R^2-(x-R)^2), x))^2), x = 0 .. 2*R)], [R > 0])

## Positive integrand and negative integral...

Maple

int(Integrand, [z = -R .. R, y = 0 .. R], numeric);

plots[implicitplot3d](Phi = phi, z = -R .. R, y = 0 .. R, Phi = 0 .. 0.1e-1, color = ColorTools[Gradient]("Red" .. "Blue", best)[4], grid = [50, 50, 20]);

Why the integrand has positive real amounts in the domain [z = -R .. R, y = 0 .. R] for R=0.5, but the integral value is negative?

## Nontrivial solution for large matrix...

Maple

Hi

I got an square matrix (70×70) from MATLAB (please download attached text file 1.txt). Following codes are used in MAPLE, but an unknown error is occurred. It seems that matrix is divided in two submatrices. Please hint me or run the codes to obtain fiirst three minimum real positive roots of the determinant.

Thank you for taking your time

Maple codes

Digits:=150: