0

is there a way to use previous calculated values of solve?

solving equations based on asymptotic expansion

$x^2+x-\varepsilon=0$

$x=x_0+\varepsilon x_1 + \varepsilon^2 x_2 + \varepsilon^3 x_3$

Clear["Global`*"]
Collect[Expand[(x0 + e x1 + e^2 x2 + e^3 x3)^2 + (x0 + e x1 + e^2 x2 +
  e^3 x3) - e], e]

for some reason output isn't grouped in ascending/descending powers of e

x0 + x0^2 + e (-1 + x1 + 2 x0 x1) + e^2 (x1^2 + x2 + 2 x0 x2) + 2 e^5 x2 x3 + e^6 x3^2 + e^3 (2 x1 x2 + x3 + 2 x0 x3) + e^4 (x2^2 + 2 x1 x3)

but anyways, copying one by one

Solve[x0 + x0^2 == 0]
Solve[-1 + x1 + 2 x0 x1 == 0, x1]
Solve[x1^2 + x2 + 2 x0 x2 == 0, x2]
Solve[2 x1 x2 + x3 + 2 x0 x3 == 0, x3]

is there a way to solve successive lines of input using previously found?

2Napasa
  • 103
  • 3
  • 3
    Before such functionality was built-in with the Asymptotic* family of solvers, I wrote such a routine for differential equations here – Michael E2 Mar 22 '22 at 03:29
  • 2
    It seems you are to use ReplaceAll (/.) i.e. Solve[2 x1 x2 + x3 + 2 x0 x3 == 0, x3] /. Solve[x1^2 + x2 + 2 x0 x2 == 0, x2] /. Solve[-1 + x1 + 2 x0 x1 == 0, x1] /. Solve[x0 + x0^2 == 0, x0] – Artes Mar 22 '22 at 03:50
  • @Artes thank you! still need intermediate values, but this makes life a bit easier, any possibility to make it work for DSolve[{y1''[x] + y0^2[x] == 0, y1[0] == 0, y1'[0] == 0}, y1[x], x] /. DSolve[{y0''[x] == 0, y0[0] == 1, y0'[0] == 0}, y0[x], x] ? – 2Napasa Mar 22 '22 at 03:59

1 Answers1

2

They are simultaneous equations, so they can be solved at the same time, can't they?

x^2 + x - ϵ /. x -> x0 + ϵ x1 + ϵ^2 x2 + ϵ^3 x3
CoefficientList[%, ϵ]
Solve[Thread[% == 0][[;; 4]]]

x0 - ϵ + x1 ϵ + x2 ϵ^2 + x3 ϵ^3 + (x0 + x1 ϵ + x2 ϵ^2 + x3 ϵ^3)^2

{x0 + x0^2, -1 + x1 + 2 x0 x1, x1^2 + x2 + 2 x0 x2, 2 x1 x2 + x3 + 2 x0 x3, x2^2 + 2 x1 x3, 2 x2 x3, x3^2}

{{x0 -> -1, x1 -> -1, x2 -> 1, x3 -> -2}, {x0 -> 0, x1 -> 1, x2 -> -1, x3 -> 2}}

The last line above just agrees with the result obtained by AsymptoticSolve mentioned by @MichaelE2 in the comment:

AsymptoticSolve[x^2 + x - ϵ == 0, {x}, {ϵ, 0, 3}]

{{x -> -1 - ϵ + ϵ^2 - 2 ϵ^3}, {x -> ϵ - ϵ^2 + 2 ϵ^3}}