2

I am doing a MATLAB assignment and it includes the evaluation of a returned lambertw() function. However, since I am doing Monte Carlo here, I need to use a branch of the function which is not the default branch. For example, change the parameter from the returned default zero

lambertw(0, -7661844165657387/9007199254740992*exp(-1))

to minus one

lambertw(-1, -7661844165657387/9007199254740992*exp(-1)).

Is there a way to do this automatically?

p.s. this is a follow up to my previous question

Community
  • 1
  • 1
zw324
  • 26,764
  • 16
  • 85
  • 118

1 Answers1

1

If you have the result shown above stored in a symbolic variable s, one option you have is to use CHAR to convert the symbolic variable to a character string, use STRREP to replace the first argument to LAMBERTW, then use SYM to convert the character string back to a symbolic equation:

s = sym(strrep(char(s),'lambertw(0','lambertw(-1'));
gnovice
  • 125,304
  • 15
  • 256
  • 359