- Re: Import polynomial from file and define function from
Use Set rather than SetDelayed F[q_, x_] = poly; Bob Hanlon ============= Hello Mathematica community, I am looking for a solution of the following problem: I have some quite long polynomial in q and x stored in a file and with test = Import["this_file_containing_t he_polynomial"]; I import the string and with - Re: coordinates in LogLogPlots
f[x_] = 700*x^-0.4; Manipulate[ LogLogPlot[f[x], {x, 100, 10^6}, Frame -> True, PlotRange -> {{10, 10^6}, {1, 100}}, Epilog -> { Disk[ {Log[10^n], Log[f[10^n]]}, r]}], {{n, 3}, 2, 6, .1, Appearance -> "Labeled"}, {{r, .25}, 0.1, 1, .05, Appearance -> "Labeled"}] Bob Hanlon ============= - Difficult constrained optimization problem
I'm optimizing a function subject to some constraints, and both FindMinimum and NMinimize fail. I suspect the difficulty is caused by the fact that if first constraint is violated, the second constraint becomes invalid (it'll be an invalid comparison between Complex and Real), can anyone suggest a way around it? - Using ChartStyle
I'm plotting a histogram and I'd like for the bars to be gray with no edges. I tried several combinations: ChartStyle -> {Gray, EdgeForm[None]} ChartStyle -> {EdgeForm[None], Gray} ChartStyle -> {{EdgeForm[None]}, {Gray}}, etc but in each case, only the first directive is implemented (e.g., the bars are gray with edges for the first option). - Difficulties with LocatorPanel
Hi All, I've been struggling to implement a locator, located at {1,0} that rescales the x-axis by stretching/shrinking. I want to use LocatorPane rather than Locator because I eventually to add another half-dozen locators that have different behaviors and appearance. The solution in LocatorPane would work more or less like the following - Using 'Module' inside 'Compile'
While I've worked with Mathematica for quite some time, I'm first learning the Compile function. Keeping it brief... Compile the function... f1 = Compile[{}, Module[{x, temp}, x = 4.; If[3 > 2, temp = x; Print["temp in 'if' statement: ", temp]]; Print["temp outside 'if' statement: ", temp]; - Re: 2 dimensional engineering problem
In article , This is a classic problem in the design of cams, the cartoon heart being the cam and the little wheel (roller) being the cam follower. One can certainly use Mathematica for cam design, but unless your friend understands the mathematics of cam design, or wants to learn, he may be happier - Re: coordinates in LogLogPlots
In article , Alessandro wrote: What often works in such situations is to use Log to transform into the underlying coordinate system of the plot. So, your example would become (but I didn't test it): Show[LogLogPlot[700*x^-0.4, {x, 100, 10^6}, Frame -> True, ... , - Re: coordinates in LogLogPlots
Alessandro, The main confusion arises because the underlying plot coordinates are in natural Log, but the tick labeling is in Log base 10. Here is a plot done using Presentations. It wasn't clear to me where you actually wanted the Disk so I just put it near the curve and near the center. I used a number formatting routine for simple labels on the x ticks. - Re: coordinates in LogLogPlots
Try something like: Epilog -> {Disk[Log@{100, 10}, .1]} to produce a disk centered at {100, 10}. If the oblong shape of the disk is a problem, you can use something like: Epilog -> {Disk[Log@{100, 10}, 0.1 {GoldenRatio, 1}]} instead. Carl Woll Wolfram Research - Re: Import polynomial from file and define function
Hi, maybe it helps when you have a function which does all that stuff for you by taking either a filename or a polynomial as string and the symbols you want to assign: SetAttributes[makePolynomial, HoldRest]; makePolynomial::invpar = "An error occured parsing the input \ string or in creating the polynomial."; - Re: Import polynomial from file and define function from it.
Example: (* Exporting the formula *) Export["test.txt", "F[x_,y_]:=3*x^2+x*y+3"] (* Importing data *) ToExpression[Import["test.txt" ]] Now you can use F: F[2,3] 21 - Re: coordinates in LogLogPlots
Neverminding the typos, it works here, so you'll have to be more specific. The Disk is stretched into an ellipse, but that's to be expected since you've chosen a plot range (log-log or not) that has an aspect ratio different from unity. - Re: List of multiple elements
I agree that if speed matters then any code using Split@Sort[...] should be reconsidered. In the present case the determiners seem to be the length of the list, the number of different values in it, and the user's requirements regarding the ordering of the results. If ordering does not matter then dup3 will be faster for longer lists - Re: coordinates in LogLogPlots
Hi Allesandro, It seems that Epilog is kept outside the coordinate system used for the loglogplot. If you take the Log (base E) of the coordinates in the Epilog graphics they end up in the correct location. Of course, a disk is not going to look good in loglog plots. Perhaps you could use points or so. - Re: Working with Log
To summarize the responses, there are two solutions: 1: Tell mathematica that the arguments are positive numbers: FullSimplify[2 Log[a] + 3 Log[b], Assumptions -> {a > 0, b > 0, c > 0}] Log[a^2 b^3] 2: Use a replacement rule 2 Log[a] + 3 Log[b] //. a_ Log[b_] + c_ Log[d_] -> Log[b^a d^c] Log[a^2 b^3] - Another question on ParallelDo
Hi All! I'm a noob using parallelizing tools in mathematica. However, the time this problem takes in one kernel, make me think about this possibility. So, this is the simplified code. SetSharedVariable[lista1, lista] ParallelDo[Do[Seen = RandomReal[{0, 100}, Num]; Expected = RandomReal[{0, 100}, Num]; - Re: Weighted graphs with sum of weights determining vertex placement?
Thanks Sjoerd, This was a really good suggestion. It turns out, though, that some of the lesser-known options to the function do the trick, namely the "RepulsiveForcePower" and "StepLength" suboptions to Method -> "SpringElectricalEmbedding" . Using a construction like the below gave good results for q = -0.6 and - Re: List of multiple elements
/@v]] I'm pretty sure the solution I posted above is the fastest unless more assumptions are made. Most of the solutions listed require multiple searches over the elements or require sorting neither of which are necessary. dup3[v_] := Join @@ (ConstantArray[#1, #2 - 1] & @@@ Tally[v]); v = RandomInteger[{1, 100}, 10000000]; - Re: Weighted graphs with sum of weights determining vertex placement?
With the total weigths in the list sums (sums = Total /@ rawnums) I suppose various constructions like VertexCoordinateRules -> ((Max[sums] - sums) ({Cos[#], Sin[#]} & /@ Table[i, {i, 0, 2 \[Pi] - 2 \[Pi]/8, 2 \[Pi]/8}])) or VertexCoordinateRules -> ((8 - Ordering[Ordering[sums]]) ({Cos[#], Sin[#]} & /@ - Re: FindRoots?
Mathematica's Reduce can do this (in the case of complex analytic functions, which covers most important practical cases) since version 7. I have posted examples of this several times, but somehow nobody seems to notice and we keep reading strange remarks like the above. Well, I don't want it to sound like I am trying to diminish Ted's achievement, but quite frankly, from the mathematical point of view, the methods used in the RootSearch package are rather primitive, relatively to the current state of knowledge in this field, of course. Not only does Reduce solve most transcendental equations much faster but it also does not require setting the values of any options by hand, and, what I think is most important, the results thus obtained are provably correct, which is not the case with Ted's package. In fact, much more general methods of solving transcendental equations exist (in general the functions need not be analytic and can involve systems of n-real equations in n-variables with non-vanishing Jacobian). An example of such a method can be found in one of my demonstrations on the demonstrations site (the algorithm can easily be converted to a practical method for real life probl ems. - Re: FindRoots?
Three comments: 1) This appears to arise from new capabilities added to Root in Version 7, capabilities that may have slipped under the radar screen of many users, certainly under mine. 2) Nice work! 3) WRI can't provide a specific command for everything and often users will have to add their own definitions, but 1-dimensional root searching of real - Re: FindRoots?
Perhaps. But note that: sols = N[Reduce[Sin[1/x] == 0 && 10^-4 < x < 10^-3, x], 10]; // Timing {2.88873,Null} Length[List @@ sols] 2865 So what do you need RootSearch for? Andrzej Kozlowski - coordinates in LogLogPlots
my fault without doubt, I keep on banging my head against the surreal coordinate usage in Mathematica. Currently I am trying to place a Disk[] in the Epilog section of a LogLogPlot - using as disk coordinates the plot coordinates - and I see that it doesnt work, I dont know why. Show[LogLogPlot[700*x^-0.4, {x, 100, 10^6}, Frame -> True, PlotRange - - Re: Plot of (2 x^2 - x^3)^(1/3)
On 8=E6=9C=8831=E6=97=A5, =E4=B8=8B=E5=8D=884=E6=99=8227 =E5=88=86, Peter s Unprotect[Power]; Power[x_?Negative, Rational[p_, q_?OddQ]] := (-(-x)^(1/q))^p; Protect[Power]; Plot[(2 x^2 - x^3)^(1/3), {x, -1, 3}] - Re: FindRoots?
Now that Daniel has shown the way here is a slightly reformulated form of his routine that provides a single convenient command that should handle most cases. The precision of the real variables in the calculation can be specified. I don't know if the Reduce options would ever come into play here, but I allowed for them. I also allowed control of messages from Reduce - Import polynomial from file and define function from it.
Hello Mathematica community, I am looking for a solution of the following problem: I have some quite long polynomial in q and x stored in a file and with test = Import["this_file_containing_t he_polynomial"]; I import the string and with poly = ToExpression[test]; I convert it to an expression. If I usually would like to define a - 2 dimensional engineering problem
Hi all, I have a friend in a manufacturing business who, I think, needs Mathematica to solve a problem. Could anyone here tell me if the following is possible and perhaps if they would be interested in taking on the project for a fee? Here's the problem... It is purely 2 dimensional cam-follower type - Re: find selected function / F1
In article , It may be easier to uninstall and reinstall Mathematica. Joe Gwinn - Re: syntax-aware selection in palette notebook
Yes, of course that's what one wants to do. Unfortunately, as my original message stated, I did _not_ have the source for the palette, just the resulting palette itself. - fit with cdf of skew normal distriubtion
Hi, to am trying to fit the integral of the skew normal distribution to a set of data. xhis is my fit function: upperlimit[x_, y0_, p2_, a_] = p2 (1 - (x/y0)^(1/a)); f[x_, y0_, a_, p2_, s_, skew_, A_, b_, p_] := b - 2 A NIntegrate[ PDF[NormalDistribution[p, s], x] CDF[ NormalDistribution[p*skew, s], (skew*x)], {x, -100, - Re: Working with Log
try: In[1]:= FullSimplify[Log[a]+Log[b],a>0 Out[1]= Log[a b] Peter - Re: Plot of (2 x^2 - x^3)^(1/3)
Hi Bernard, maybe you want Plot[Root[#^3-(2 x^2-x^3)&,1]//Re,{x,-1,4}] ? Peter - Re: Working with Log
PowerExpand[Log[a b c]] log(a)+log(b)+log(c) % //. Log[x_] + Log[y_] -> Log[x*y] log(a b c) Bob Hanlon ============= I can use PowerExapnd to expand a Log: PowerExpand[Log[a b]] Log[a] + Log[b] How can I do the opposite, i.e. combine Log[a] + Log[b] into Log[a b]? Thanks Themis - Re: List of multiple elements
dupels1 is twice as fast as dupels2. dupels1[v_List] := Module[{f}, f[x_] := ((f[x] = x); {}); Flatten[f/@v]] {m,n} = {50,1*^4} Timing[w = Table[Random[Integer,{1,m}],{n }]; Do[Null,{1*^7}]]; First@AbsoluteTiming[t1 = dupels1[w];] First@AbsoluteTiming[t2 = dupels2[w];] - Re: Working with Log
PowerExpand treats its expressions assuming all variables are positive. Normally Log[ab]==Log[a]+Log[b] is not always tru, e.g. 0=Log[(-1)(-1)]!=Log[-1]+Log[- 1]==2Pi I So you have to declare the variables as positives (if your domains are right): In[1]:= Simplify[Log[a]+Log[b], Assumptions->a>0&&b>0] - Re: Numerical solution of coupled nonlinear PDEs
Dominic, eqn = { D[a[t, y], t] == D[a[t, y], {y, 2}] + a[t, y] D[x[t, y], {y, 2}] + D[x[t, y], y] D[a[t, y], y], D[b[t, y], t] == D[b[t, y], {y, 2}] - b[t, y] D[x[t, y], {y, 2}] - D[x[t, y], y] D[b[t, y], y], D[D[x[t, y], {y, 2}] == b[t, y] - a[t, y], t]} mysol = NDSolve[{{eqn}, - Is it possible?
Hi Mathematica community, is Mathematica able to find a transitif superset of a given set S ? S is of the form (a && b && c ...) || (d && e && f ...) || ... such as a,b,c,d,e,f,... are equations. Thank you. - Re: i get an empty figure when exporting it, if I keep
Andy & Mirela, I can confirm that the graphic file is empty in the code given by Mirela (you have to plot something that spans the negative axes -- see example below). This is the case whether you Export into a file (pdf or eps), copy/paste to another application, or copy to clipboard and transfer to preview.app with command-N. But if you print the whole notebook into a pdf, the graphic is included. - Weighted graphs with sum of weights determining vertex placement?
Dear all, Suppose I have a weighted adjacency matrix like this: rawnums={{0, 43, 25, 70, 92, 75, 83, 69}, {0, 0, 0, 0, 0, 0, 0, 2}, {6, 28, 0, 1, 0, 3, 0, 3}, {26, 1, 2, 0, 4, 1, 7, 14}, {0, 2, 1, 0, 0, 1, 0, 0}, {7, 18, 60, 0, 1, 0, 2, 10}, {49, 2, 2, 6, 3, 7, 0, 1}, {12, 5, 10, 23, 0, 13, 7, 0}} - Re: FindRoots?
True, Sin[1/x] will eventually break any root finding algorithm because we will always run out of time or space to store the answers if we push too close to zero. However, this does provide a good example to show how well Ted's algorithm works. In this case the exact roots are 1/(n Pi) where n is a positive - Re: scienceworld.wolfram.com
e That's interesting, a good chunk of the categories aren't implemented yet... I guess this is working towards a library/mine of simple systems that Wolfram talks about. - Re: Working with Log
Note that Log[a] + Log[b] does not always equal Log[a b], that being said... Just write some replacement rules logRep = x_. Log[a_] + y_. Log[b_] :> Log[a^x b^y] Then, e.g. In[2]:= y Log[2]+Log[x^2]-Log[z] Out[2]= y Log[2]+Log[x^2]-Log[z] In[3]:= %//.logRep Out[3]= Log[(2^y x^2)/z] Simon - Re: Working with Log
Hi, Themis, one idea may be as follows. Introduce two functions for expansion and to collect logarithms: expandLog[expr_] := Module[{rule1, rule2, a, b, x}, rule1 = Log[a_*b_] -> Log[a] + Log[b]; rule2 = Log[a_^x_] -> x*Log[a]; (expr /. rule1) /. rule2 ]; collectLog[expr_] := Module[{rule1, rule2, a, b, x}, - Re: Could you prove this proposition:the i-th prime gap p[i+1]-p[i]<=i
Now, I can prove that p[i+1]-p[i]<=i. please visit [link][i+1]-p[i]<=i.nb - Re: "Abort Evaluation" does not work
I would really appreciate having a Front End abort command as well. If the kernel can be aborted I can't see a reason why the Front End couldn't be either. FE: Just drop everything you're doing, don't display any new stuff, just give me the prompt line ASAP. Cheers -- Sjoerd - Re: Working with Log
Hi, there's no unexpand but to know that PowerExpand uses heavy assumptions per default is useful. This should be a warning too that the results of PowerExpand not in general true. See for instance what PowerExpand[Log[a b], Assumptions -> Element[{a, b}, Complexes]] gives: 2*I*Pi*Floor[1/2 - Arg[a]/(2*Pi) - Arg[b]/(2*Pi)] + Log[a] + - Re: find selected function / F1
Has this always been the case or did it just start after years of good service? If so, did something change on your system? Did you move Mathematica files, edit init files? Do you encounter other strange things, crashes etc.? On Aug 28, 1:02 pm, Sander van den Berg wrote: - Re: Working with Log
Assuming[{a > 0, b > 0}, Simplify[Log[a] + Log[b]]] Cheers -- Sjoerd - Re: Can I programming little applications by Mathematica, just like Java
yes (depending on your definition of "just like"). You will always need Mathematica itself or Mathematica player to run them, but Java also needs a runtime. Cheers -- Sjoerd |