1
$\begingroup$

I am trying to do

pad[t_] := PadeApproximant[t Log[t], {t, 1, {2, 1}}] 
pad[t] // Simplify //Factor
pad[1]
Plot[pad[t], {t, 0, 1}]

The last two lines do not work. Why? How to fix them?

$\endgroup$
3
  • 2
    $\begingroup$ Try = instead of := or use Evaluate in pad[t_] := Evaluate[PadeApproximant[..]]. $\endgroup$ – Michael E2 Mar 19 at 1:50
  • 1
    $\begingroup$ If you're wondering why that suggestion of @MichaelE2 works, it's because := does not evaluate its right hand side before substituting. So it substitutes 1 verbatim into PadeApproximant[t Log[t], {t, 1, {2, 1}}] , to get PadeApproximant[1 Log[1], {1, 1, {2, 1}}], which doesn't make any sense to Mathematica. By using =, you evaluate the rhs first, and then 1 gets substituted into the output of PadeApproximant[t Log[t], {t, 1, {2, 1}}]. $\endgroup$ – thorimur Mar 19 at 4:07
  • $\begingroup$ @thorimur: I did. Thank you for the explanation. $\endgroup$ – Hans Mar 19 at 6:25
2
$\begingroup$

Conversion of comments to a community wiki answer:

Michael E2:

Try = instead of := or use Evaluate in pad[t_] := Evaluate[PadeApproximant[..]].

thorimur:

If you're wondering why that suggestion of @MichaelE2 works, it's because := does not evaluate its right hand side before substituting. So pad[1] substitutes 1 verbatim into PadeApproximant[t Log[t], {t, 1, {2, 1}}], to get PadeApproximant[1 Log[1], {1, 1, {2, 1}}], which doesn't make any sense to Mathematica. By using =, you evaluate the rhs first, and then 1 gets substituted into the output of PadeApproximant[t Log[t], {t, 1, {2, 1}}].

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.