1

I have an expression:

KK = -(2*b *(c + 6) *(b + a) *d /(b + d) *(c + d))

a, b, c, d - are variables,

a[i_]:=i^2; b[i_]:=i; c[i_]:=i-2; d[i_]:=i^3; - are functions.

I would like to change the variables to the functions in this way:

a -> a[i_], b -> b[i_], c -> c[i_], d -> d[i_].

How can this be done?

Rohit Namjoshi
  • 10,212
  • 6
  • 16
  • 67
Mam Mam
  • 1,843
  • 2
  • 9

1 Answers1

3
Clear["Global`*"]

KK = -(2*b*(c + 6)*(b + a)*d/(b + d)*(c + d));

KK2 = KK /. (# :> #[i] & /@ Variables[Level[KK, {-1}]])

(* -((2 b[i] (a[i] + b[i]) (6 + c[i]) d[i] (c[i] + d[i]))/(b[i] + d[i])) *)
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198