Linked Questions

96
votes
4answers
5k views

Replacement inside held expression

I wish to make a replacement inside a held expression: f[x_Real] := x^2; Hold[{2., 3.}] /. n_Real :> f[n] The desired output is ...
29
votes
3answers
3k views

1D Euler equations (fluid dynamics) with NDSolve

Is it possible to accurately solve the 1D Euler equations in Mathematica using NDSolve? For example, let us consider the Sod shock tube problem. Introduction to ...
20
votes
2answers
853 views

When should I, and when should I not, set the HoldAll attribute on a function I define?

I have seen a number of examples on this site (such as in syntax highlighting and checking evaluation status) in which functions definitions are preceded with ...
22
votes
2answers
895 views

NDSolve uses different difference order for different spatial derivative when solving PDE

I found something this tutorial for method of line doesn't tell us. Consider the following toy example: ...
33
votes
2answers
780 views

Why is CompilationTarget -> C slower than directly writing with C?

Probably a hard question, but I think it's better to cry out loud. I've hesitated for a while about whether I should post this in StackOverflow with a c tag or not, ...
16
votes
2answers
693 views

Conservation of area solving a PDE via finite difference scheme

I have two PDEs that describe the movement of fluid: $h_t + [h^3(1-h)^3((1+\varepsilon h)\sin \theta - \varepsilon h_\theta \cos \theta]_\theta$ = 0 $h_t - [h^3(1-h)^3 \varepsilon h_\theta]_\theta$ = ...
11
votes
2answers
422 views

Nonlinear dispersal equation modeling insect aggregation

I'm a newbie with Mathematica, I know it's a basic answer, but I can't solve the problem on my own. I have the following equation reflecting insect aggregation at low population densities (taken from ...
11
votes
1answer
816 views

Modelling the effect of a structure on a “tsunami” (hyperbolic wave equation)

So, the hyperbolic wave equation can be quite easily solved in Mathematica like this: ...
5
votes
3answers
280 views

Problems with solving PDEs

I am using NDSolve to solve the two equations: ...
7
votes
1answer
276 views

Instability, Courant Condition and Robustness about solving 2D+1 PDE

After several discussions, I would like to focus on the robustness of solving 2D+1 PDE by considering all suggested methods from @xzczd (see here) I found that the Ratio between the convection term ...
4
votes
1answer
339 views

Laplace equation in a gapped rectangular domain with finite difference method

I have a situation that is shown by this picture: For this situation I have this code. ...
2
votes
1answer
218 views

How to make the code inside Compile conciser without hurting performance?

Consider the following sample: ...
0
votes
1answer
205 views

How to exchange interpolating function results of NDSolve between different platforms?

For example, I have a interpolating function solution by NDSolve in a windows x64 platform and want to share the result to users in other windows x86. I tried the DumpSave and ".mx" binary format, ...
2
votes
1answer
53 views

Indexed variables in compile

In this contribution Leonid Shifrin says that You can not really use indexed variables in Compile, although it may appear that you can. This sounds ambiguous to me. Is it possible or is it not ...
0
votes
0answers
73 views

Wave scattering visualisation

I've been looking around on the web for some mathematica visualisation of a wave scattering with an interface or layer. I can't seem to find any nice 2-d or 3-d examples. Could anyone point me in the ...