instruction
stringlengths
34
28.4k
completion
stringlengths
10
43.3k
conversations
listlengths
2
2
Is there some way to do this other than going to Evaluation -> Quit kernel and firing a new one up?
Yes, if you're using a Jupyter Notebook and want to restart the kernel without going through the Evaluation -> Quit Kernel menu, you have a couple of alternatives: 1. **Keyboard Shortcut**: You can use the keyboard shortcut `0, 0` (press the zero key twice in quick succession) to restart the kernel. 2. **Kernel Menu*...
[ { "from": "human", "value": "Is there some way to do this other than going to Evaluation -> Quit kernel and firing a new one up?\n" }, { "from": "gpt", "value": "Yes, if you're using a Jupyter Notebook and want to restart the kernel without going through the Evaluation -> Quit Kernel menu, you h...
I'm aware that I can use (* ... *) to comment out stuff in a notebook. Many languages have a syntax for single-line comments, such as // in C, C++, Java, C#, ... # in shell, Python, ... For example, in C++ you can write int x = 5; // std::cout << "debug: x = " << x << std::endl; return x; in which the second line is...
Yes, in Mathematica (also known as Wolfram Language), you can quickly comment out a single line of code using the `(* ... *)` comment syntax by simply selecting the line you want to comment out and then using a keyboard shortcut. To comment out a single line, follow these steps: 1. Select the line of code you want to...
[ { "from": "human", "value": "I'm aware that I can use (* ... *) to comment out stuff in a notebook. Many languages have a syntax for single-line comments, such as\n\n// in C, C++, Java, C#, ...\n# in shell, Python, ...\n\nFor example, in C++ you can write\nint x = 5;\n// std::cout << \"debug: x = \" << x <<...
I've started using AbsoluteTiming to discriminate between similar function constructs, but I sometimes feel like it takes substantially more time to evaluate a function using AbsoluteTiming than without. Is this behaviour normal? (This may qualify as a second question) Is there a way to know how much time the last eval...
Yes, it is normal for `AbsoluteTiming` to take longer than simply evaluating a function without timing it. The reason for this is that `AbsoluteTiming` itself introduces some overhead to measure the execution time. This includes the setup and management of timing mechanics, which can contribute to a small but noticeabl...
[ { "from": "human", "value": "I've started using AbsoluteTiming to discriminate between similar function constructs, but I sometimes feel like it takes substantially more time to evaluate a function using AbsoluteTiming than without.\nIs this behaviour normal?\n(This may qualify as a second question) Is ther...
I'm new to functional programming of Mathematica and trying to remove one list of assorted elements from another. However I only find functions working with the Index rather than the values itself: list1={b,a,e,f,c,d} list2={f,e,c} I can now remove list2 from list1: result={b,a,d} I already found out, that...
In Mathematica, you can easily remove the elements of one list from another using the `Complement` function. This function returns the elements in the first list that are not present in the second list. Given your lists: ```mathematica list1 = {b, a, e, f, c, d}; list2 = {f, e, c}; ``` You can remove the elements in...
[ { "from": "human", "value": "I'm new to functional programming of Mathematica and trying to remove one list of assorted elements from another. However I only find functions working with the Index rather than the values itself: \n list1={b,a,e,f,c,d} \n list2={f,e,c}\n\nI can now remove list2 from list1: ...
What is the character obtained with they key sequence Esc,Esc called? On my front end it is not displayed, but there's something there messing up my input. It's a bit annoying when I'm after a $\mu$ but hit the wrong key.
The character obtained by the key sequence Esc, Esc is known as the "escape sequence." In many systems, pressing the Esc key twice might send an "escape" character that can disrupt input or trigger unintended behavior, especially in text editors or terminal environments. In certain contexts, this could also generate a...
[ { "from": "human", "value": "What is the character obtained with they key sequence Esc,Esc called? On my front end it is not displayed, but there's something there messing up my input. It's a bit annoying when I'm after a $\\mu$ but hit the wrong key.\n" }, { "from": "gpt", "value": "The chara...
Just wondering if anyone knows the proper Syntax to change the Text properties in the BarChart's ChartLegend. I cannot seem to figure out how to get Style[] to apply. Here is an example: BarChart[{1, 2, 3}, ChartStyle -> "Pastel", ChartLegends -> Placed[{"John", "Mary", "Bob"}, Bottom]] BarChart[{1, 2, 3}, ChartStyl...
In Mathematica, when you want to apply styles to the legends of a `BarChart`, you can use the `Style` function directly on each individual legend entry rather than wrapping the whole list of legends in `Style`. Here’s how you can apply different styles to each legend entry in your `BarChart`: ```mathematica BarChart...
[ { "from": "human", "value": "Just wondering if anyone knows the proper Syntax to change the Text properties in the BarChart's ChartLegend. I cannot seem to figure out how to get Style[] to apply. Here is an example:\nBarChart[{1, 2, 3}, ChartStyle -> \"Pastel\", \n ChartLegends -> Placed[{\"John\", \"Mary\"...
If I do ClearAll[a, d] lsts = {{a, d}, {a, d}}; Union[lsts] I get the expected answer {{a, d}} but if I do lsts = {{a, d}, {d, a}}; Union[lsts] I get {{a, d}, {d, a}} Since I am using Union, I thought the order of the lists would not matter. Hence to get around this, now I always add Sort first, like this lsts = {{...
Your approach using `Sort` is indeed a common way to handle this situation, especially when you want to treat lists as sets where the order of elements within the lists does not matter. By sorting each inner list first, you ensure that lists like `{a, d}` and `{d, a}` will be treated as identical. Your usage of `Sort ...
[ { "from": "human", "value": "If I do\nClearAll[a, d]\nlsts = {{a, d}, {a, d}};\nUnion[lsts]\n\nI get the expected answer\n{{a, d}}\n\nbut if I do\nlsts = {{a, d}, {d, a}};\nUnion[lsts]\n\nI get\n{{a, d}, {d, a}}\n\nSince I am using Union, I thought the order of the lists would not matter. Hence to get aroun...
Whenever a Link is created using LinkCreate or LinkLaunch with LinkProtocol -> "TCPIP", Mathematica opens up two ports for communicating with the attached process. Can these be specified by the user of these functions? I ask because it would allow me to route all communication over ssh via port-forwarding.
In Mathematica, when you create a link using `LinkCreate` or `LinkLaunch` with the `LinkProtocol` set to `"TCPIP"`, Mathematica indeed opens up two ports for communication. However, as of my last knowledge update in October 2023, Mathematica does not provide a built-in way to specify the specific ports used for these l...
[ { "from": "human", "value": "Whenever a Link is created using LinkCreate or LinkLaunch with LinkProtocol -> \"TCPIP\", Mathematica opens up two ports for communicating with the attached process. Can these be specified by the user of these functions? \nI ask because it would allow me to route all communicati...
Consider the following: lists = Import["G:/Notebooks/Lists.csv"]; col7 = lists [[All, 7]]; For[i=0,i<101,i++,Print[Count[col7,i]]] This will get a 100 cells printed out but what I really want to do is capture this output to another variable as a list. So far the best way I have figured out is to copy the output, edi...
Yes, there's definitely a more efficient way to capture the output to a variable in Mathematica. You can use the `Table` function to create a list that contains the counts for each value from 0 to 100, instead of printing the counts directly to the console. Here’s how you can do it: ```mathematica lists = Import["G:/N...
[ { "from": "human", "value": "Consider the following:\nlists = Import[\"G:/Notebooks/Lists.csv\"];\n\ncol7 = lists [[All, 7]];\n\nFor[i=0,i<101,i++,Print[Count[col7,i]]]\n\nThis will get a 100 cells printed out but what I really want to do is capture this output to another variable as a list. So far the best...
The best way I can come up with to say "show me this fraction as a decimal number to M places, don't use scientific notation" is: NumberForm[N[1/998001,2994],ExponentFunction->(Null&)] It seems like that's an awful lot of typing for a very simple request. Is it possible to say it more concisely?
Yes, you can definitely simplify your request to display a fraction as a decimal number without using scientific notation in a more concise way. Instead of using `NumberForm` with an `ExponentFunction`, you can use the `SetPrecision` function combined with `N` directly. Here's a more concise way to achieve your goal: ...
[ { "from": "human", "value": "The best way I can come up with to say \"show me this fraction as a decimal number to M places, don't use scientific notation\" is:\nNumberForm[N[1/998001,2994],ExponentFunction->(Null&)]\n\nIt seems like that's an awful lot of typing for a very simple request.\nIs it possible t...
Suppose I have a string containing the C-representation of a floating point number; for example s = "1.23e-5" and I want to convert this to a Mathematica number. How can I do this? ToExpression[s] gives Plus[-5, Times[1.23`, e]].
In Mathematica, the `ToExpression` function does not directly interpret C-style floating point representations like `"1.23e-5"` correctly because the format involves `e` for exponentiation, which is treated differently in Mathematica. To convert a C-representation string to a Mathematica number, you can replace the `e...
[ { "from": "human", "value": "Suppose I have a string containing the C-representation of a floating point number; for example\ns = \"1.23e-5\"\n\nand I want to convert this to a Mathematica number. How can I do this?\nToExpression[s] gives Plus[-5, Times[1.23`, e]]. \n" }, { "from": "gpt", "val...
I have a ragged list ragged = {{a,b,c,d,e},{x,y,z}} that I would like to trim (on the right) to be rectangular. The desired result is {{a,b,c},{x,y,z}} It seems like this should be a one-word operation but I can't find the one word. So far the best I can do is to PadRight with Null and then delete everything with a N...
In Mathematica, you can achieve your goal of trimming a ragged list to make it rectangular by using the `Length` function to find the length of the shortest sublist and then applying `Take` to each sublist accordingly. Here's a more straightforward one-liner solution: ```mathematica ragged = {{a, b, c, d, e}, {x, y,...
[ { "from": "human", "value": "I have a ragged list\nragged = {{a,b,c,d,e},{x,y,z}}\n\nthat I would like to trim (on the right) to be rectangular. The desired result is\n{{a,b,c},{x,y,z}}\n\nIt seems like this should be a one-word operation but I can't find the one word. So far the best I can do is to PadRigh...
My minimal example Panel[Column[{ Row[{"Board size: ", InputField[Dynamic[max], Number, FieldSize -> 3], Button["Clear Board"]}], "A graphic object which is large enough"}]] evaluates to Since I have a large graphic object underneath the first row, there is some space to the right of the "Clear Board" button...
To achieve the effect you're looking for, where the "Clear Board" button aligns flush with the right boundary of the panel, you can use `Spacer` to create flexible space to push the button to the right. Here's how you can modify your example: ```mathematica Panel[ Column[{ Row[{"Board size: ", InputField[Dynamic...
[ { "from": "human", "value": "My minimal example\nPanel[Column[{\n Row[{\"Board size: \", InputField[Dynamic[max], Number, FieldSize -> 3],\n Button[\"Clear Board\"]}], \"A graphic object which is large enough\"}]]\n\nevaluates to\n\nSince I have a large graphic object underneath the first row, there ...
For example: How can I draw such kinds of coordinates? Thank you~
To help you draw coordinates, I need a bit more information about what you have in mind. Are you looking to draw a Cartesian coordinate system, polar coordinates, or something else? Additionally, would you like guidance on using graphing software, programming languages (like Python with Matplotlib), or by hand? Please ...
[ { "from": "human", "value": "For example:\n\nHow can I draw such kinds of coordinates?\nThank you~\n" }, { "from": "gpt", "value": "To help you draw coordinates, I need a bit more information about what you have in mind. Are you looking to draw a Cartesian coordinate system, polar coordinates, o...
Suppose I have a few symbols, one of which has a value: {abc1, abc2 = 5, abc3}; I can use Names to get the list of names, as strings: InputForm[names = Names["Global`abc*"]] (* {"abc1", "abc2", "abc3"} *) Now I want to find which symbols have values. This fails, because ValueQ expects the first argument to be a Symb...
You're right that using `ValueQ` with strings directly leads to complications due to the way it expects symbols rather than strings. The approach you've taken with `ToExpression` works, but it's not the cleanest solution. Here's a more elegant way to achieve the same result using `Select` along with `Symbol` and `Valu...
[ { "from": "human", "value": "Suppose I have a few symbols, one of which has a value:\n{abc1, abc2 = 5, abc3};\n\nI can use Names to get the list of names, as strings:\nInputForm[names = Names[\"Global`abc*\"]]\n(* {\"abc1\", \"abc2\", \"abc3\"} *)\n\nNow I want to find which symbols have values. This fails...
I would like to express a second derivative with two dots above the variable. You can do this with a first derivative by saying: f[x_] := OverDot[x]; Print[HoldForm[f[x]], " == ", f[x]] Is there a possible syntax to do this with the second derivative?
Yes, you can express a second derivative with two dots above a variable in a similar manner to how you did with the first derivative. In Mathematica, you can define a function for the second derivative with two dots above the variable using the `OverDot` function and combining it appropriately. Here's how you can do it...
[ { "from": "human", "value": "I would like to express a second derivative with two dots above the variable. You can do this with a first derivative by saying:\nf[x_] := OverDot[x];\nPrint[HoldForm[f[x]], \" == \", f[x]]\n\nIs there a possible syntax to do this with the second derivative?\n" }, { "fro...
If you have a simple list of lists as follows: test = {{1, 2}, {4, 5, 6, 7}, {5, 4, 3}} How do you ask Mathematica to return the sublist of greatest length? I've been trying to write a Select command using pure functions without success.
To find the sublist of greatest length in a list of lists in Mathematica, you can use a combination of the `Length`, `MaximalBy`, or `SortBy` functions. The `MaximalBy` function is particularly straightforward for this purpose. Here is how you can do it: ```mathematica test = {{1, 2}, {4, 5, 6, 7}, {5, 4, 3}}; longes...
[ { "from": "human", "value": "If you have a simple list of lists as follows:\ntest = {{1, 2}, {4, 5, 6, 7}, {5, 4, 3}}\n\nHow do you ask Mathematica to return the sublist of greatest length?\nI've been trying to write a Select command using pure functions without success.\n" }, { "from": "gpt", "...
At my graduate school, all of the clusters still use version-6, and I only have version-7 and version-8 installed on my computer. I would like to use those machines remotely. Are either of the versions I have compatible with the version-6 kernel?
In general, if you have version-7 and version-8 installed on your computer, it is important to note that they are typically not compatible with version-6 of the kernel. Each major version of software (like a programming language, library, or a specific tool) usually introduces new features and possibly breaking changes...
[ { "from": "human", "value": "At my graduate school, all of the clusters still use version-6, and I only have version-7 and version-8 installed on my computer. I would like to use those machines remotely. Are either of the versions I have compatible with the version-6 kernel?\n" }, { "from": "gpt", ...
In Mathematica version 7, there was a big advance in logic support ("Boolean computations" is the official name). This was not further developed in version 8.0. So now we have a fairly robust support for propositional calculus, but not too much for predicate calculus. To this end, it would help a lot if we had an inter...
As of my last knowledge update in October 2023, there isn't a widely known third-party Mathematica package specifically for transforming logical formulas into Prenex or Skolem normal forms. However, there are a few options you might consider: 1. **Custom Implementation**: If you are comfortable with programming, you c...
[ { "from": "human", "value": "In Mathematica version 7, there was a big advance in logic support (\"Boolean computations\" is the official name). This was not further developed in version 8.0.\nSo now we have a fairly robust support for propositional calculus, but not too much for predicate calculus.\nTo thi...
How do I render a letter with a single dot above it? I see \[DoubleDot] and \[TripleDot] are readily available, but what about a single dot? Specifically I am after Q dot, which is used in thermodynamics. If it helps, here is some background on Unicode and Q dot.
To render a letter with a single dot above it in a typesetting system like LaTeX, you can use the `\dot{}` command. In your case, if you want to create a "Q dot", you can do it as follows: ```latex \documentclass{article} \usepackage{amsmath} \begin{document} The dot above Q is represented as \( \dot{Q} \). \end{do...
[ { "from": "human", "value": "How do I render a letter with a single dot above it?\nI see \\[DoubleDot] and \\[TripleDot] are readily available, but what about a single dot?\nSpecifically I am after Q dot, which is used in thermodynamics. If it helps, here is some background on Unicode and Q dot.\n" }, {...
Mathematica has a useful feature that for functions and special constructs getting passed local variables (for example Minimize or Block), the affected variables are shown in a different colour. Now when writing your own functions of this type (like the NOptimize function found in this answer), Mathematica of course do...
In Mathematica, syntax highlighting for local variables in constructs like `Block` or `Module` is tied to the specific usage of those constructs. When you're defining your own functions, there isn't a built-in way to directly inform the front end about which variables are local. However, you can use the `Context` and `...
[ { "from": "human", "value": "Mathematica has a useful feature that for functions and special constructs getting passed local variables (for example Minimize or Block), the affected variables are shown in a different colour. Now when writing your own functions of this type (like the NOptimize function found ...
Pane[ Style["text is here", Bold, FontColor -> Darker[Gray, .6], Background -> Red ], Alignment -> {Center, Center} ] How to let the pane have rounded corners?
To create a pane with rounded corners in the Wolfram Language, you can use the `Style` function in combination with `RoundedRectangle` to set the shape of the background. Here's how you can achieve that: ```wolfram Graphics[{ EdgeForm[None], Style[RoundedRectangle[{0, 0}, {1, 1}, .1], Red], Style[Text[Style["t...
[ { "from": "human", "value": "Pane[\n Style[\"text is here\", Bold, FontColor -> Darker[Gray, .6],\n Background -> Red\n ],\n Alignment -> {Center, Center}\n ]\n\n\nHow to let the pane have rounded corners?\n" }, { "from": "gpt", "value": "To create a pane with rounded corners in the Wolfram La...
Consider the following: list={1,2,2,2,3}; I would like to replace all 2 with the string "Test". Replace[list,2->"Test"] does not do it. Result must be: {1,"Test","Test","Test",3}.
To replace all instances of `2` with the string `"Test"` in your list `{1, 2, 2, 2, 3}`, you can use the `Replace` function in combination with the `Rule` operator `->`, or you can use `ReplaceAll` (denoted by `/.` in Mathematica). Here’s how you can do it correctly: ```mathematica list = {1, 2, 2, 2, 3}; newList = l...
[ { "from": "human", "value": "Consider the following:\nlist={1,2,2,2,3};\n\nI would like to replace all 2 with the string \"Test\". Replace[list,2->\"Test\"] does not do it.\nResult must be: {1,\"Test\",\"Test\",\"Test\",3}.\n" }, { "from": "gpt", "value": "To replace all instances of `2` with th...
I'm wondering if an automatic differentiation package exists for Mathematica. This is what I mean by automatic differentiation.
Yes, Mathematica has built-in support for automatic differentiation (AD) through its various functions. You can use the `D` function for symbolic differentiation, but for automatic differentiation specifically, you can make use of the `ForwardDiff` and `ReverseDiff` methods implemented in Mathematica. Additionally, th...
[ { "from": "human", "value": "I'm wondering if an automatic differentiation package exists for Mathematica.\nThis is what I mean by automatic differentiation.\n" }, { "from": "gpt", "value": "Yes, Mathematica has built-in support for automatic differentiation (AD) through its various functions. Y...
Print["first part of the result", DateString[]] Print["addition to the result", DateString[]] will add a newline character at the end of line automatically for each Print[]. But I'd like the two strings to be shown on the same line. How can I do this?
In Mathematica, the `Print` function automatically adds a newline at the end of the output. If you want to display two strings on the same line, you can use `StringJoin` or `Row`. Here are two ways to achieve that: 1. **Using `StringJoin`:** You can concatenate the strings with a space in between and then print the...
[ { "from": "human", "value": "Print[\"first part of the result\", DateString[]] \nPrint[\"addition to the result\", DateString[]]\n\nwill add a newline character at the end of line automatically for each Print[]. But I'd like the two strings to be shown on the same line. How can I do this?\n" }, { ...
I have a list of transformations like this: list = {"A" -> "B", "B" -> "A", "C" -> "D"} As this is used to plot an undirected graph with GraphPlot, I don't want to have an Edge between the vertices A-B and B-A. I just want one of them. How do I remove either A -> B or B -> A from this list? In the end, I want the list...
To achieve your goal of removing one of the duplicate edges (i.e., either "A" -> "B" or "B" -> "A"), you can use the `DeleteDuplicates` function along with a custom comparison function that accounts for the undirected nature of your graph. Here's how you can do it: 1. Define a comparison function that checks for the ...
[ { "from": "human", "value": "I have a list of transformations like this:\nlist = {\"A\" -> \"B\", \"B\" -> \"A\", \"C\" -> \"D\"}\n\nAs this is used to plot an undirected graph with GraphPlot, I don't want to have an Edge between the vertices A-B and B-A. I just want one of them.\nHow do I remove either A -...
Say I have a list x={2,4,6,8,10} and I want to find out the positions of the elements that are greater than 7. Select[x, #>7&] gives the elements themselves, and Position[x,8] gives the position of the elements satisfying one of the possible criteria, but what I am looking for would be a mix of the two returning {4,5}....
To find the positions of the elements in the list `x = {2, 4, 6, 8, 10}` that are greater than 7, you can use the `Position` function along with a condition. Specifically, you can apply a condition that filters the positions based on the values in the list. Here's how you can do it: ```mathematica x = {2, 4, 6, 8, 1...
[ { "from": "human", "value": "Say I have a list x={2,4,6,8,10} and I want to find out the positions of the elements that are greater than 7.\nSelect[x, #>7&] gives the elements themselves, and Position[x,8] gives the position of the elements satisfying one of the possible criteria, but what I am looking for ...
"CodeGolf" challenge: write the shortest practical Least Common Multiple function that: Does not use built in GCD, LCM or any related fuctions Accepts multiple arguments in any order, e.g. LCM[3, 20, 6] In the spirit of the original, obfuscated is better
Here's a compact implementation of a Least Common Multiple (LCM) function that meets the specified requirements: ```python l=lambda*a:0if 0in a else abs(reduce(lambda x,y:x*y//gcd(x,y),a)) gcd=lambda x,y:x and gcd(y%x,x)or y from functools import reduce ``` This implementation uses a recursive approach to calculate t...
[ { "from": "human", "value": "\"CodeGolf\" challenge: write the shortest practical Least Common Multiple function that:\n\nDoes not use built in GCD, LCM or any related fuctions\nAccepts multiple arguments in any order, e.g. LCM[3, 20, 6]\nIn the spirit of the original, obfuscated is better\n\n" }, { ...
Here's a simple script saved in the file hello #!/usr/local/bin/MathematicaScript -script Print["Hello world"] I can then run this file using math -script hello or, if the file is set to be executable, ./hello. In Windows or OSX, run MathKernel -script hello It prints "Hello world" to the terminal. How can I change...
To modify your Mathematica script so that it prints "Hello world" without the quotation marks, you should use the `Print` function without the surrounding quotation marks. The `Print` function inherently outputs the string you provide without adding any extra characters. Here's how you can adjust your script: ```mathe...
[ { "from": "human", "value": "Here's a simple script saved in the file hello\n#!/usr/local/bin/MathematicaScript -script\nPrint[\"Hello world\"]\n\nI can then run this file using math -script hello or, \nif the file is set to be executable, ./hello.\nIn Windows or OSX, run MathKernel -script hello\nIt prints...
Probably easy and short question, I still didn't fully figure out how to easily select/delete sublists from a list. Example: tt = {{2, 4}, {4, 8}}; I want to delete/select all the elements where the difference between them (Abs) is greater than four.
You can use a combination of `Select` or `DeleteCases` in Mathematica to filter your sublists based on the condition you provided. Here's how you can do it: 1. **To select the sublists where the absolute difference between the elements is less than or equal to four**, you can use `Select`: ```mathematica tt = {{2, 4}...
[ { "from": "human", "value": "Probably easy and short question, I still didn't fully figure out how to easily select/delete sublists from a list. Example:\ntt = {{2, 4}, {4, 8}};\n\nI want to delete/select all the elements where the difference between them (Abs) is greater than four.\n" }, { "from": ...
The integration of Wolfram|Alpha seems to be one of the (many!) major features of Mathematica 8. Earlier I was reading this Wolfram Blog archive and noticed quite a few articles talking about the use of this API. But what finally got me to ask my first Stack Overflow question was reading the top ranked answer on this q...
As of my last knowledge update in October 2023, the integration of Wolfram|Alpha into Mathematica does indeed provide powerful features that allow users to access the computational engine of Wolfram|Alpha directly from within Mathematica. However, specific usage limits or restrictions regarding how much Mathematica use...
[ { "from": "human", "value": "The integration of Wolfram|Alpha seems to be one of the (many!) major features of Mathematica 8. Earlier I was reading this Wolfram Blog archive and noticed quite a few articles talking about the use of this API.\nBut what finally got me to ask my first Stack Overflow question w...
On my system, the result of this: f[x_] := 2 Sin[x] + Sin[x]^2; Reduce[f'[x] == 0, x] contains the following expression twice: x == -(Pi/2) + 2*Pi*C[1] This is the entire result: Element[C[1], Integers] && (x == -(Pi/2) + 2*Pi*C[1] || x == Pi/2 + 2*Pi*C[1] || x == -(Pi/2) + 2*Pi*C[1] || x == (3*Pi)/2 + 2...
In the context of your problem, when you define the function \( f[x] \) and then use the `Reduce` function to find the critical points (where the derivative \( f'[x] \) is equal to zero), you are getting a result that includes duplicate expressions. The appearance of \( x == -(Pi/2) + 2*Pi*C[1] \) twice in your output...
[ { "from": "human", "value": "On my system, the result of this:\nf[x_] := 2 Sin[x] + Sin[x]^2;\nReduce[f'[x] == 0, x]\n\ncontains the following expression twice:\nx == -(Pi/2) + 2*Pi*C[1]\n\nThis is the entire result:\nElement[C[1], Integers] && \n (x == -(Pi/2) + 2*Pi*C[1] || x == Pi/2 + 2*Pi*C[1] || \n...
This is just a follow-up of this post: Animating a rotating disk Part of the code is: circ = RegionPlot[x^2 + y^2 <= radius^2, {x, -radius, radius}, {y, -radius, radius}, Mesh -> 20, MeshStyle -> {{Red}, {Blue}}, BoundaryStyle -> Black, PlotStyle -> None] where radius = 20. Say that I would like to add a big dot at...
To add a point at the coordinates (10, 10) to your existing `RegionPlot` graphic, you can use the `Epilog` option to specify the point directly. Here's how you can modify your code: ```mathematica radius = 20; circ = RegionPlot[x^2 + y^2 <= radius^2, {x, -radius, radius}, {y, -radius, radius}, Mesh -> 20, Me...
[ { "from": "human", "value": "This is just a follow-up of this post:\nAnimating a rotating disk\nPart of the code is:\ncirc = RegionPlot[x^2 + y^2 <= radius^2, {x, -radius, radius}, \n{y, -radius, radius}, \nMesh -> 20, MeshStyle -> {{Red}, {Blue}}, BoundaryStyle -> Black, \nPlotStyle -> None]\n\nwhere radiu...
Is it by any chance possible to make the Menu key work as one would expect in Mathematica: opening a context menu? The Menu key does nothing in version 7 or 8 on Windows.
In Mathematica, the Menu key may not work as expected on Windows, especially in versions 7 and 8, because the software might not have native support for that key functioning as a context menu trigger. However, you can try the following workarounds: 1. **Use Right-Click**: If you are looking for context menu options, t...
[ { "from": "human", "value": "Is it by any chance possible to make the Menu key work as one would expect in Mathematica: opening a context menu?\nThe Menu key does nothing in version 7 or 8 on Windows.\n" }, { "from": "gpt", "value": "In Mathematica, the Menu key may not work as expected on Windo...
How can I, in one line, generate all the dates with a constant day difference from one date to another? For example, if I'm interested in dates in the interval staring from 24.4.2012 till 2015 and a 28 day difference.
You can generate all the dates with a constant day difference using Python's `pandas` library. Here's a one-liner that achieves this for your specified interval and difference: ```python import pandas as pd dates = pd.date_range(start='2012-04-24', end='2015-12-31', freq='28D') print(dates) ``` This code creates a r...
[ { "from": "human", "value": "How can I, in one line, generate all the dates with a constant day difference from one date to another? \nFor example, if I'm interested in dates in the interval staring from 24.4.2012 till 2015 and a 28 day difference.\n" }, { "from": "gpt", "value": "You can genera...
Graphics only supports machine precision numbers (i.e. number that can be converted to machine precision). Take for example Graphics[Point[{0, Exp[1000.]}]] which produces an error because Exp[1000.] is too large to be representable as a double. What is the simplest way to deal with situations like this? Replacing a...
In Mathematica, you can handle large numbers that exceed machine precision limits by using the built-in function `Clip`. The `Clip` function allows you to limit values to a specified range, replacing values that exceed the bounds with the nearest bound. In your case, you can define a function that clips values above ...
[ { "from": "human", "value": "Graphics only supports machine precision numbers (i.e. number that can be converted to machine precision). Take for example\nGraphics[Point[{0, Exp[1000.]}]]\n\nwhich produces an error because Exp[1000.] is too large to be representable as a double.\nWhat is the simplest way to...
I have a string variable. I want to obtain another string which contains the representation of the string variable content itself. s = "a \n b" I need to get a string containing the exact characters from above, including the escape character \ and the ": r = "\"a \\n b\"" Is there a function that can do that? The out...
Yes, you can achieve this using Python's built-in `repr()` function, which returns a string representation of an object that can be used to reproduce that object when passed to `eval()`. Here's how you can use it with your string variable: ```python s = "a \n b" r = repr(s) print(r) # Output: "'a \\n b'" ``` If yo...
[ { "from": "human", "value": "I have a string variable. I want to obtain another string which contains the representation of the string variable content itself.\ns = \"a \\n b\"\n\nI need to get a string containing the exact characters from above, including the escape character \\ and the \":\nr = \"\\\"a \\...
I have created a new stylesheet but now I'd like to delete a style type, for example "program" from it. How can I do it ?
To delete a style type, such as "program," from your stylesheet, you can follow these steps: 1. **Open Your Stylesheet**: Start by opening your stylesheet file in a text or code editor. This could be a `.css`, `.scss`, or any other stylesheet format. 2. **Locate the Style Type**: Search for the "program" style type w...
[ { "from": "human", "value": "I have created a new stylesheet but now I'd like to delete a style type, for example \"program\" from it. How can I do it ?\n" }, { "from": "gpt", "value": "To delete a style type, such as \"program,\" from your stylesheet, you can follow these steps:\n\n1. **Open Yo...
There are commands like NonlinearModelFit[] or NDSolve[] that have the option Method it typically defaults to Automatic. How can you check after the evaluation of the command which method Mathematica picked?
In Mathematica, after evaluating commands like `NonlinearModelFit[]` or `NDSolve[]`, you can access the options used, including the method that was automatically selected, by examining the output. Both of these functions return a specific type of object that contains information about the options used. 1. For `Nonline...
[ { "from": "human", "value": "There are commands like NonlinearModelFit[] or NDSolve[] that have the option Method it typically defaults to Automatic. How can you check after the evaluation of the command which method Mathematica picked?\n" }, { "from": "gpt", "value": "In Mathematica, after eval...
I have manipulated an image and want to ListPlot it. However, the result is not to my liking because the conventions for drawing images and plots are different. Images have the origin at the top left and increase in Y downwards while plots have the origin at the bottom left and increase in Y upwards. What is the easies...
To reconcile the differences in coordinate systems between images and plots in your case, you can flip the y-axis in the `ListPlot` function. This allows you to maintain the original data without any manipulation. In Mathematica, you can achieve this by using the option `PlotRange -> {All, Automatic}` and the `AxesOrig...
[ { "from": "human", "value": "I have manipulated an image and want to ListPlot it. However, the result is not to my liking because the conventions for drawing images and plots are different. Images have the origin at the top left and increase in Y downwards while plots have the origin at the bottom left and ...
How do I substitue z^2->x in the following polynomial z^4+z^2+4? z^4+z^2+4 /. z^2->x gives z^4+x+4
In your expression, it seems you're trying to substitute \( z^2 \) with \( x \) in the polynomial \( z^4 + z^2 + 4 \). To perform the substitution correctly, you should recognize that \( z^4 \) can also be expressed in terms of \( z^2 \). Specifically, since \( z^4 = (z^2)^2 \), you can substitute \( z^2 \) with \( x ...
[ { "from": "human", "value": "How do I substitue z^2->x in the following polynomial z^4+z^2+4?\nz^4+z^2+4 /. z^2->x\n\ngives \nz^4+x+4\n\n" }, { "from": "gpt", "value": "In your expression, it seems you're trying to substitute \...
I wonder what is the shortcut key for traverse command history (i.e. retrieve last, last last, ..., commands) in a Mathematica session in a terminal? If I hit the up/down arrow or pageup/pagedown, it will only show some incomprehensible codings of the keys. My OS is Ubuntu. Thanks!
In a Mathematica session running in a terminal on Ubuntu, the default keyboard shortcuts for navigating through command history may not work as expected, especially if you're encountering issues with the up/down arrows producing unexpected output. Instead of using Mathematica's built-in command history functionality, ...
[ { "from": "human", "value": "I wonder what is the shortcut key for traverse command history (i.e. retrieve last, last last, ..., commands) in a Mathematica session in a terminal?\nIf I hit the up/down arrow or pageup/pagedown, it will only show some incomprehensible codings of the keys.\nMy OS is Ubuntu.\nT...
Say I have some function that I'm applying every element in a list to... if that element matches some criteria: If[#==<condition>,{#}, <Do nothing> ] & /@ LongList Is there a way to do something like this? I want the result to just not have that element.
Yes, you can achieve this by using the `Select` function in combination with your condition. The `Select` function allows you to filter elements based on a given criterion. If you want to remove elements from `LongList` that match a certain condition, you can use `Select` in the following way: ```mathematica result = ...
[ { "from": "human", "value": "Say I have some function that I'm applying every element in a list to... if that element matches some criteria:\nIf[#==<condition>,{#}, <Do nothing> ] & /@ LongList\n\nIs there a way to do something like this? I want the result to just not have that element.\n" }, { "fro...
An old notebook I've recently started working with has a strange error: Prior to version 8, a figure I generated using Drop[AstronomicalData["Planet"],-1] to display all of the currently recognized planets, along with some other data, worked fine, but in version 8, Neptune is missing. Is this a bug in 8, or am I missin...
The issue you're experiencing with `Drop[AstronomicalData["Planet"], -1]` in version 8, where Neptune is missing, could be due to a change in how `AstronomicalData` handles the list of recognized planets in that version. It's possible that the data returned by `AstronomicalData["Planet"]` has been modified or that Nept...
[ { "from": "human", "value": "An old notebook I've recently started working with has a strange error: Prior to version 8, a figure I generated using Drop[AstronomicalData[\"Planet\"],-1] to display all of the currently recognized planets, along with some other data, worked fine, but in version 8, Neptune is ...
For example, to change the color of each pixel to the mean color of the three channels, I tried i = ExampleData[{"TestImage", "Lena"}]; Mean[i] but it just remains unevaluated: How can I read the colors of an image into a list or matrix and change the color codes and save it back to an image?
In Mathematica, you can manipulate images by accessing their pixel data and then altering it as needed. To change the color of each pixel to the mean color of its three channels, you can follow these steps: 1. Read the image. 2. Convert the image to a list of pixel values. 3. Compute the mean color for each pixel and ...
[ { "from": "human", "value": "For example, to change the color of each pixel to the mean color of the three channels, I tried\ni = ExampleData[{\"TestImage\", \"Lena\"}];\nMean[i]\n\nbut it just remains unevaluated:\n\nHow can I read the colors of an image into a list or matrix and change the color codes and...
Suppose I need to create sliders associated with variables from a given list: ClearAll[a, b, c, d]; vars = {a, b, c, d}; Slider[Dynamic@#, {0, 1}] & /@ vars Dynamic@vars Unfortunately it works only for variables which don't have values: ClearAll[a, b, c, d]; vars = {a, b, c, d}; a = 1; Slider[Dynamic@#, {0, 1}] & /@ v...
To create dynamic sliders that modify variables in a list, you need to ensure that the sliders reference the variables correctly even when they are pre-assigned values. One approach to accomplish this is to use `Dynamic` in combination with `ToExpression` or an anonymous function. Here's how you can do it: ```mathemat...
[ { "from": "human", "value": "Suppose I need to create sliders associated with variables from a given list:\nClearAll[a, b, c, d];\nvars = {a, b, c, d};\nSlider[Dynamic@#, {0, 1}] & /@ vars\nDynamic@vars\n\nUnfortunately it works only for variables which don't have values:\nClearAll[a, b, c, d];\nvars = {a, ...
I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to process, which is why I am trying to accomplish my goal progammatically. The code below results in a Tag warning. I h...
The warning you are receiving indicates that you are trying to assign a value to a symbol created by `ToExpression`, which is not allowed because the `ToExpression` function evaluates its argument and returns a symbol that is not writable (in this case, it's effectively a protected symbol). Instead of using `ToExpres...
[ { "from": "human", "value": "I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to process, which is why I am trying to accomplish my goal progammatically. The ...
NDSolve has an interface for repeatedly solving an equation with different initial conditions without having to analyze the equation and set up the solving algorithm each time. This can improve performance dramatically. For example, nd = First@NDSolve`ProcessEquations[{y'[t] == -y[t], y[0] == 1}, {y}, t] (* NDSolve...
As of my last update in October 2023, there is no direct equivalent to `NDSolve`'s state management feature for `NIntegrate` in the same way as you described for differential equations. `NIntegrate` is designed to perform numerical integration directly each time it is called, and it does not have built-in support for r...
[ { "from": "human", "value": "NDSolve has an interface for repeatedly solving an equation with different initial conditions without having to analyze the equation and set up the solving algorithm each time. This can improve performance dramatically. For example,\nnd = First@NDSolve`ProcessEquations[{y'[t] ==...
A quick question, but which I don't believe has been asked here or at SO. Does Mathematica have a simple way to just download a file from the web? i.e. if I have a list of PDF links (~ 2,000), can I use Mathematica to quickly take them and save them to my system. The obvious way that I've used in the past is to Import[...
Yes, Mathematica provides a straightforward way to download files from the web using the built-in `URLDownload` function. This function allows you to download files directly to your system without needing to import them into Mathematica. You can easily use it in a loop to handle a list of URLs. Here's a basic example ...
[ { "from": "human", "value": "A quick question, but which I don't believe has been asked here or at SO.\nDoes Mathematica have a simple way to just download a file from the web? i.e. if I have a list of PDF links (~ 2,000), can I use Mathematica to quickly take them and save them to my system. The obvious wa...
The task is to compute symmSum[{a, b, c, d, e, f}] (*==> {a+f, b+e, c+d} *) symmSum[{a, b, c, d, e}] (*==> {a+e, b+d, c} *) My clumsy solution is symmSum[l_List] := Block[{n = Length@l, res}, res = Last@Last@Reap@Do[Sow[l[[i]] + l[[-i]]], {i, Ceiling[n/2]}]; If[OddQ@n, res[[-1]] /= 2]; res ]; I feel th...
You can indeed compute the symmetric sums without explicitly using the `Length` function. Instead, you can use pattern matching and functional programming constructs. Below is a clean implementation of `symmSum` that achieves this: ```mathematica symmSum[l_List] := Module[{n = Length[l]}, If[EvenQ[n], Tot...
[ { "from": "human", "value": "The task is to compute\nsymmSum[{a, b, c, d, e, f}]\n\n(*==> {a+f, b+e, c+d} *)\n\nsymmSum[{a, b, c, d, e}]\n\n(*==> {a+e, b+d, c} *)\n\nMy clumsy solution is\nsymmSum[l_List] := Block[{n = Length@l, res},\n res = Last@Last@Reap@Do[Sow[l[[i]] + l[[-i]]], {i, Ceiling[n/2]}];\n ...
The product page for Mathematica Home Edition says: Mathematica Home Edition is intended for hobbyists and enthusiasts alike, for non-professional use. If you wish to integrate Mathematica in your work, teaching, or research, other licensing options are available. but I cannot find there nor here any technical descr...
Mathematica Home Edition and the professional versions of Mathematica (such as the Student, Education, or Commercial editions) are essentially the same software in terms of functionality and features. The primary difference lies in the licensing restrictions associated with each edition. 1. **Mathematica Home Edition*...
[ { "from": "human", "value": "The product page for Mathematica Home Edition says:\n\nMathematica Home Edition is intended for hobbyists and enthusiasts alike, for non-professional use. If you wish to integrate Mathematica in your work, teaching, or research, other licensing options are available. \n\nbut I c...
Suppose I read a file with B = Import["something.wav"] Now how can I obtain a list of sample values?
In Mathematica, when you use `Import` to read a WAV file, the data is typically stored in a nested list structure, where each sublist corresponds to a channel of the audio. To extract the sample values from the imported data, you can use the following steps: 1. First, ensure that you have imported the audio file into ...
[ { "from": "human", "value": "Suppose I read a file with\nB = Import[\"something.wav\"]\n\nNow how can I obtain a list of sample values?\n" }, { "from": "gpt", "value": "In Mathematica, when you use `Import` to read a WAV file, the data is typically stored in a nested list structure, where each s...
I want to modify the value that is returned by Solve. Example: SolC1 = Solve[Sin[ π x / L] == 1, x] {{x -> L/2}} I need to add n to x so that x becomes n + L/2. Both of the following I tried yields unwanted result in the succeeding calculation. SolC1 = (x -> L/2) + n ---- SolC1 = SolC1 + n I particularly need the pro...
To modify the value returned by `Solve` in Mathematica, you can map over the solution rules and add \( n \) to each instance of \( x \) in the rules. Since the output of `Solve` is a list of replacement rules, you can use the `ReplaceAll` (or `/.` shorthand) function to achieve this. Here’s how you can modify the solut...
[ { "from": "human", "value": "I want to modify the value that is returned by Solve. Example:\nSolC1 = Solve[Sin[ π x / L] == 1, x]\n{{x -> L/2}}\n\nI need to add n to x so that x becomes n + L/2.\nBoth of the following I tried yields unwanted result in the succeeding calculation.\nSolC1 = (x -> L/2) + n\n---...
I find it very convenient to use Mathematica notebooks to organize the codes + results. I was wondering if it is possible to insert an animated image (say an animated gif) in the middle of a notebook. I tried dragging and dropping an animated gif into a notebook, the gif itself was created using Mathematica. Mathematic...
Yes, you can insert an animated GIF directly into a Mathematica notebook without needing to recreate it using `Manipulate` or `Animate`. Mathematica supports the insertion of animated images in a straightforward manner. Here’s how you can do it: 1. **Use the `Import` Function**: You can directly import the animated GI...
[ { "from": "human", "value": "I find it very convenient to use Mathematica notebooks to organize the codes + results.\nI was wondering if it is possible to insert an animated image (say an animated gif) in the middle of a notebook.\nI tried dragging and dropping an animated gif into a notebook, the gif itsel...
Possible Duplicate: Get a “step by step” evaluation in Mathematica In wolfram alpha, when preforming for complicated integrals there's a 'show steps' option that explains how the integral was computed. Is there any way to do that using mathematica?
In Mathematica, you can obtain step-by-step solutions for integrals (and other mathematical problems) using the `FunctionExpand`, `Simplify`, `Integrate`, and `FullSimplify` functions along with the `Assuming` function for additional context. However, Mathematica does not have a built-in equivalent to Wolfram Alpha's "...
[ { "from": "human", "value": "\nPossible Duplicate:\nGet a “step by step” evaluation in Mathematica \n\nIn wolfram alpha, when preforming for complicated integrals there's a 'show steps' option that explains how the integral was computed. Is there any way to do that using mathematica?\n" }, { "from":...
Say I make and display a graph in a Mathematica notebook: graph = CompleteGraph[100] If I drag the corner of the graph to increase its size, and then save it to a file, I get a really big detailed picture of the graph. This is great! I would like to do this without the dragging interaction. Specifically, I want to gen...
To create high-resolution images of a graph in Mathematica without manual interaction, you can adjust the `ImageSize` option when exporting the graph. Instead of using `ImageResize`, which rasterizes the image before resizing, you can specify a larger size directly when exporting. Here's how you can do it: 1. Use the ...
[ { "from": "human", "value": "Say I make and display a graph in a Mathematica notebook:\ngraph = CompleteGraph[100]\n\nIf I drag the corner of the graph to increase its size, and then save it to a file, I get a really big detailed picture of the graph. This is great! I would like to do this without the dragg...
I saved a Mathematica Notebook as a *.tex file. When compiling in TeXnicCenter I get the an error on the following generated code. \begin{doublespace} \noindent\(\(\{0,10,1\}\)\) \end{doublespace} The error is just: Bad math environment delimiter. Question: How to get rid of the above error? ( Perhaps, this is one for...
The error you're encountering in your LaTeX document is due to incorrect syntax in the generated code. Specifically, the use of `\(\(\{0,10,1\}\)\)` is problematic because it has extra pairs of parentheses that don't conform to LaTeX's math environment requirements. To fix the error, you need to ensure that your LaTeX...
[ { "from": "human", "value": "I saved a Mathematica Notebook as a *.tex file. When compiling in TeXnicCenter I get the an error on the following generated code.\n\\begin{doublespace}\n\\noindent\\(\\(\\{0,10,1\\}\\)\\)\n\\end{doublespace}\n\nThe error is just: Bad math environment delimiter.\nQuestion: How t...
Mathematica 8 includes "Wolfram | Alpha integration", but the features of Alpha available in Mathematica seem not to include many of those available in the "Pro" version of Alpha. Does Mathematica 8 include Alpha's Plus features? If not, has Wolfram announced plans to include them?
Mathematica 8 does indeed include integration with Wolfram|Alpha, allowing users to access a range of computational capabilities directly within the Mathematica environment. However, the features available through this integration are typically based on the standard Wolfram|Alpha services and do not include the additio...
[ { "from": "human", "value": "Mathematica 8 includes \"Wolfram | Alpha integration\", but the features of Alpha available in Mathematica seem not to include many of those available in the \"Pro\" version of Alpha. \nDoes Mathematica 8 include Alpha's Plus features? If not, has Wolfram announced plans to incl...
Bug introduced in 8.0 or earlier and fixed in 9.0.0 Concerns Linux I have a very annoying problem. The Conjugate glyph (*) does not show when I type. That is, if I type \[Conjugate] or ⋮co⋮ then no character appears on the screen, although the conjugation operator is definitely there and working. I'm running Mathema...
It sounds like you're experiencing a rendering issue with the conjugate glyph in Mathematica 8 on your Fedora system. This type of problem, where specific characters don't display properly even though they are recognized and functional, can often be attributed to font issues or bugs in the software. Since you mentione...
[ { "from": "human", "value": "Bug introduced in 8.0 or earlier and fixed in 9.0.0\nConcerns Linux\n\nI have a very annoying problem. \nThe Conjugate glyph (*) does not show when I type.\nThat is, if I type \\[Conjugate] or ⋮co⋮ then no character appears on the screen, although the conjugation operator is def...
Is there a possibility to suppress the Mathematica Kernel taskbar tab when accessing it through .NETLink on Windows?
Yes, when using the .NET/Link to access Mathematica from a .NET application, it is possible to suppress the Mathematica kernel window (and its taskbar tab) from appearing. To achieve this, you can configure the kernel's display options by manipulating the process creation settings. In particular, you can set the `Crea...
[ { "from": "human", "value": "Is there a possibility to suppress the Mathematica Kernel taskbar tab when accessing it through .NETLink on Windows?\n" }, { "from": "gpt", "value": "Yes, when using the .NET/Link to access Mathematica from a .NET application, it is possible to suppress the Mathemati...
I have the following images, both 480 x 270 pixels: I'd like to stitch them side by side in a 960 x 270 pixel image like so (scaled down): So far, I've been using GraphicsGrid to try to achieve this: c1 = Import["https://i.stack.imgur.com/2SRcD.png"]; c2 = Import["https://i.stack.imgur.com/zL8id.png"]; (* Frame para...
To stitch two images side by side without scaling or padding in Mathematica, you can use the `Image` function along with `ImageCompose` or simple image manipulation functions. Here's how you can do it: 1. Load the images. 2. Use the `ImageCollage` function or `ImageCompose` to combine them without adding padding. Her...
[ { "from": "human", "value": "I have the following images, both 480 x 270 pixels:\n\n\nI'd like to stitch them side by side in a 960 x 270 pixel image like so (scaled down):\n\nSo far, I've been using GraphicsGrid to try to achieve this:\nc1 = Import[\"https://i.stack.imgur.com/2SRcD.png\"];\nc2 = Import[\"h...
I have an external function called increment (for the sake of illustration) that I call from Mathematica using MathLink. I.e., Install[<path-to-mathlink-executable>] which is defined as ?increment increment[x_Real]:=ExternalCall[LinkObject[<path-to-mathlink-executable>,10,10],CallPacket[0,{x}]] It works fine when I ...
In Mathematica, when you use `ParallelMap`, each parallel kernel runs in its own separate session and does not share the same environment or variables as the master kernel. This includes external links created with MathLink. That's why you see the errors regarding `LinkObject` being invalid; each parallel kernel does n...
[ { "from": "human", "value": "I have an external function called increment (for the sake of illustration) that I call from Mathematica using MathLink. I.e., \nInstall[<path-to-mathlink-executable>]\n\nwhich is defined as\n?increment\nincrement[x_Real]:=ExternalCall[LinkObject[<path-to-mathlink-executable>,10...
Mathematica can import zipped files automatically, but when the content of the zip file it's another zipped file, I just get the list of files in the second zip: In[317]:= Import["http://www.meff.com/docs/Ficheros/Descarga/dRV/RV120312.zip","*"] Out[317]={{TGENTRADES.M3,CCONTRGRP.C2,CCONTRTYP.C2,CCONTRACTS.C2,CCONTRSTA...
In Mathematica, when you import a zipped file that contains another zipped file, you can extract the inner zip file and then import its contents manually. Below is a step-by-step method to access the contents of the inner zipped files. Assuming you've already imported the outer zip file, you can use the following appr...
[ { "from": "human", "value": "Mathematica can import zipped files automatically, but when the content of the zip file it's another zipped file, I just get the list of files in the second zip:\nIn[317]:= Import[\"http://www.meff.com/docs/Ficheros/Descarga/dRV/RV120312.zip\",\"*\"]\nOut[317]={{TGENTRADES.M3,CC...
Suppose I'm stopped at a breakpoint in Workbench, say at one of the y = ... lines in: foo[a_] := Block[{y}, If[Sin[a] > 0, y = -1, y = 1 ] ] How can I find out what Sin[a] is? Or more generally do some other evaluation using the current state of my program?
When you're stopped at a breakpoint in Wolfram Language (Mathematica) Workbench, you have access to the current state of your program, and you can evaluate expressions in the current scope. To find out the value of `Sin[a]` at the breakpoint, you can use the following approach: 1. **Evaluate `Sin[a]`**: You can simply...
[ { "from": "human", "value": "Suppose I'm stopped at a breakpoint in Workbench, say at one of the y = ... lines in:\nfoo[a_] := Block[{y}, \n If[Sin[a] > 0,\n y = -1,\n y = 1\n ]\n ]\n\nHow can I find out what Sin[a] is? Or more generally do some other evaluation using the current...
I'm using SingularValueDecomposition for a least-squares regression, the instruction that works fine for what I need is SingularValueDecomposition[X,Length[SingularValueList[X]]] Is there a way to do the same thing but without calling SingularValueList as I suppose similar computations are done two times in SingularVa...
Yes, you can avoid calling `SingularValueList` separately by directly using the output of the `SingularValueDecomposition` function. When you use `SingularValueDecomposition`, it returns both the singular values and the singular vectors in a single call. Here’s how you can achieve that: 1. Call `SingularValueDecompos...
[ { "from": "human", "value": "I'm using SingularValueDecomposition for a least-squares regression, the instruction that works fine for what I need is\nSingularValueDecomposition[X,Length[SingularValueList[X]]]\n\nIs there a way to do the same thing but without calling SingularValueList as I suppose similar c...
In a stacked BarChart or Histogram the bars are stacked from bottom to top, while the legend entries are listed from top to bottom. Is there a way to make the legend entries go the other way round to improve the visual correspondence between the chart and the legend? E.g. {bottom,middle,top}=RandomReal[NormalDistributi...
In Mathematica, you can customize the order of legend entries in relation to your stacked BarChart or Histogram by manually specifying the order of the legend entries to match the stack order of the bars. In the example you provided, the `ChartLegends` can be reversed by reordering the entries accordingly. Here's how ...
[ { "from": "human", "value": "In a stacked BarChart or Histogram the bars are stacked from bottom to top, while the legend entries are listed from top to bottom. Is there a way to make the legend entries go the other way round to improve the visual correspondence between the chart and the legend?\nE.g.\n{bot...
How does one clear the notebook from symbols that remain in it after an edit session?
To clear symbols from a notebook in a computational environment like Jupyter Notebook or similar platforms, you generally have a few options depending on the context in which you're working: ### In Jupyter Notebook: 1. **Restart the Kernel:** - Go to the menu bar and select `Kernel` > `Restart`. This will clear al...
[ { "from": "human", "value": "How does one clear the notebook from symbols that remain in it after an edit session?\n" }, { "from": "gpt", "value": "To clear symbols from a notebook in a computational environment like Jupyter Notebook or similar platforms, you generally have a few options dependi...
I am plotting two histograms on the same graph: g1 = Histogram[bc, ChartStyle -> {Red}] g2 = Histogram[bcx] Show[g1, g2, PlotRange -> {{0.1, 0.6}, All}] But I would like the plots to overlap so that they are "see-through" and I can compare them. I've been trying with ChartStyle -> {"Overlapped"} which hasn't been w...
To create overlapping histograms in Mathematica (Wolfram Language) with transparency so that you can compare them effectively, you can use the `Opacity` function to set the transparency level of each histogram. Here's how you can modify your code to achieve that: ```mathematica g1 = Histogram[bc, ChartStyle -> {Red, O...
[ { "from": "human", "value": "I am plotting two histograms on the same graph:\ng1 = Histogram[bc, ChartStyle -> {Red}]\ng2 = Histogram[bcx]\nShow[g1, g2, PlotRange -> {{0.1, 0.6}, All}]\n\n\nBut I would like the plots to overlap so that they are \"see-through\" and I can compare them.\nI've been trying with ...
Mathematica has a built-in function ValueQ. Quoting the docs, ValueQ[expr] gives True if a value has been defined for expr, and gives False otherwise. ... ValueQ gives False only if expr would not change if it were to be entered as Mathematica input. This works nicely with symbols that only have OwnValues: x = Print[...
Yes, it is possible to create a more robust version of `ValueQ` that avoids evaluating its argument in an unexpected or dangerous manner. The key is to use `Hold` to prevent evaluation of the expression passed to your custom function. Here’s how you can implement such a version: ```mathematica SafeValueQ[expr_] := ...
[ { "from": "human", "value": "Mathematica has a built-in function ValueQ. Quoting the docs,\n\nValueQ[expr] gives True if a value has been defined for expr, and gives False otherwise.\n...\nValueQ gives False only if expr would not change if it were to be entered as Mathematica input.\n\nThis works nicely wi...
Options[myPlot] = Options[Plot]; myPlot[args___] := ... When defining a "wrapper" function like the above, I'd like it to inherit the System` function's options. Should I use Options[myPlot] = Options[Plot] or Options[myPlot] := Options[Plot]?
When defining a wrapper function that should inherit options from another function, you should use `Options[myPlot] := Options[Plot]`. The `:=` (SetDelayed) will ensure that `myPlot`'s options are always retrieved freshly from `Plot` whenever they are needed. This is particularly important if the options of `Plot` chan...
[ { "from": "human", "value": "Options[myPlot] = Options[Plot];\nmyPlot[args___] := ...\n\nWhen defining a \"wrapper\" function like the above, I'd like it to inherit the System` function's options. Should I use Options[myPlot] = Options[Plot] or Options[myPlot] := Options[Plot]?\n" }, { "from": "gpt...
Upon exporting a Mathematica graphics expression as a PDF, Mathematica does not seem to embed any nonstandard fonts used. When you open the resulting PDF document with a PDF viewer, all the text items are rendered with standard fonts instead. Is there a way to make Mathematica embed nonstandard fonts? Example with Mat...
In Mathematica, the ability to embed nonstandard fonts in exported PDFs can be limited, particularly in older versions like 8.0.4. When exporting graphics, Mathematica might not include the nonstandard fonts you use in the output PDF, leading to the default font being used instead. Here's how you might work around thi...
[ { "from": "human", "value": "Upon exporting a Mathematica graphics expression as a PDF, Mathematica does not seem to embed any nonstandard fonts used. When you open the resulting PDF document with a PDF viewer, all the text items are rendered with standard fonts instead. \nIs there a way to make Mathematica...
My aim is to extract the contents of an Input cells as plain text. Ideally I would like to be able to select one or more Input cells and press a button which would then extract the text from these cells as a string and assign it to a variable. However, this turns out to be harder than it seems (to me at least). One wa...
It looks like you're trying to extract the content from selected input cells in a Mathematica notebook while preserving the clipboard contents. While the two methods you've mentioned do work, they both involve intermediate steps that may not be necessary. You can extract the text directly from the selected input cell...
[ { "from": "human", "value": "My aim is to extract the contents of an Input cells as plain text. Ideally I would like to be able to select one or more Input cells and press a button which would then extract the text from these cells as a string and assign it to a variable. However, this turns out to be harde...
I currently have a Mathematica code similar to: ParallelDo[ Quiet@Check[ Print[var1, "\t", var2, "\t", integral1[var1,var2], "\t", integral2[var1, var2]], err ], {var1, 10, 50, 2}, {var2, 10, 100,1} ] And, I get the results I want in the GUI. However, I can't seem to figure out the best way to expo...
You can modify your `ParallelDo` loop to collect the results into a list instead of printing them directly. Once you've collected the results, you can export them to a CSV file. Here's how you can do it: 1. Create a list to hold the results. 2. Append the results to this list within the loop. 3. After the loop, export...
[ { "from": "human", "value": "I currently have a Mathematica code similar to:\nParallelDo[\n Quiet@Check[\n Print[var1, \"\\t\", var2, \"\\t\", integral1[var1,var2], \"\\t\",\n integral2[var1, var2]], \n err\n ], \n {var1, 10, 50, 2}, {var2, 10, 100,1}\n]\n\nAnd, I get the results I want in the G...
How could I export the following as a single image and set its dimensions ? Column[{Row[{Graphics@Disk[], Graphics@Rectangle[]}], Row[{Graphics@Rectangle[], Graphics@Disk[]}]}]
In order to export a layout consisting of graphics as a single image in Mathematica, you can use the `Image` and `ImageCompose` functions to combine the graphics and then export the final image with specified dimensions. Here is a step-by-step guide: 1. Create the graphics that you want to combine. 2. Use `ImageCompo...
[ { "from": "human", "value": "How could I export the following as a single image and set its dimensions ?\nColumn[{Row[{Graphics@Disk[], Graphics@Rectangle[]}],\n Row[{Graphics@Rectangle[], Graphics@Disk[]}]}]\n\n\n" }, { "from": "gpt", "value": "In order to export a layout consisting of g...
How would I create an output similar to the result produced by this $ \mathrm\LaTeX $ code: M = \bordermatrix{~ & x & y \cr A & 1 & 0 \cr B & 0 & 1 \cr} which when compiled, looks like
To create an output similar to the provided LaTeX code, you can use the `bordermatrix` command to construct a matrix with labeled rows and columns. Here is how you can do it: ```latex \documentclass{article} \usepackage{amsmath} \begin{document} \[ M = \bordermatrix{~ & x & y \cr A & 1 & 0 \cr ...
[ { "from": "human", "value": "How would I create an output similar to the result produced by this $ \\mathrm\\LaTeX $ code:\nM = \\bordermatrix{~ & x & y \\cr\n A & 1 & 0 \\cr\n B & 0 & 1 \\cr}\n\nwhich when compiled, looks like \n\n" }, { "from": "gpt", "value":...
Suppose I have a plot like LogLogPlot[2 x^5/3, {x,0.1,10}, GridLines->Automatic] How can I achieve to get "custom" gridlines to reduce the number of horizontal lines? I know how to do it with linear scaled plot. Edit For linear scale I do basicly: myGrid[{xmin,xmax,xstep}, {ymin,ymax,ystep}]:= GridLines->{{#&,/@Range[...
To customize gridlines in a `LogLogPlot`, you can utilize the `LogLinearPlot` functionality along with custom grid line specifications. However, since you're looking to reduce the number of horizontal lines, you can manually specify the grid lines in the logarithmic scale context. You can define a custom grid line spe...
[ { "from": "human", "value": "Suppose I have a plot like\nLogLogPlot[2 x^5/3, {x,0.1,10}, GridLines->Automatic]\n\nHow can I achieve to get \"custom\" gridlines to reduce the number of horizontal lines?\nI know how to do it with linear scaled plot.\nEdit\nFor linear scale I do basicly:\nmyGrid[{xmin,xmax,xst...
I have two ArrayPlots that I would like to align but my "tweaking" failed yet. I would like each "row" to be aligned. lista = RandomReal[{0, 1}, 10]; listb = Table[RandomReal[{0, 1}, 10], {1000}]; Row[{ArrayPlot[{Table[0, {Length@lista}], lista}\[Transpose], Frame -> False, AspectRatio...
To align the two `ArrayPlot` outputs such that each "row" corresponds properly between the two plots, we can use the `Grid` function instead of `Row`. This allows us to specify the alignment of the plots vertically, making it easier to maintain the intended visual relationship. Here's how you can adjust your code to u...
[ { "from": "human", "value": "I have two ArrayPlots that I would like to align but my \"tweaking\" failed yet. I would like each \"row\" to be aligned.\nlista = RandomReal[{0, 1}, 10];\nlistb = Table[RandomReal[{0, 1}, 10], {1000}];\n\nRow[{ArrayPlot[{Table[0, {Length@lista}], lista}\\[Transpose], \n ...
I display a financial chart which I display with InteractiveTradingChart[]. My problem is that when my financial is displayed, even though I ask for 6 months of data, the chart only shows a subset of that. I can go to the bottom of the chart and enlarge the area of interest manually. How do I tell InteractiveTradingCha...
To display the entire time period you requested in `InteractiveTradingChart[]`, you can use the `TimeRange` option to specify the range explicitly. You should set the `TimeRange` to cover the full duration of the data you're loading, in this case, 6 months. Here’s a general example of how you might structure your `Int...
[ { "from": "human", "value": "I display a financial chart which I display with InteractiveTradingChart[]. My problem is that when my financial is displayed, even though I ask for 6 months of data, the chart only shows a subset of that. I can go to the bottom of the chart and enlarge the area of interest manu...
This is certainly a newbie question but I could not find the answer by searching. I am using Mathematica 8 under Windows 7. I want to use default magnification of 150% for all notebooks and help files which I open in Mathematica. At present I have to do it through Windows->Magnification for every single document I open...
In Mathematica, you can set default options for all notebooks, including the magnification level, by modifying the initialization files. Here's how you can do it for Mathematica 8: 1. **Open your Initialization Notebook**: In Mathematica, you can create an initialization notebook that runs automatically when you start...
[ { "from": "human", "value": "This is certainly a newbie question but I could not find the answer by searching.\nI am using Mathematica 8 under Windows 7. I want to use default magnification of 150% for all notebooks and help files which I open in Mathematica. At present I have to do it through Windows->Magn...
In my investigation of the possibilities offered by the Notation package, I came over a limitation in the complexity of the left hand side symbol. For instance, although I am able to enter Notation[ ParsedBoxWrapper[ OverBar[SuperStar[af]]] \[DoubleLongLeftRightArrow] ParsedBoxWrapper["afstarbar"]] with...
The issue you're experiencing with the Notation package in Mathematica is related to the way Mathematica handles the representation of complex symbols using boxes. The boxes are essentially the underlying structure that determines how expressions are displayed, and any errors in these boxes can lead to incorrect or inc...
[ { "from": "human", "value": "In my investigation of the possibilities offered by the Notation package, I came over a limitation in the complexity of the left hand side symbol. For instance, although I am able to enter\n Notation[\n ParsedBoxWrapper[\n OverBar[SuperStar[af]]]\n \\[DoubleLongLeftRight...
Graphics[{ Text[ Style["Jean", 14, Bold, "Helvetica", Black, TextAlignment -> Right],{1, 1}], Text[ Style["Claude", 10, "Helvetica", Bold, Black, TextAlignment -> Right], {19, .8}]}, PlotRange -> {{0, 21}, {0, 2}}, ImageSize -> 300, Method -> {"ShrinkWrap" -> True}, ImagePadding -> 2...
In the context of using `Graphics` in a language like Mathematica, the issue you're encountering with the `Text[]` objects disappearing after adding a `Rectangle[]` is likely related to the order in which the graphics primitives are rendered. In `Graphics`, the order of elements matters because they are drawn in the or...
[ { "from": "human", "value": "Graphics[{\n Text[\n Style[\"Jean\", 14, Bold, \"Helvetica\", Black, \n TextAlignment -> Right],{1, 1}],\n\n Text[\n Style[\"Claude\", 10, \"Helvetica\", Bold, Black, \n TextAlignment -> Right], {19, .8}]},\n\n PlotRange -> {{0, 21}, {0, 2}}, ImageSize -> ...
I know that there are methods to structurally manipulate held expressions (discussed e.g. here), but I failed to apply those for this particular problem: (Hold[{3, 4, 5 | 6}] /. (Verbatim@Alternatives)[x__] :> RandomChoice@List@x) Hold[{3, 4, RandomChoice[{5, 6}]}] The code should replace any Alternatives in the he...
To achieve the desired behavior of replacing `Alternatives` in a held expression with a random choice from the specified alternatives, you can use a combination of `Replace`, `Verbatim`, and `RandomChoice` functions. Here is how you can structure your code to achieve that: ```mathematica Hold[{3, 4, 5 | 6}] /. (Verb...
[ { "from": "human", "value": "I know that there are methods to structurally manipulate held expressions (discussed e.g. here), but I failed to apply those for this particular problem:\n(Hold[{3, 4, 5 | 6}] /. (Verbatim@Alternatives)[x__] :> RandomChoice@List@x)\n\n\nHold[{3, 4, RandomChoice[{5, 6}]}]\n\n\nTh...
May be someone can explain why I can't use Begin["context`"] and End[] inside a Manipulate expression, or inside the initialization section? When I use it in the Manipulate expression, and close the notebook and restart, I get the error: Here is the code, please feel free to modify as needed. I am just trying to see i...
The issue you're experiencing with using `Begin["context`"]` and `End[]` inside a `Manipulate` expression is primarily due to how `Manipulate` and `DynamicModule` handle contexts and scoping. Here's a breakdown of the situation: 1. **Dynamic Scope**: `Manipulate` creates a `DynamicModule`, which generates a local sco...
[ { "from": "human", "value": "May be someone can explain why I can't use Begin[\"context`\"] and End[] inside a Manipulate expression, or inside the initialization section?\nWhen I use it in the Manipulate expression, and close the notebook and restart, I get the error:\n\nHere is the code, please feel free ...
How can one simplify an expression by assuming that one of the variables is equal to zero? For instance, while Simplify[%,a>0] gives the desired output, Simplify[%,a=0] produces the following error: $Assumptions::bass: 0 is not a well-formed assumption. >>
When you want to simplify an expression by assuming that one of the variables is equal to zero in a system like Mathematica, you can use a different approach than using `Assumptions`. The error you encountered arises because the syntax for setting a variable equal to a value is not treated as a proper assumption in the...
[ { "from": "human", "value": "How can one simplify an expression by assuming that one of the variables is equal to zero? For instance, while Simplify[%,a>0] gives the desired output, Simplify[%,a=0] produces the following error:\n$Assumptions::bass: 0 is not a well-formed assumption. >>\n\n" }, { "fr...
If I have a list list={3,7,4,5,1} how to get the List of Intervals /Ranges result = {{1,3},{3,4},{4,5},{5,7}}
To get the list of intervals or ranges from a given list of numbers, you can follow these steps: 1. **Sort the list**: First, make sure the list is sorted in ascending order. 2. **Create intervals**: Iterate through the sorted list to create pairs of consecutive elements, forming the intervals. Here is how you can im...
[ { "from": "human", "value": "If I have a list \nlist={3,7,4,5,1}\n\nhow to get the List of Intervals /Ranges\nresult = {{1,3},{3,4},{4,5},{5,7}}\n\n" }, { "from": "gpt", "value": "To get the list of intervals or ranges from a given list of numbers, you can follow these steps:\n\n1. **Sort the li...
I can think of calling Print and then SelectionMove to copy the expression and then delete it. Is there any more transparent way?
It sounds like you are trying to manipulate an expression in a way that involves printing it, moving the selection, copying, and then deleting it. However, depending on the context (for example, whether you are using a specific programming language, a text editor, or a software application), there could be various meth...
[ { "from": "human", "value": "I can think of calling Print and then SelectionMove to copy the expression and then delete it. Is there any more transparent way?\n" }, { "from": "gpt", "value": "It sounds like you are trying to manipulate an expression in a way that involves printing it, moving the...
I'm looking for the best function to apply the product of the last two elements of sublist elements to each element: Example: (*Input:*) {{x1, y1, z1}, {x2, y2, z2}, ...} (*Desired output:*) {{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...} I know I could just use a Do loop with an index k and do it element by ...
You can achieve this in a more functional and efficient way in Mathematica using `Map`. Specifically, you can use `Map` to apply a function to each sublist. In this case, you want to take the product of the last two elements of each sublist and append it to the end of the sublist. Here is how you can do it: ```mathem...
[ { "from": "human", "value": "I'm looking for the best function to apply the product of the last two elements of sublist elements to each element:\nExample:\n(*Input:*)\n {{x1, y1, z1}, {x2, y2, z2}, ...} \n\n(*Desired output:*)\n\n\n{{x1, y1, z1, y1 z1}, {x2, y2, z2, y2 z2}, ...} \n\n\nI know I could just...
Table[{Re[5 Exp[I 5/2 t]], Im[5 Exp[I 5/2 t]]}, {t, 0, 6}] ListPlot[%] This code plots 6 points in the complex plane. To each point I would like to add a label in the plot that lists the value of t. How can I do that? Please note: I want to print this plot, so the labels should all be visible.
To label the points in your plot with the corresponding values of \( t \), you can use the `Text` function in combination with `ListPlot`. Below is a modification of your code that adds labels to each point in the plot. Here’s how you can do it: ```mathematica (* Generate the points *) data = Table[{Re[5 Exp[I 5/2 t...
[ { "from": "human", "value": "Table[{Re[5 Exp[I 5/2 t]], Im[5 Exp[I 5/2 t]]}, {t, 0, 6}]\nListPlot[%]\n\nThis code plots 6 points in the complex plane. To each point I would like to add a label in the plot that lists the value of t. How can I do that?\nPlease note:\nI want to print this plot, so the labels s...
I am using the following code to easily generate a row of images of all eight planets of our Solar System: Labeled[# // Text, AstronomicalData[#, "Image"]] & /@ AstronomicalData["Planet"] // Row I like the above code because it is concise and gives nice output. However, if I wanted to do something similar for the ...
You can achieve the desired behavior of filtering out elements based on a condition using the `Select` function in combination with `Map`. The `Select` function allows you to create a list that contains only those elements that satisfy a certain criterion. In your case, you want to keep only the moons that have an asso...
[ { "from": "human", "value": "I am using the following code to easily generate a row of images of all eight planets of our Solar System:\nLabeled[# // Text, AstronomicalData[#, \"Image\"]] & /@ \n AstronomicalData[\"Planet\"] // Row\n\nI like the above code because it is concise and gives nice output. Howe...
Possible Duplicate: Why does MatrixForm affect calculations? I am doing a matrix multiplication, but not getting the desired output. I am doing the matrix multiplication of $A^{-1}B$ from the following $Ax=B$. Multiplying a square matrix times a column vector, I would expect to get a column vector as so: $4\times 4 ...
The issue you're encountering is due to the fact that when you use `MatrixForm` in your code, it does not produce a matrix that can be used for calculations. Instead, `MatrixForm` is primarily for display purposes. It essentially wraps the matrix in a way that prevents further calculations from being performed correctl...
[ { "from": "human", "value": "\nPossible Duplicate:\nWhy does MatrixForm affect calculations? \n\nI am doing a matrix multiplication, but not getting the desired output. I am doing the matrix multiplication of $A^{-1}B$ from the following $Ax=B$. Multiplying a square matrix times a column vector, I would exp...
How can I programmatically check from a preemptive evaluation whether a main evaluation is currently ongoing? I need a function mainEvaluationOngoingQ[] so that Button["Evaluating?", Print@mainEvaluationOngoingQ[], Method -> "Preemptive"] will print True only if a main evaluation is ongoing.
In order to determine if a main evaluation is currently ongoing in a preemptive evaluation in Mathematica, you can use the built-in function `EvaluationNotebook[]` alongside some other functions to track the state of the main evaluation. Here's a potential implementation of `mainEvaluationOngoingQ[]`: ```mathematica ...
[ { "from": "human", "value": "How can I programmatically check from a preemptive evaluation whether a main evaluation is currently ongoing?\nI need a function mainEvaluationOngoingQ[] so that \nButton[\"Evaluating?\", Print@mainEvaluationOngoingQ[], Method -> \"Preemptive\"]\n\nwill print True only if a main...
I have some data: data={{"a", 1, 1}, {"a", 1, 2}, {"a", 1, 3}, {"c", 2, 1}, {"b", 2, 2}, {"b", 2, 3}, {"c", 3, 1}, {"a", 3, 2}, {"a", 3, 3}} When I use: Sort[data] I get the list ordered in incremental order first with column 1 then by 2 and last by the third. Suppose I want the first column in increasi...
To sort your data in the desired order (first column in increasing order, second column in decreasing order, and third column in increasing order), you can use `SortBy` with a custom sorting key. In Mathematica, you can achieve this by specifying a sort key for each element in your data. You can represent the second ...
[ { "from": "human", "value": "I have some data:\ndata={{\"a\", 1, 1}, {\"a\", 1, 2}, {\"a\", 1, 3}, \n {\"c\", 2, 1}, {\"b\", 2, 2}, {\"b\", 2, 3}, \n {\"c\", 3, 1}, {\"a\", 3, 2}, {\"a\", 3, 3}}\n\nWhen I use:\nSort[data]\n\nI get the list ordered in incremental order first with column 1 then by 2...
Possible Duplicate: Point Renderings Slightly Off in Mathematica I'm using the ErrorListPlot function in the ErrorBarPlots package. I want to display markers and the error bars, however, the marker appears to be shifted slightly to the left of the error bars. I'm not sure which is actually at the correct position. I...
This is a common issue when using `ErrorListPlot` in Mathematica, where the markers might appear misaligned with the error bars. The confusion often arises from how the markers and error bars are drawn relative to the data points. In the version you are using, the markers are typically drawn at the point specified (in...
[ { "from": "human", "value": "\nPossible Duplicate:\nPoint Renderings Slightly Off in Mathematica \n\nI'm using the ErrorListPlot function in the ErrorBarPlots package. I want to display markers and the error bars, however, the marker appears to be shifted slightly to the left of the error bars. I'm not sure...
According to the Mathematica help: Round rounds numbers of the form x.5 toward the nearest even integer. For example: Round[{0.5, 1.5, 2.5, 3.5, 4.5}] gives {0, 2, 2, 4, 4} What's the rationale behind this? Why not the usual x.5 always rounds up?
The rounding method used in Mathematica (and many other programming environments) is known as "bankers' rounding" or "round half to even." The rationale behind this approach is primarily to minimize bias in rounding over a large dataset. Here are a few key points explaining the reasoning: 1. **Bias Reduction**: If yo...
[ { "from": "human", "value": "According to the Mathematica help: \n\nRound rounds numbers of the form x.5 toward the nearest even integer.\n\nFor example:\nRound[{0.5, 1.5, 2.5, 3.5, 4.5}]\n\ngives\n{0, 2, 2, 4, 4}\n\nWhat's the rationale behind this? Why not the usual x.5 always rounds up?\n" }, { ...
I've been noticing something strange since updating to Mathematica 8, and that is that occaisionally I'll see that the MathKernel is using up to 800% CPU in my Activity Monitor on OS X (I have 8 cores). I have no Parallel calls whatsoever, and this is in a single kernel, not across multiple kernels. My code is pretty m...
Yes, it's indeed possible that some built-in Mathematica routines can leverage parallelism under the hood, even if you are not explicitly using any parallel constructs like `ParallelMap`, `ParallelTable`, or `ParallelDo`. This feature has been increasingly integrated into Mathematica, especially in later versions, wher...
[ { "from": "human", "value": "I've been noticing something strange since updating to Mathematica 8, and that is that occaisionally I'll see that the MathKernel is using up to 800% CPU in my Activity Monitor on OS X (I have 8 cores). I have no Parallel calls whatsoever, and this is in a single kernel, not acr...
Assume that I know a package's (Context?) name that is loaded. Now I want to list the functions defined in this package. How can I do it? I remember that I found a way once, but I cannot re-find it. I tried some combinations with ? but for vain.
In R, you can use the `ls` function in combination with the `getNamespace` function to list the functions defined in a particular package. Here's how you can do it: 1. Load the package (if not already loaded) using `library()`. 2. Use `ls` on the package's namespace to get the list of functions. Here’s a step-by-step...
[ { "from": "human", "value": "Assume that I know a package's (Context?) name that is loaded. Now I want to list the functions defined in this package. How can I do it?\nI remember that I found a way once, but I cannot re-find it. I tried some combinations with ? but for vain.\n" }, { "from": "gpt", ...
Ask to compute the convolution of 2 lists, I managed to do so, with what I feel is rather heavy : Let my 2 lists be : a = {1,2,3,4} b = {1,1,1,1,1,1}; The below function adds 0s on each part of one list given the Length of the other bpad[listA_, listB_] := Flatten@{ Table[0, {Length@listA - 1}], l...
You have a good start with your convolution implementation! Here are a few improvements that can make your code cleaner and more efficient: ### 1. Avoid Manual Padding Instead of creating a padding function with explicit zeros, you can use built-in functions like `PadLeft` and `PadRight` which are optimized for these ...
[ { "from": "human", "value": "Ask to compute the convolution of 2 lists, I managed to do so, with what I feel is rather heavy : \nLet my 2 lists be :\na = {1,2,3,4}\nb = {1,1,1,1,1,1};\nThe below function adds 0s on each part of one list given the Length of the other\nbpad[listA_, listB_] :=\n Flatten@{\n ...
Say I have a matrix m and a vector v. v = {a[1], a[2], a[3], a[4]}; m={{a[1,1],a[1,2],a[1,3],a[1,4]}, {a[2,1],a[2,2],a[2,3],a[2,4]}, {a[3,1],a[3,2],a[3,3],a[3,4]}, {a[4,1],a[4,2],a[4,3],a[4,4]}}; What is the most efficient way to add v to the rows of m to create... mrow={{a[1],a[2],a[3],a[4]}, {a[1,1],...
To achieve your goal of adding a vector `v` to the rows and columns of a matrix `m` efficiently in a programming environment like Mathematica (Wolfram Language), you can use a couple of different approaches. However, from your tests, you want to prioritize performance when working with larger matrices. ### Adding `v`...
[ { "from": "human", "value": "Say I have a matrix m and a vector v.\nv = {a[1], a[2], a[3], a[4]};\n\nm={{a[1,1],a[1,2],a[1,3],a[1,4]},\n {a[2,1],a[2,2],a[2,3],a[2,4]},\n {a[3,1],a[3,2],a[3,3],a[3,4]},\n {a[4,1],a[4,2],a[4,3],a[4,4]}};\n\nWhat is the most efficient way to add v to the rows of m to crea...
Consider the following list of countries which I would like to highlight on a world map: MyCountries={"Germany","Hungary","Mexico","Austria","Bosnia","Turkey","SouthKorea","China"}; From the documentation center (Country Data > Applications > Application 5), I know that Graphics[{If[CountryData[#, "AntarcticNations"],...
It looks like you're trying to use `CountryData` to highlight specific countries on a world map. In your approach, you're trying to directly replace `"AntarcticNations"` with `MyCountries`, but this will not work because `MyCountries` is a set of countries and doesn't match the expected argument type. To highlight the...
[ { "from": "human", "value": "Consider the following list of countries which I would like to highlight on a world map:\nMyCountries={\"Germany\",\"Hungary\",\"Mexico\",\"Austria\",\"Bosnia\",\"Turkey\",\"SouthKorea\",\"China\"};\n\nFrom the documentation center (Country Data > Applications > Application 5), ...
Is there a good way to transform syntax from other computer algebra systems or from latex to mathematica syntax?
Yes, there are several approaches you can take to transform syntax from other computer algebra systems (CAS) or LaTeX to Mathematica syntax: 1. **Manual Translation**: This is the simplest method, where you manually convert the syntax based on your understanding of both systems. For example, you can convert mathematic...
[ { "from": "human", "value": "Is there a good way to transform syntax from other computer algebra systems or from latex to mathematica syntax?\n" }, { "from": "gpt", "value": "Yes, there are several approaches you can take to transform syntax from other computer algebra systems (CAS) or LaTeX to ...