masterxilo
  • Member for 8 years, 9 months
  • Last seen more than a week ago
Testing that an algorithm has converged
Accepted answer
4 votes

I think all of these algorithms can be described in the following form: Assume your iterative numerical algorithm f takes and returns a pair {x, additionalState}. x is the quantity (tensor) that ...

View answer
Print[] to console in Mathematica 11
3 votes

Run SetOptions[$FrontEnd, PrintAction -> "PrintToConsole"] The setting will persist across restarts of Mathematica.

View answer
Running external pdflatex command and importing the generated PDF document
3 votes

It would be helpful if Mathematica could at least say that the error lies in the pdf version mismatch. Thanks @Jens. Here is another way to fix a pdf generated from pdflatex to be Importable in ...

View answer
How to draw an infinitely long line that automatically scales with the plot?
3 votes

This can now be done with an InfiniteLine in Epilog or Prolog since version 10: Manipulate[ Plot[10^f*x^3, {x, -E/2, 1}, PlotRangePadding -> 0, Epilog -> InfiniteLine[{0.5, 0}, {0, 1}]], {{...

View answer
Learn Mathematica (Wolfram) Language in one day
Accepted answer
16 votes

For learning what I consider "just the wolfram/mathematica language" I would proceed as follows and start at the very low-level basics: Learn what is meant by a symbolic expression: ...

View answer
SymbolicC`: Is there a CChar, i.e. a way to generate a single character constant?
2 votes

You could do CArray[CString@"a", 0] // ToCCodeString giving "a"[0] maybe wrap it in CParentheses. Alternatively, just put it there verbatim (losing the type information): CAssign[a, "'a'"] // ...

View answer
How to make a Spherical Cow?
1 votes

You can do this using the discrete laplacian computed on the mesh by transforming along the thusly computed mean curvature flow. This operation is often called called smoothing in Geometry Processing. ...

View answer
Calling MATLAB from Mathematica
1 votes

For what it's worth, there also seems to be a way to integrate Mathematica into matlab (the other way around) using the "Mathematica Symbolic Toolbox for MATLAB--Version 2.0" http://ch.mathworks.com/...

View answer
Why is Graph an atomic expression in Mathematica?
10 votes

Graph being AtomQ has about the same implications as doing lots of overloadings of the type Part[_Graph,___] := Error[]; Replace[_Graph,___] := Error[]; .... It signifies that it is an "abstract data ...

View answer
Why does `Times` evaluate within `Hold` when doing replacement?
3 votes

This is purely a formatting "issue":

View answer
why does Function have the HoldAll attribute?
1 votes

Inspired by Szabolcs answer and the discussion in the comments, here's another solution: EvaluateOwnValuesOnlyAndHold~SetAttributes~HoldAll EvaluateOwnValuesOnlyAndHold[expr_] := Hold[expr] /. ...

View answer
Possible bug with `KeyValuePattern` and `Optional`
Accepted answer
2 votes

This was fixed in 11.0.0. The output is all 0 now as expected.

View answer
Version inconsistency with optional arguments: what if the default value doesn't match the pattern?
2 votes

In my opinion, Optional should just consistently not match when the default value does not match the pattern, period. Now we have nonsense like this: {}~MatchQ~{Optional[0., 0]} False You might ...

View answer
How to specify optional arguments that take functional values
1 votes

HeldOptional = Function[, HoldPattern@Optional[#1, #2], HoldRest] Remove[CurrentTime] CurrentTime[time_~HeldOptional~DateList[]] := {time, DateList[]}; Pause[1] CurrentTime[] c.f. How to write a `...

View answer
Fast `Shallow` for Associations?
1 votes

This formats Associations in the usual way: ShallowAssociation[x_Association] := RawBoxes@(({s = Shallow@Normal@x}~With~MakeBoxes@s)~ Replace~(RowBox[{"{", val_, "}"}] :> RowBox@{"\...

View answer
Fast `Shallow` for Associations?
1 votes

$r = Association["x" -> ConstantArray[0, {1000, 1000}]]; Shallow@($r /. Association -> Normal@*Association) performs well.

View answer
How to stop `Format` from evaluating when doing `Put`/`Export`?
0 votes

Export["file.m", FullForm@HoldComplete[Format[$hello, StandardForm]], "String"] works, but all operators will be eliminated because of FullForm: FullForm@HoldComplete[Format[$hello, StandardForm]*2] ...

View answer
Is it important that the front-end has a built-in parser?
10 votes

The result of the front-end's parsing is definitely used, but it does not need to be complete, it seems. This can be seen by constructing Cells/Boxes manually. Try RawBoxes@RowBox[{"1", "+", RowBox[{...

View answer
How to get the height of a triangle from three points
4 votes

Let's ask FormulaData. These should suffice (there are not that many anyways :( ): Flatten@{FormulaData["TriangleAreaSSS"], FormulaData["TriangleAreaBH"]} // TeXForm (I started looking for something ...

View answer
Mathematica is taking too much time in solving my problem
Accepted answer
1 votes

This numerical approach seems to work: Norm2[x_] := x.x; ConvertEquationsToLeastSquares[eqns : {__Equal}] := Norm2@Flatten[eqns //. { Equal[x_, y_, rest___] -> {Subtract[x, y], Equal[y, ...

View answer
How to write a `HeldOptional` variant of `Optional` that does not evaluate its second argument?
1 votes

This works: ClearAll[DontEvaluateInOptional]; DontEvaluateInOptional~SetAttributes~HoldAllComplete; DontEvaluateInOptional /: (h: Except[Optional])[l___, HoldPattern@DontEvaluateInOptional[b___], ...

View answer
Why does `Block` reset `Attributes`?
0 votes

This is not an answer as to why, wolfram-language-design wise, but to how: It seems Block[{x = new}, ...code...] effectively does the following: newValue = new; allValues = ...

View answer
VerificationTest for uncaught `Throw`?
0 votes

A VerificationTest with Outcome Error cannot be fixed by changing the expected-messages argument. This only applies to MessagesFailure Outcome (orange versus yellow cross, a bit hard to distinguish). ...

View answer
How to change styling of HoldForm expressions?
3 votes

I'm using this now: Unprotect@HoldForm; Format[HoldForm[x_], StandardForm] := {boxes = MakeBoxes@x, bg = LightBlue}~With~ RawBoxes@ InterpretationBox[ TagBox[StyleBox[boxes, ...

View answer
Improving `$AssertFunction` to always tell what the assertion test resulted in
3 votes

Defining $AssertFunction might be a place to get started, but it is not ideal since when it gets called, the evaluation will have already happened. You will change the program behaviour if you ...

View answer
Disable "The option to save automatically after each result is enabled" warning
Accepted answer
4 votes

Go to Edit > Preferences > Messages and set Minor user interface warnings: to Ignore.

View answer
Is there any PythonForm ? to automate Sin[] to math.sin()?
Accepted answer
6 votes

If I where to do this manually, I would start with PythonForm~SetAttributes~HoldAll (*known symbols*) PythonForm[Sin[x_]] := StringTemplate["math.sin(``)"]@PythonForm@x PythonForm[Times[a_, b_]] := ...

View answer
How can I make Mathematica do, ArcTanh[x] + ArcTanh[y] = ArcTanh[x+y/1+xy]?
6 votes

Probably, MathematicalFunctionData["ArcTanh"] knows about this. First let's see what categories of things are known: MathematicalFunctionData["ArcTanh", "Properties"] ah well, let's just list them ...

View answer
How to use "managed library expressions" to free the memory?
3 votes

For returning multiple values, you'll find it much easier to return them via a WSTP/Mathlink link object. Start from this: #include <mathlink.h> #pragma comment(lib, "ml64i4m") // only 4 seems ...

View answer
Why doesn't Mathematica abort evaluation when I tell it to?
6 votes

If you ever develop a library for LibraryLink, be sure to include calls to AbortQ to support aborting lengthy computations. Code that runs for a long time should call AbortQ to see if the user has ...

View answer