Hot answers tagged

20

= can only be entered at the beginning of a cell and then interprets the entire cell content as a free-form WolframAlpha query. By contrast, CTRL-= can be used to create an inline WolframAlpha interpretation cell that appears in the middle of an otherwise normal expression. For example, we can start by typing ImageDimensions[ followed by CTRL-= to create ...


18

EDIT--- The code was updated to include anti-cheating filter to address important issues raised by @Jens in comments (thanks). More filters can be added to exclude other type of cheating. ---EDIT I was teaching physics and math for many years and consider this to be a very important question. I would say Mathematica is very well equipped for this type of ...


14

The keyboard shortcut for underscripts has now been changed to ctr-4 (ctr-$). So, to enter your Sum[expr, {n, 1, 10}], you should type escsumesc ctr-$n=1ctr-%10 ctr-spaceexpr Another option is to type the overscript ctr-& first and then use the ctr-% shortcut to move to the underscript position. Not all of the tutorials have been updated (and if you ...


14

In this context it might be useful to remark that if you enter escsumtesc you'll get a complete sum template with your cursor already at the bottom: I feel this is much easier than going through the other shortcuts. The same works for products: escprodtesc indefinite integrals: escinttesc and definite integrals: escdinttesc The 't'-s at the ...


11

As I mentioned in my comment to the question, I am quite fascinated by the idea of testing free-form input by numerical means similar to what the AcroTeX bundle has been able to do for a long time. This idea differs quite fundamentally from Vitaiy's suggestion, so I have tried to make it work in Mathematica. I will suspend discussion of the crucial ...


11

Here is a proof-of-concept of something that you can build upon to create such homework assignments. First, a helper function to check the correct answer and display the result. I'm only checking for accuracy to the third decimal, but you can tweak that as you wish. ClearAll[checkAnswer] checkAnswer[Null, _] := "" checkAnswer[ans_, correct_] := If[ Abs[...


11

Verbeia is right. An alternative notation is to use escpdesc which gives a partial derivative; thus, typing escpdesc ctrl-t followed by f[x,t] will give the derivative of f with respect to its second argument. For instance, this is a valid way to specify a differential equation: This is closer to what you're after than D[f[x,t],t], for instance.


11

Assuming Sjoerd's interpretation, I would use: f[x : 0 | 1] := 1 - x


9

Most likely you want to disable the "Enable natural language detection". This is in the same list in the preferences as the "Suggestion Bar" setting.


9

For a start, f[x,y]^(0,1) isn't the same as f^(0,1)[x,y]. But the real reason is that these expressions are very different in meaning, as revealed by their FullForm: D[f[x, y], y] // FullForm Derivative[0,1][f][x,y] versus (and I had to use a simple symbolic expression as the exponent to show what was going on: f[x,y]^z//FullForm Power[f[x,y],z] ...


7

As the combination Ctrl+% behaves as before (it toggles between Subscript and Superscript, between Underscript and Overscript), you can use it instead of any special short cuts for Underscript: Enter your Overscript first, and use Ctrl+% to enter Underscipts. Of course, this is more challenging a habit switch than the alternative (switch to the new short ...


7

What internally makes the superscript behave as a Derivative seems to be implemented with TagBox, this is what the output looks like: SuperscriptBox["f", TagBox[ RowBox[{"(", RowBox[{"0", ",", "1"}], ")"}], Derivative], MultilineFunction -> None] If you show this with DisplayForm you will get something that looks like a superscript but ...


7

I believe that Mathematica feeds the input string in free-form linguistic input to the function WolframAlpha. Try something like Manipulate[ If[in =!= "", WolframAlpha[in], "Enter input"], {{in, ""}, InputField[Dynamic[in], String] &} ] Response to comment I can't find a definitive statement in the documentation that an internet connection is ...


6

Your question is not very clear, but I guess something like this meets your requirements: notFun[x_?(#==0||#==1&)]:= 1-x or notFun[x_]:=1-x /; x==0||x==1


6

You can use a slightly different query: (convert 1 atm to pascals)/pascals The number in this case is a regular number (not a string or some other exotic construction.) If you instead use Wolfram|Alpha query (shortcut ==), you get a lot of results: with a + icon on the right of each. Clicking on the + gives a menu where you can choose a format: ...


5

I have a function called "AbleitungsForm" (Ableitung is german for Derivative) which is based on an answer I found here in SE. I coudn't find the original answer. It looks like this: AbleitungsForm::ON = "AbleitungsForm with Options \"AuchStandard\[Rule]`1`\" and \"MitArgumenten\[Rule]`2`\" is activ."; AbleitungsForm::OFF = "AbleitungsForm has been ...


5

NTDOY is the Nasdaq ticker for the Nintendo ADR. Once it's traded on an American stock exchange you don't need to define the stock exchange previously (i.e., you don't need to use PK: before the NTDOY ticker). So, the only thing you have to do is to use FinancialData["NTDOY"] and Mathematica will retrieve the current price: 11.79 EDITED You have ...


4

To add to WReach's answer, since = works on the entire cell, it can return formatted Wolfram|Alpha pods when there is no corresponding Wolfram Language syntax. It wouldn't make much sense to have a formatted W|A pod inline. Compare = vs CTRL-= Clicking on the gray question mark says exactly this:


4

Following Sjoerd┬┤s interpretation: f[x_ /; MemberQ[{0, 1}, x]] := x


4

There is another way to input derivatives for people who really like TraditionalForm. I like TraditionalForm output to look as much as possible like a $\LaTeX$ typeset formula, and that's why I came up with the format that Peter is using in his answer. For example, I want partial derivatives to look like this: $\frac{\partial^2 f}{\partial x\partial y}$ or ...


4

It turns out if you run an exteral process it gets stdin.. img=Import["!python readstdin.py","tiff"]; Print[Dimensions[ImageData[img]]]; where my python script is just this: import sys print sys.stdin.read() seems to work: math -script script.m < file.tiff (* {900,1200,3} *) Edit .. even better..: img=Import["!cat -","tiff"];


3

Edit: My interpretation of your question: From the clarification in your comment to the question: like for second derivative, fCtrl6Esc''Esc I assume you want the analogous entry method for the third derivative as you demonstrated for the second derivative. The difference to the other entry methods is that it uses the special character \[DoublePrime]...


3

Another way to skin this cat is to define your own test to verify what you consider binary. For example, if you mean a single binary digit you would use BinaryQ[x_] := If[x == 1 || x == 0, True, False] Or some other analogous expression. This form can lead to a cleaner implementation when you have more than one variable logicFun[x1_?BinaryQ, x2_?BinaryQ] ...


3

As I have mentioned in comment the problem is that (1/3)x^3 is not a proper function definition. Applying this to Your starting value will give You, as one can expect: (* => (1/3)x^3 [.8]*) Natural way is to use pure function form for it: (1/3)#^3&. Manipulate[ list2 = NestList[f, .8, 10], {f, (1/3) #^3 &, InputField[_]}, ControlType -> ...


1

Note This answer assumes the most optimistic version of this question is "no, you cannot refer to the last output in words" and instead assumes you're happy using the WolframAlpha function. Answer In my experience = and == should not be expected to give reproducible output over a reasonable time period. It's better since V10 with the introduction of ...


1

This doesn't seem to work on Mac You can check with $PreRead = Echo (or Print in case of V<10.3) that +1 returns RowBox[{+,1}] in FrontEnd and "+1" in Kernel. So the solution is to use: $PreRead = StringReplace[#, StartOfString ~~ op : "*" | "+" | "-" | "/" :> "%" <> op] &


1

My definition of $Pre does not work as intended.See also edits of this answer. I originally intended a solution similar to that in Kuba's answer. I got confused because $PreRead does not do anything for me in a kernel window, which also seems to be the case for the OP, but not for Kuba. The kernel does not deal with boxes. In the front end $PreRead is ...


1

I am not sure there is a simple solution to this. result = %; result //FullForm WolframAlphaResult["convert 1 atm to pascals", List[List["Result", 1], "Content"]] Copy As... and various other attempts to get at the result don't work. Interestingly, copying and pasting the result into somewhere other than Mathematica (e.g. an answer window ...



Only top voted, non community-wiki answers of a minimum length are eligible