New answers tagged

2

This is more of an extended comment. The setting of the weights depends on what structure you want for the error term. For example, suppose you have the linear model $$y=a+b x + x \epsilon$$ where $a$ and $b$ are the respective intercept and slope, $x$ is the predictor variable and $\epsilon \sim N(0,\sigma^2)$. The weights you want are $1/x^2$. This ...


6

Looking at the internal structure of the compiled functions, we can see a distinct call to an integer-valued function Log2 of an integer argument. There is also one for a real-valued function Log2 of a real argument. The first example I think shows that the integer Log2 is intentional. There are similar special integer functions for Log10, Power, Gamma and ...


3

A DensityPlot helps in picking good starting values for FindMaximum: DensityPlot[ 1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, -5, 5}, {u, -5, 5}, PlotRange -> All, PlotPoints -> 50, PlotLegends -> Automatic] Then using the aproximate values from the DensityPlot FindMaximum locates one of the points FindMaximum[ 1/2*Abs[(o ...


1

your data is complex and ( I guess) the spline method cannot handle complex numbers. You can separately fit the real and imaginary parts like this: LTNOsplineRe = Interpolation[MapAt[Re, DiscreateLT, {All, 2}], Method -> "Spline"] LTNOsplineIm = Interpolation[MapAt[Im, DiscreateLT, {All, 2}], Method -> "Spline"] LTNOspline = Function[{x, y}, ...


2

As the error message says, EulerEquations takes only a single integrand, not a vector equation as you are trying to give it. Your Lagrangian looks like it should have two scalar terms, corresponding to kinetic energy terms, and a final potential term which is presumably supposed to be a scalar as well (but is currently a vector). At the moment, you are ...


0

If the data has the dimensions {n, 2} where n = Length[Range[ti, tf, dt]] things should work fine. Below is a minimal data set that has a length of 501. ti = 100; tf = 1600; dt = 3.; ndsol1 = ParametricNDSolve[{y'[x] == -k1*y[x] - k2*y[x]*y[x] - k3*y[x]*y[x]*y[x], y[ti] == 0.016470755}, y, {x, ti, tf}, {k1, k2, k3}] junk = y[0, 1.05, 1.05] /. ...


0

You may use Check and $MessageList. x = MapThread[Check[#1/#2, Last@$MessageList] &, {a, b}] (* {1/2, HoldForm[Power::infy], 3/40, 4/5, HoldForm[Power::infy]} *) Indices of errors can be obtained by: errs = Position[x, HoldForm[MessageName[__]]] (* {{2}, {5}} *) and extracted by: Extract[x, errs] (* {HoldForm[Power::infy], HoldForm[Power::infy]} *)...


5

Multiple formatting errors consisting of missing ->, incorrect capitalization and function definition. Take a look at LogLogPlot and Defining Functions. I also used PlotLabels to automatically associate labels with individual curves as opposed to the more manual method of Epilog. aa = {5*^-1, 5*^-2, 5*^-3, 5*^-4, 5*^-5}; n[k_, a_] := a k (3 + 6 k + 4 k^...


3

Another way (see How to catch complete error message information for more ways to hack messages): This works because i is effectively Block[]-ed by Do[]. badindices = {}; $MessagePrePrint = (AppendTo[badindices, i]; #) &; Do[Append[x, a[[i]]/b[[i]]], {i, 1, 5}] $MessagePrePrint = Automatic; badindices (* {2, 5} *) As function for running code: ...


3

In case you want to use Quiet and need to know which error messages were generated during the evaluation, you can use $MessageList. Starting from your code: Module[{errors = Internal`Bag[{}], mess, a, b, x}, a = {1, 2, 3, 4, 5}; b = {2, 0, 40, 5, 0}; x = {}; Block[{$MessageList = {}}, Do[ Quiet[ AppendTo[x, a[...


2

Check is the function supplied with Mathematica for doing what you request. Here is how it can be used in your situation. a = {1, 2, 3, 4, 5}; b = {2, 0, 40, 5, 0}; Quiet @ Module[{errs = {}, vals}, vals = Table[Check[a[[i]]/b[[i]], AppendTo[errs, i]; Nothing], {i, 5}]; {vals, errs}] {{1/2, 3/40, 4/5}, {2, 5}}


6

Here's one way to do it: a = {1, 2, 3, 4, 5}; b = {2, 0, 40, 5, 0}; x = Quiet[Table[a[[i]]/b[[i]], {i, 1, 5}]]; Position[x, ComplexInfinity] {{2}, {5}} Basically, ans contains the values plus the errors, which in this case are ComplexInfinity. You can locate the errors using Position, in this case, at positions 2 and 5. If you want to check for any old ...


3

Avoid using capital letters as variables so that they don't conflict with Mathematica's existing definitions/functions (here "N" was part of the problem). There were some erroneous underscores as well, used when referencing a function from another function. rd = 1; n = 5; pb = 1; c[α_, r_, x_] := x^2 - x^2*Hypergeometric2F1[1, 2/ α, 1 + 2/ α, -x^α/(β*r^α)]; ...


3

Do you mean rd = 1; n = 5; pb = 1; c[α_, r_, x_] := x^2 - x^2*Hypergeometric2F1[1, 2/α, 1 + 2/α, -x^α/(β*r^α)]; β = 3.1623; α = 4; p = Integrate[((c[α, r, rd] - c[α, r, r])/(rd^2 - r^2))^(n - 1)*2*n*r*(1 - r^2)^(n - 1), {r, 0, 1}] Integrate[10*r*(1 - 0.08904220055024259*r^2 - Hypergeometric2F1[1/2, 1, 3/2, -(0.31622553204945764/r^4)])^4, {r, 0,...


2

Here is code that makes the plot of 1st ReandIm` of the function without messages. Clear[f, "G*", ϕ] f[x_?NumberQ] := Exp[-(x - 5)^2] G1[b_?NumberQ, σ_, λ_] := 0 G2[b_?NumberQ, σ_, λ_] := (1/π) Sqrt[ b/σ] EllipticK[ Abs[(λ^2 - 4 (σ - b)^2)/(16 σ*b)]]; G3[b_?NumberQ, σ_, λ_] := (4/π)*((b)/(Sqrt[\ λ^2 - 4 (σ - b)^2])) EllipticK[ Abs[(16 σ*b)/(λ^2 ...


6

This is similar to the problem you get when you try to use an interpolating function inside a numeric integral, and the solution is similar: Define a helper function that only calls Part when the arguments are both integers: noise := RandomVariate[PoissonDistribution[10], {20, 20}]; noisefunc[i_Integer, j_Integer] := noise[[i, j]]; DiscretePlot3D[noisefunc[...


5

I think that that the key feature is to use the MaxExtraConditions option for the Solve command. In elaborate answer of Artes in here, a very very nice presentation is referred. It is entitled as Getting the Most from Algebraic Solvers in Mathematica by Adam Strzeboński. You can download the .cdf file of the presentation which is really helpful. Slide $10$ ...


3

Try the following: eq = Eliminate[{A*ra^B == fa, A*rb^B == fb}, A] Solve[eq, B] (* {{B->-(Log[fb/fa]/(Log[ra]-Log[rb]))}} *) and as you repeat this or do it by hand, please note that there are certain restrictions on the values. If you want to know what Maple did not tell you, try this Reduce[eq, B] and look at the conditions that need to be ...


3

First of all you need to update to FeynCalc 9, FC 8.2 is already outdated. Please use the development version: https://github.com/FeynCalc/feyncalc/wiki/Installation#dev_automatic_installation I'm not using FeynRules myself, but I have already been asked to make FeynCalc compatible with FeynRules+FeynArts and according to the user who needed this, ...


10

You can't do without good starting values: curve = FindFit[data, model, {{par1, 10}, {par2, -2}, {par3, -1}}, x] Show[ListPlot[data], Plot[model /. curve, {x, 7, 11}]] However, the residuals suggest that the assumed constant variance about the line is unwarranted (residuals are much larger for smaller values of "x") and there is overestimation for ...


1

You can avoid the use of global variables x and y altogether. data2 = {#, f[#]} & /@ Range[20, 60, 10]; Fit[data2, {1, x, x^2, x^3, x^4}, x] 322.355 - 23.0869 x + 0.68087 x^2 - 0.00924801 x^3 + 0.0000476869 x^4


3

Your problem stems from the fact that you are using x in two different roles, i.e. as a container for a list of values first, and then again as the independent variable in your Fit expression, where it should NOT have a value associated with it. You could Clear[x] before the Fit to fix that issue, but more generally your code can be simplified considerably....


3

For the sake of an answer: After several tries I have found that with Mathematica 10.4 and nvidia drivers 367.27 and upgrading to the latest CUDAResources paclet everythig is working ok – Javier Vales Alonso 2 days ago



Top 50 recent answers are included