wolfram-mathematica

smallest integer not obtainable from {2,3,4,5,6,7,8} (Mathematica)

隐身守侯 提交于 2019-12-04 03:32:15
I'm trying to solve the following problem using Mathematica: What is the smallest positive integer not obtainable from the set {2,3,4,5,6,7,8} via arithmetic operations {+,-,*,/} , exponentiation, and parentheses. Each number in the set must be used exactly once. Unary operations are NOT allowed (1 cannot be converted to -1 with without using a 0, for example). For example, the number 1073741824000000000000000 is obtainable via (((3+2)*(5+4))/6)^(8+7) . I am a beginner with Mathematica. I have written code that I believe solves the problems for the set {2,3,4,5,6,7} (I obtained 2249 as my

What is the simplest way to constraint a built-in function's output in Mathematica? say let Sin returns only odd numbers?

ぐ巨炮叔叔 提交于 2019-12-04 03:21:07
For example, for a built-in function in Mathematica, f, originally f[1] gives {1,2,3}, but I want to let Mathematica gives only {1,3}. A simple method for rewritting f is desired. I don't want to define a new function or totally rewrite f or just dealing with original f's outputs. I want to rewite f. Thanks. :) Alexey Popkov You can use the Villegas-Gayley trick for this. For the Sin function: Unprotect[Sin]; Sin[args___]/;!TrueQ[$insideSin]:= Block[{$insideSin=True,result}, If[OddQ[result=Sin[args]],result] ]; Protect[Sin]; {Sin[Pi],Sin[Pi/2]} ==> {Null,1} I prefer a method which is

Return elements of the Groebner Basis as they are found

↘锁芯ラ 提交于 2019-12-04 03:16:51
This question could refer to any computer algebra system which has the ability to compute the Groebner Basis from a set of polynomials (Mathematica, Singular, GAP, Macaulay2, MatLab, etc.). I am working with an overdetermined system of polynomials for which the full groebner basis is too difficult to compute, however it would be valuable for me to be able to print out the groebner basis elements as they are found so that I may know if a particular polynomial is in the groebner basis. Is there any way to do this? If you implement Buchberger's algorithm on your own, then you can simply print out

Firewall settings for remote kernel to work (Mathematica)

Deadly 提交于 2019-12-04 02:41:44
What firewall settings must be used on the remote machine for a remote kernel connection to work? In particular I'm interested in connecting from Windows (front end) to a Linux machine (kernel). I don't know the exact ports, but this is a generic way to solve most such firewall issues: (at least with connections using TCP) Try to use the 'netstat -n' command and see which remote ports do the connections that are being blocked by the firewall use. They should be in the SYN_SENT state or something similar. Then on the remote machine open those ports and try to repeat this process until it works.

An efficient code to determine if a set is a subset of another set

跟風遠走 提交于 2019-12-04 01:43:09
I am looking for an efficient way to determine if a set is a subset of another set in Matlab or Mathematica. Example: Set A = [1 2 3 4] Set B = [4 3] Set C = [3 4 1] Set D = [4 3 2 1] The output should be: Set A Sets B and C belong to set A because A contains all of their elements, therefore, they can be deleted (the order of elements in a set doesn't matter). Set D has the same elements as set A and since set A precedes set D, I would like to simply keep set A and delete set D. So there are two essential rules: 1. Delete a set if it is a subset of another set 2. Delete a set if its elements

Problems interpreting input cell box expressions

与世无争的帅哥 提交于 2019-12-04 01:26:15
How do I convert an arbitrary box specification extracted from a cell expression into an input expression? This came up as a problem with my answer to Save Mathematica code in FullForm syntax . In that context, pattern matching was being used to extract box specifications from notebook expressions read using Import . I thought that ToExpression or MakeExpression would do the job of box interpretation, but in some circumstances they do not. Consider an input cell that contains the expression: StringForm["a = ``", 1] The cell expression for such a cell looks like this: Cell[BoxData[ RowBox[{

Proper way to simplify integral result in Mathematica given integer constraints

风格不统一 提交于 2019-12-04 00:05:39
Evaluating the following integral should be non-zero, and mathematica correctly gives a non-zero result Integrate[ Cos[ (Pi * x)/2 ]^2 * Cos[ (3*Pi*x)/2 ]^2, {x, -1, 1}] However, attempting a more general integral: FullSimplify[ Integrate[Cos[(Pi x)/2]^2 Cos[((2 n + 1) Pi x)/2] Cos[((2 m + 1) Pi x)/2], {x, -1, 1}], Element[{m, n}, Integers]] yields zero, which is definitely not true for m = n = 1 I'd expect a conditional expression. Is it possible to "tell" mathematica about my constraints on m and n before the integral is evaluated so that it handles the special cases properly? rcollyer While

Mathematica execution-time bug: symbol names

丶灬走出姿态 提交于 2019-12-04 00:01:59
There is a strange bug that has been in Mathematica for years, at least since version 5.1, and persisting through version 7. Module[{f, L}, L = f[]; Do[L = f[L, i], {i, 10^4}]] // Timing {0.015, Null} Module[{weirdness, L}, L = weirdness[]; Do[L = weirdness[L, i], {i, 10^4}]] // Timing {2.266, Null} What causes this? Is it a hashing problem? Is it fixed in Version 8? Is there a way to know what symbol names cause a slowdown, other than testing? Daniel Lichtblau What causes this? Is it a hashing problem? Yes, more or less. Is it fixed in Version 8? Yes (also more or less). That is to say, it is

Equation Threading: Why the default behavior?

喜你入骨 提交于 2019-12-03 23:39:55
I recently rediscovered a small package by Roman Maeder that tells Mathematica to automatically thread arithmetic and similar functions over expressions such as x == y. Link to Maeder's package. First, to demonstrate, here's an example given by Maeder: In[1]:= Needs["EqualThread`"] Now proceed to use the threading behavior to solve the following equation for x 'by hand': In[7]:= a == b Log[2 x] In[8]:= %/b Out[8]:= a/b == Log[2 x] Now exponentiate: In[9]:= Exp[%] Out[9]= E^(a/b) == 2 x And divide through by 2: In[10]:= %/2 Out[10]= (E^(a/b))/2 == x Q: From a design perspective, can someone

Generating table of contents

两盒软妹~` 提交于 2019-12-03 21:50:27
I posted this one a couple of months ago on the Mathematica newsgroup, but got no usable response. I thought I'd give SO a try. The question was: I don't seem to be able to find the method to generate the table of contents of a Mathematica document I'm working on. Anyone knows this feauture's hideout? David Annetts pointed me in the direction of the AuthorTools, an old v5.1 utility package that's still hidden in Mathematica. However, it doesn't work on my document (v7). Any clue? Edit The TOC should contain correct section numbers (if present in the stylesheet) and list page numbers (this