# I use the rule, but it cannot work, So I want to know why it can't? [closed]

I make a approximate solution of the differential equations. But when I use the rule for one, and it can work. But when using a list of rules, It cannot. I mean "(Sum[ep^k*Subscript[y, k], {k, 0, n - 1}] /. First@s1)[x]" cannot caculate.(The last line cannot work, the line before the last line can work) Could you help me please? Thanks a lot.

Clear["*"]
f := ((1 + #3)*#2^2 + 1) &
n = 3;
s = CoefficientList[Collect[D[Series[y[x, ep], {ep, 0, n}], x] -
Series[f[x, y[x, ep], ep], {ep, 0, n}], ep], ep] // Simplify;
s = s /. {
\!$$\*SuperscriptBox[\(y$$,
TagBox[
RowBox[{"(",
RowBox[{"j_", ",", "i_"}], ")"}],
Derivative],
MultilineFunction->None]\)[x, 0] :> D[Subscript[y, i][x], {x, j}],
y[x, 0] :> Subscript[y, 0][x]};
s1 = DSolve[{s[] == 0, s[] == 0, s[] == 0,
Subscript[y, 0] == 0, Subscript[y, 1] == 0,
Subscript[y, 2] == 0}, {Subscript[y, 0], Subscript[y, 1],
Subscript[y, 2]}, x];
a = (Subscript[y, 0] /. s1[[1, 1]])[x]

(Sum[ep^k*Subscript[y, k], {k, 0, n - 1}] /. First@s1)[x]


What you are doing is quite complicated (I wonder whether you wrote this or copied it from somewhere).

To make it work you only need a simple change - the last line could be written as

Sum[ep^k*Subscript[y, k][x], {k, 0, n - 1}] /. First[s1]
(* 1/4 ep Sec[x]^2 (2 x - Sin[2 x]) + Tan[x] +
1/8 ep^2 Sec[x]^2 (-6 x + 3 Sin[2 x] + 4 x^2 Tan[x]) *)


Your version added the functions (which Mathematica doesn't understand), and then tried to evaluate the sum at x. This evaluates the functions at x first, and then sums them.

• Excellent! Thank you very much. I write it to find the Asymptotic Solution of a differential equation. It cannot work when pure function added ? Sep 3 at 10:23

Suggest you change

(Sum[ep^k*Subscript[y, k], {k, 0, n - 1}] /. First@s1)[x]


To

(Sum[ep^k*Subscript[y, k][x], {k, 0, n - 1}] /. First@s1)
`

Each Subscript[y,*] is a function of x.

• We obviously looked at this at the same time! Sep 2 at 19:32
• And came to the same recommendation. All good.
– JV3
Sep 2 at 20:09
• So good! Thank you very much! Sep 3 at 10:24
{"ft_lang_label":"__label__en","ft_lang_prob":0.5524142,"math_prob":0.9916463,"size":1005,"snap":"2021-43-2021-49","text_gpt3_token_len":414,"char_repetition_ratio":0.16883117,"word_repetition_ratio":0.037037037,"special_character_ratio":0.47562188,"punctuation_ratio":0.2835249,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.999251,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-07T09:24:31Z\",\"WARC-Record-ID\":\"<urn:uuid:49201dc1-9705-411a-aba6-c7bf851afb07>\",\"Content-Length\":\"130680\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b0dd870e-c05d-4ecc-943a-6e061d05e1d4>\",\"WARC-Concurrent-To\":\"<urn:uuid:0dd86021-4848-4570-86aa-992ec4b8889b>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/255159/i-use-the-rule-but-it-cannot-work-so-i-want-to-know-why-it-cant\",\"WARC-Payload-Digest\":\"sha1:PMQVQ5JUFODHK7N2M2XEREHHVSOD2L3I\",\"WARC-Block-Digest\":\"sha1:WSBIAO5R6VQHFTETV4IGKHFURELSISI5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964363337.27_warc_CC-MAIN-20211207075308-20211207105308-00141.warc.gz\"}"}