New answers tagged

2 votes

Mathematica doesn't evaluate an expression

I think your expression E[t] inside Solve should be Exp[t]. Try this instead, where I ...
  • 63.1k
2 votes

How to Thread lists elementwise with the If function?

Using Thread: ...
  • 222k
5 votes

How to Thread lists elementwise with the If function?

Inner is more suitable for this task then Thread. ...
  • 41.7k
3 votes

How to Thread lists elementwise with the If function?

Just another way using MapApply: ...
12 votes
Accepted

How to Thread lists elementwise with the If function?

Thread doesn't hold its arguments unevaluated. In Thread[If[#1 > #2, 1, 0] &[list1, list2]] the "body", ...
  • 8,628
3 votes

'Update' and how to use variables to define patterns in functions' arguments...?

If I'm understanding the semantics, you want to define testF as: if the single argument matches the expression currently saved as $symbols, then return "It works!!!"; otherwise return "...
  • 8,628
3 votes

'Update' and how to use variables to define patterns in functions' arguments...?

Perhaps better answers will come, but I have found two on my own: The easy answer: One cannot use 'variable patterns' ($symbols) 'directly' within the LHS of ...
  • 1,335
1 vote

Replacement inside held expression

Trott-Strzebonski is great, but there is a case when some additional trick is required. At least I couldn't figure this out any other way... Consider this slightly silly example. You have some ...
  • 7,285
3 votes
Accepted

Replacing symbolic variables inside of a compile

It's not really an error, only a warning message, if w is atomic. It's not an error in the sense that w[[1]] is the result of <...
  • 222k
2 votes

Replacing symbolic variables inside of a compile

This would fix the issue (it might not be the cleanest solution though) ...
4 votes

Preventing evaluation of $Exp[\pm i\pi]$ until the end of a calculation

Something like this? ClearAll[f] SetAttributes[f, HoldFirst] f := Hold[Exp[I Pi]] And once you want you can do f // ReleaseHold ...
  • 6,579
2 votes

Can every usage of While be changed into NestWhile?

One approach to change While to NestWhile is to incorporate variable increments, such as i++, as part the repeated function application. The idea of incorporating increments is similar to what Simon ...
  • 1,286

Top 50 recent answers are included