Linked Questions

30 votes
5 answers
776 views

Unexpected behaviors in built-in functions

Existence of this topic is discussed in this mathematica.meta post. I'm sure I am not the only non-beginner in WL who from time to time finds themselves not being able to predict an outcome of a ...
17 votes
2 answers
2k views

Difference between Piecewise, Which and If?

I have the impression that these functions have different evaluation rules. I cannot produce a minimal example right now, but in general, what are the differences between these functions? That is, ...
a06e's user avatar
  • 11.4k
8 votes
4 answers
1k views

Setting Up Boundary Conditions for Magnetostatic PDE

Bug introduced in 11.2.0 and fixed in 11.3.0 The system is a hollow cylinder (thin solenoid) with a current density $\text{J}$ and I'm looking to solve the magnetic potential ($\text{A}$) inside the ...
Young's user avatar
  • 7,495
5 votes
2 answers
3k views

A discontinuity in a plot of a continuous function

I plot a continuous, though not a smooth function: Plot[If[a >= 0.5, 0, Sqrt[0.5 - a]], {a, -1, 1}, PlotRange -> All] which returns the following One can ...
Alexei Boulbitch's user avatar
3 votes
1 answer
2k views

How to properly use conditionals inside NDSolve

Currently I am working with Mathematica to learn the program, and I'm confused what exactly is wrong with this code. ...
Joseph Kessler's user avatar
8 votes
1 answer
1k views

When are `If`, `Piecewise`, `Switch`, and `Which` interchangeable and when are they not?

Experimenting with joint dependent distributions via the TransformedDistribution function, I used the following to derive a distribution where the second variate is ...
ciao's user avatar
  • 25.8k
1 vote
1 answer
495 views

Summand is not numerical at some point

I am trying to do some numerical integration with the following codes: ...
Y. Zhang's user avatar
2 votes
1 answer
465 views

NMaximize and Conditional Loop

I have developed the following code that simulates a process that decays over time and then returns to its initial state periodically. When I pass a list of random integers in the interval $(1,0)$ as ...
dixontw's user avatar
  • 441
0 votes
1 answer
224 views

How to compute DSolve or NDSolve for kind of piece wise function?

I need to Compute the expression for two functions. q[t] and q1[t] over certain range of time. The code is given below. ...
AK K Khan's user avatar
3 votes
1 answer
131 views

Mod[k, 2] == 0 versus EvenQ[k] [duplicate]

I'm having some trouble with Mod[k, 2] == 0 versus EvenQ[k] They are sometimes yielding different results when given the ...
Gerald's user avatar
  • 309