Message Boards Message Boards

0
|
250 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Help debugging code to get computational components

Posted 12 days ago
(*Define variables and functions*)ClearAll[t, x, alpha, s, f]
t = Symbol["t", Positive -> True];
x = Symbol["x", Positive -> True];
alpha = Symbol["alpha", Positive -> True];
s = Symbol["s", Positive -> True];
n = Symbol["n", Integers -> True];
f[n_, x_, t_] := f[n][x, t];

(*Define Elzaki Transform*)
elzakiTransform[func_, var_, transformVar_] := 
 Integrate[
  transformVar*func*Exp[-var/transformVar], {var, 0, Infinity}]

(*Define Inverse Elzaki Transform*)
inverseElzakiTransform[transformFunc_, transformVar_] := 
 InverseLaplaceTransform[transformFunc, transformVar, t]

(*Define the functional correction method*)
correctionFunctional[fPrev_, x_, t_, alpha_] := 
 Module[{delayTerm, rhs, transformedRHS, correctedTransform, 
   correctedFunction},(*Define the delay term*)
  delayTerm = fPrev /. t -> t - 1;

  (*Define the RHS of the equation*)rhs = x^2*t - delayTerm;

  (*Apply Elzaki Transform to RHS*)
  transformedRHS = elzakiTransform[rhs, t, s];

 (*Multiply by s^alpha for fractional derivative correction*)

  correctedTransform = s^alpha*transformedRHS;
  (*Apply inverse Elzaki transform to get back to time domain*)

  correctedFunction = inverseElzakiTransform[correctedTransform, s];
  (*Add the initial condition x^2*)correctedFunction]

(*Example:Initialize f_0(x,t)*)
f0 = x^2;

(*Compute iterations*)
iterations = 3;
fPrevious = f0;

For[i = 1, i <= iterations, i++, 
 fCurrent = correctionFunctional[fPrevious, x, t, alpha];
 Print["Iteration ", i, ":"];
 Print[TraditionalForm[fCurrent]];
 fPrevious = fCurrent;]
2 Replies
Posted 12 days ago

It would help if you explicitly described the issue you're having. Are you getting an error message? What error message? Do you get no output? Does the code run forever?

POSTED BY: Drjbaldwin

Sure, the code runs forever, but it gives symbolic components that are not in proper form. Just want to know why this inverse function does not work properly, although I do a dry run of this code step by step. The components are below:

Iteration 1:

x (- InverseLaplaceTransform(s^ α + 2 , s, t, None) + InverseLaplaceTransform(s^ α + 3 , s, t, None))

Iteration 2:

x (- InverseLaplaceTransform(s^ α + 2 , s, t, None) + InverseLaplaceTransform(s^ α + 3 , s, t, None))

Iteration 3:

x (- InverseLaplaceTransform(s^ α + 2 , s, t, None) + InverseLaplaceTransform(s^ α + 3 , s, t, None))

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract