Skip to main content
added 801 characters in body
Source Link
Sjoerd Smit
  • 24.8k
  • 48
  • 80

I'm not exactly sure what's causing the problem, but you generally want to avoid re-defining functions inside of dynamics like these. Every time the manipulate re-calculates the result, it redefines g and this seems to cause some sort of infinite update loop. It's better to do this:

Manipulate[
 Solve[g[x] == g[m x], x],
 {{m, 2, "Times"}, -10, 10, 0.1},
 Initialization :> (
   g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}]
   )
 ]

edit

It seems like the problem persists for the OP, so here's 2 more suggestions. First of all, try using the TrackedSymbols option:

Manipulate[
 Solve[g[x] == g[m x], x],
 {{m, 2, "Times"}, -10, 10, 0.1}, 
 Initialization :> (g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}]),
 TrackedSymbols :> {m}
]

Failing that, another good trick it to encapsulate the output in Dynamic with a TrackedSymbols option:

Manipulate[
 Dynamic[
  Solve[g[x] == g[m x], x],
  TrackedSymbols :> {m}
 ],
 {{m, 2, "Times"}, -10, 10, 0.1}, 
 Initialization :> (g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}])
]

If that doesn't work, I suspect there might be a hardware issue or a problem with your Mathematica installation.

I'm not exactly sure what's causing the problem, but you generally want to avoid re-defining functions inside of dynamics like these. Every time the manipulate re-calculates the result, it redefines g and this seems to cause some sort of infinite update loop. It's better to do this:

Manipulate[
 Solve[g[x] == g[m x], x],
 {{m, 2, "Times"}, -10, 10, 0.1},
 Initialization :> (
   g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}]
   )
 ]

I'm not exactly sure what's causing the problem, but you generally want to avoid re-defining functions inside of dynamics like these. Every time the manipulate re-calculates the result, it redefines g and this seems to cause some sort of infinite update loop. It's better to do this:

Manipulate[
 Solve[g[x] == g[m x], x],
 {{m, 2, "Times"}, -10, 10, 0.1},
 Initialization :> (
   g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}]
   )
 ]

edit

It seems like the problem persists for the OP, so here's 2 more suggestions. First of all, try using the TrackedSymbols option:

Manipulate[
 Solve[g[x] == g[m x], x],
 {{m, 2, "Times"}, -10, 10, 0.1}, 
 Initialization :> (g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}]),
 TrackedSymbols :> {m}
]

Failing that, another good trick it to encapsulate the output in Dynamic with a TrackedSymbols option:

Manipulate[
 Dynamic[
  Solve[g[x] == g[m x], x],
  TrackedSymbols :> {m}
 ],
 {{m, 2, "Times"}, -10, 10, 0.1}, 
 Initialization :> (g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}])
]

If that doesn't work, I suspect there might be a hardware issue or a problem with your Mathematica installation.

Source Link
Sjoerd Smit
  • 24.8k
  • 48
  • 80

I'm not exactly sure what's causing the problem, but you generally want to avoid re-defining functions inside of dynamics like these. Every time the manipulate re-calculates the result, it redefines g and this seems to cause some sort of infinite update loop. It's better to do this:

Manipulate[
 Solve[g[x] == g[m x], x],
 {{m, 2, "Times"}, -10, 10, 0.1},
 Initialization :> (
   g[x_] := Piecewise[{{2 - x, 1 <= x}, {x, x < 1}}]
   )
 ]