Paras31

240 Reputation

9 Badges

1 years, 360 days
Agricultural University of Athens
PhD Candidate

Social Networks and Content at Maplesoft.com

Teacher of Mathematics with a proven track record of working in education management. Proficient in Ease of Adaptation, Course Design, and Instructional Technology. Holds a Bachelor's degree in Mathematics from the University of the Aegean and a Master's in Applied Mathematics at the Hellenic Open University, focusing on Ordinary and Partial Differential Equations. His enthusiasm lies in the application of mathematical models to real-world contexts, such as epidemiology and population growth. Aside from his passion for teaching, Athanasios enjoys football, basketball, and spending time with his dogs.

MaplePrimes Activity


These are replies submitted by Paras31

@dharr 

I have implemented the solution in Mathematica using a modular approach with NumericQ guards to ensure robust numerical evaluation. The integration is split into the diagonal 'wings' ($\lambda_1, \lambda_2$) and the horizontal segment ($\lambda_3$)
approxW[x_?NumericQ, t_?NumericQ] :=
Module[{temp1, temp2},
  temp1 = NIntegrate[
    Re[v[λ1[r], x, t]*dλ1[r] - v[λ2[r], x, t]*dλ2[r]], {r, 0, Infinity},
    AccuracyGoal -> 8, PrecisionGoal -> 8, MaxRecursion -> 25];
  temp2 = NIntegrate[
    Re[v[λ3[s], x, t]*dλ3[s]], {s, -l, l},
    AccuracyGoal -> 8, PrecisionGoal -> 8, MaxRecursion -> 25];
  temp1 + temp2]

approxW[0.01, 0.1] = 0.375077, which is different from my solution

@dharr 

The Fokas Method represents the solution as an integral in the complex $\lambda$-plane. To ensure the integral converges and is well-defined, we must stay within the $D^+$ domain, where the exponential term $e^{-d\lambda^2 t}$ decays rapidly.

Avoiding Poles: The boundary conditions (Robin type) introduce "poles" (points where the denominator becomes zero) along the real axis. By lifting the horizontal contour $\lambda_3$ by $+i$ (the $s+i$ shift you used), you effectively "fly over" these singularities, making the numerical integration smooth and reliable.

Analyticity: Because the function is analytic within the region enclosed by your chosen contours ($\lambda_1, \lambda_2, \lambda_3$), the Cauchy Integral Theorem ensures that this path provides the exact solution for the heat equation part of the Hopf-Cole transform.

I have solved this problem with the Fokas method and with the Fourier Series expansions, and as you can observe, the results are similar but not the same. For this reason I asked how to create  more accurate plots

Download ex2.mw

Download Fourier_ex.2_.mw

@dharr @acer Thanks for your assistance. Should I increase the tolerance for more accurate plots?

@dharr First of all, thank you very much for your help. Numerically, I validated my research, although when I tried to create the plots, Maple ran for too much time. Is there a trick to creating the plots faster? I have highlighted the code blocks in red.

Download third_try.mw

@dharr I have tried what you suggested, but as you can see, approx_w is not numeric. It should be 0.375077

Download second_try.mw

@acer 

Yes exactly! I tried running it again after fixing k*(L-x), but it still runs indefinitely.

Download resources.mw

@sand15 You are right the integrand must be integrand1 := Re(eval(V, k = k1(r))*dk1(r) - eval(V, k = k2(r))*dk2(r)):

@dharr Thank you!! It was difficult to find what to do hear. There were no other references for Fokas Method on Maple!


@Rouben Rostamian, I created a function, so the solution is given faster now, but when I try to replicate the two panels from the textbook, as you can see they are a bit different


 

restart; with(plots); with(ColorTools); with(LinearAlgebra); with(Student[VectorCalculus]); V := proc (k, x, t) options operator, arrow; -((1/2)*I)*exp(I*k*x-k^2*t)*(1/(k-I)+1/(k+I)-k*(1/(k^2+I)+1/(k^2-I)))/Pi end proc; k1 := proc (r) options operator, arrow; r*exp(((1/8)*I)*Pi) end proc; k2 := proc (r) options operator, arrow; r*exp(((7/8)*I)*Pi) end proc; dk1 := proc (r) options operator, arrow; exp(((1/8)*I)*Pi) end proc; dk2 := proc (r) options operator, arrow; exp(((7/8)*I)*Pi) end proc; u1 := proc (x::numeric, t::numeric) try evalf(Int(Re(V(k1(r), x, t)*dk1(r)-V(k2(r), x, t)*dk2(r)), r = 0 .. infinity)) catch: 0 end try end proc; approx_u := proc (x::numeric, t::numeric) Re(evalf(exp(-x/sqrt(2))*cos(t-x/sqrt(2))+u1(x, t))) end proc; surf := plot3d(proc (x, t) options operator, arrow; approx_u(x, t) end proc, 0 .. 3, 0 .. Student[VectorCalculus]:-`*`(2, Pi), grid = [40, 40], axes = boxed, labels = ["x", "t", "u(x,t)"], title = "Fokas Method Solution of Half-Line Heat Equation", shading = zhue)

 

``

 

 

p1 := plot(proc (x) options operator, arrow; approx_u(x, .1) end proc, 0 .. 2, color = red); p2 := plot(proc (x) options operator, arrow; approx_u(x, .2) end proc, 0 .. 2, color = green); p3 := plot(proc (x) options operator, arrow; approx_u(x, .3) end proc, 0 .. 2, color = blue); p4 := plot(proc (x) options operator, arrow; approx_u(x, .4) end proc, 0 .. 2, color = magenta); p5 := plot(proc (x) options operator, arrow; approx_u(x, .5) end proc, 0 .. 2, color = RGB(1.0, .5, 0.)); p6 := plot(proc (x) options operator, arrow; approx_u(x, .6) end proc, 0 .. 2, color = cyan); p0 := plot(exp(-x), x = 0 .. 2, linestyle = dash, color = black); display([p0, p1, p2, p3, p4, p5, p6], legend = ["u(x,0)", "t=0.1", "t=0.2", "t=0.3", "t=0.4", "t=0.5", "t=0.6"], legendstyle = [location = right, font = [Helvetica, 12]], view = [0 .. 2, 0 .. 1.2], labels = ["x", "u(x,t)"], labelfont = [Helvetica, 12], axes = boxed, title = "Short-Time Behavior of u(x,t)")

 

q1 := plot(proc (x) options operator, arrow; approx_u(x, .5) end proc, 0 .. 2, color = red); q2 := plot(proc (x) options operator, arrow; approx_u(x, 1.0) end proc, 0 .. 2, color = green); q3 := plot(proc (x) options operator, arrow; approx_u(x, 1.5) end proc, 0 .. 2, color = blue); q4 := plot(proc (x) options operator, arrow; approx_u(x, 2.0) end proc, 0 .. 2, color = magenta); q5 := plot(proc (x) options operator, arrow; approx_u(x, 2.5) end proc, 0 .. 2, color = RGB(1.0, .5, 0.)); q6 := plot(proc (x) options operator, arrow; approx_u(x, 3.0) end proc, 0 .. 2, color = cyan); q0 := plot(exp(-x), x = 0 .. 2, linestyle = dash, color = black); long_plot := display([q0, q1, q2, q3, q4, q5, q6], title = "Long-Time Behavior of u(x,t)", labels = ["x", "u(x,t)"], labelfont = [Helvetica, 12], legend = ["u(x,0)", "t=0.5", "t=1.0", "t=1.5", "t=2.0", "t=2.5", "t=3.0"], legendstyle = [location = right, font = [Helvetica, 10]], axes = boxed, view = [0 .. 2, -1.2 .. 1.2])

 

 

 

``


 

Download fokas_method_new.mw

@dharr Thank you for your answer and the time you spent looking at my question. I will try to find a faster way. 

@dharr oh!! Thank you this info is very usefyl.

restart; with(plots); with(plottools); TR := proc (col) options operator, arrow; cat(`#mo("►",mathcolor="`, col, `")`) end proc; TL := proc (col) options operator, arrow; cat(`#mo("◄",mathcolor="`, col, `")`) end proc; TU := proc (col) options operator, arrow; cat(`#mo("▲",mathcolor="`, col, `")`) end proc; TD := proc (col) options operator, arrow; cat(`#mo("▼",mathcolor="`, col, `")`) end proc; `print/slash` := proc (x, y) Typesetting:-mrow(Typesetting:-Typeset(x), Typesetting:-mo(), Typesetting:-mo("/", fontweight = "bold"), Typesetting:-mo(), Typesetting:-Typeset(y)) end proc; h := .2; Rint := 1/4; Rout := 2; aint := arcsin(h/Rint); aout := arcsin(h/Rout); opt := color = red, thickness = 2; theta1 := 0-(1/3)*Pi-.1; theta2 := Pi+(1/4)*Pi+.3; phi1 := 3*Pi*(1/4)-.3; phi2 := 2*Pi+(1/4)*Pi+.3; x1 := Rint*cos(theta1); y1 := 1+Rint*sin(theta1); x2 := Rint*cos(theta2); y2 := 1+Rint*sin(theta2); x3 := Rint*cos(phi1); y3 := -1+Rint*sin(phi1); x4 := Rint*cos(phi2); y4 := -1+Rint*sin(phi2); t := .5; x_arrow1 := (1-t)*x1+t*x4; y_arrow1 := (1-t)*y1+t*y4; x_arrow2 := (1-t)*x2+t*x3; y_arrow2 := (1-t)*y2+t*y3; display(arc([0, 0], Rout, aout .. 3*Pi-aout, opt), arc([0, 1], Rint, theta1 .. theta2, opt), arc([0, -1], Rint, phi1 .. phi2, opt), line([x1, y1], [x4, y4], opt), line([x2, y2], [x3, y3], opt), textplot([x_arrow1, y_arrow1, TU("red")], font = [Times, 20]), textplot([x_arrow2, y_arrow2, TD("red")], font = [Times, 20]), textplot([0, Rout, TL("red")], font = [Times, 20]), textplot([0, -Rout, TR("red")], font = [Times, 20]), textplot([0, -1.25, TR("red")], font = [Times, 20]), textplot([0, 1.25, TL("red")], font = [Times, 20]), textplot([.2, -1., z = -i], align = {above, left}), textplot([.2, 1., z = i], align = {above, left}), axis[1] = [tickmarks = []], axis[2] = [tickmarks = []], view = [-1.2*Rout .. 1.2*Rout, -1.2*Rout .. 1.2*Rout], scaling = constrained)

proc (col) options operator, arrow; cat(`#mo("►",mathcolor="`, col, `")`) end proc

 

proc (col) options operator, arrow; cat(`#mo("◄",mathcolor="`, col, `")`) end proc

 

proc (col) options operator, arrow; cat(`#mo("▲",mathcolor="`, col, `")`) end proc

 

proc (col) options operator, arrow; cat(`#mo("▼",mathcolor="`, col, `")`) end proc

 

proc (x, y) Typesetting:-mrow(Typesetting:-Typeset(x), Typesetting:-mo(), Typesetting:-mo("/", fontweight = "bold"), Typesetting:-mo(), Typesetting:-Typeset(y)) end proc

 

 
 

Download Plotting_contour_integrals.mw

@mmcdara  I played a bit with the code you gave me, and now I have the desired results. Thanks

@Rouben Rostamian  I thought about that, and sure, it's handy. However, I would like to know if I can do the same with Maple. I searched on Google for a tutorial, but I did not find anything.

@mmcdara, sorry for my English!! This is exactly what I was trying to do

1 2 3 4 5 6 Page 1 of 6