# Tag Info

## Hot answers tagged homework

23

Mathematica wouldn't be much helpful if one applied only formulae calculated by hand. Here we demonstrate how to calculate the desired geometric objects with the system having a definition of the curve r[t] : r[t_] := {t, t^2, t^3} now we call uT the unit tangent vector to r[t]. Since we'd like it only for real parameters we add an assumption to Simplify ...

13

In Mathematica: Integrate[Integrate[x^2 + y^2, {x, -Sqrt[1 - y^2], Sqrt[1 - y^2]}], {y, -1, 1}] Or, shorter: Integrate[x^2 + y^2, {y, -1, 1}, {x, -Sqrt[1 - y^2], Sqrt[1 - y^2]}] The main trick is to calculate the bound on $x$ based on the current value of $y$, which is what you need to make the integration bounds explicit. Indeed, $x_{max}=\sqrt{1-y^2}$. ...

12

I assume (sorry if I'm being wrong) that this is some kind of homework. So I've written an answer as guidance. You'll have to work out some details. If your problem is three dimensional, you can write for example: dist[x0_,x1_] := (x0-x1).(x0-x1); power[x0_,x1_]:= c/dist[x0,x1]; findAnt[{{pow1_,pos1_},{pow2_,pos2_},{pow3_,pos3_}}]:= ...

12

You have some errors in your syntax: you name your lists x_sample and y_sample, but in Mathematica, an underscore is not allowed in names (as it is reserved to patterns). your last sum runs from 0, but in Mathematica, the first element in a List has index 1 your last sum should run until the number of data points, not 4 furthermore, I would advise you to ...

8

Observe that even when the tangent vector $r'(t)$ is not normalized, it is still a linear combination of $T(t)$ and $N(t)$. Thus--operating under the usual assumptions that $r'$ and $r''$ exist and are linearly independent--all we have to do is make an orthonormal frame out of $r'(t)$ and $r''(t)$ (which is very much in the spirit of the entire proceeding). ...

6

This is quite common a problem when doing nonlinear fit. As far as I know, the most general and effective solution for it is to give the fitted parameters a good enough start value, which you've already known for your specific problem: exp = c/(1 + ((c - n)/n)*E^(-r*t)); FindFit[points, exp, {{c, 256}, {n, 9}, r}, t] Show[Plot[exp /. %, {t, 7, 84}], ...

6

If you want to translate Matlab code into Mathematica, my advice is - don't! As programming languages, the two are very different and an idiom that works well in one is unlikely to work well in the other. A fundamental theorem theorem in discrete dynamics states that if there's an attractive orbit, then it must attract at least one critical point. Thus, ...

6

This is mainly an answer to your last question, but I think it will help with your other ones. I assume you know that the $T$ function is vector valued, and that is what you want. To substitute in a specific value of $t$, you probably want replacement rules, specifically the ReplaceAll (/.) construct. For example, if you had defined your expression $T(t)$ ...

5

I can say with certainty that, as of version 9, it is not possible to set the degrees of freedom for PearsonChiSquareTest. I recommend seeing my answer here for an implementation of your own test that allows you to bin your own data.

5

I'm not too good at graphs, but this seems straightforward. myAdjacencyMatrix = {{0, 3, 1, 3, 3, 8, 0, 0, 3, 4, 2}, {1, 0, 2, 0, 0, 16, 5, 3, 0, 6, 1}, {2, 3, 0, 0, 1, 1, 4, 1, 1, 0, 0}, {5, 3, 3, 0, 5, 0, 2, 2, 2, 2, 1}, {1, 0, 0, 6, 0, 1, 2, 6, 10, 2, 4}, {0, 11, 3, 0, 1, 0, 8, 3, 1, 3, 3}, {2, 4, 1, 7, 6, 7, 0, 6, 0, 8, 2}, {1, 2, 1, 3, 8, 4, 4, ...

5

The quick answer is: AntennaPower[measure_List, antenna_List] := Module[{x1,x2,xa,ya,sd2}, {x1, x2, sd1} = measure; {xa, ya} = antenna; N[ sd1*(4*Pi*((xa - x1)^2 + (ya - y1)^2)/1000)] ] The point here is that the first argument to Module can only be a sequence of symbols (or of assignments x=x0,y=y0,...) but no expressions are allowed. Just an ...

4

freddieknets already told you what you're supposed to be doing. Here's how I'd have done your approach to least squares: n = 4; f[x_] = Map[C, Range[0, n]].x^Range[0, n]; Solve[Thread[ D[Total[(ysample - f /@ xsample)^2], {Map[C, Range[0, n]]}] == 0], Map[C, Range[0, n]]] // First // Chop {C[0] -> 0, C[1] -> 10., C[2] -> 0, C[3] -> 0, ...

4

You can not assign to a list in local variable specification as You did {x1,x2,sd1}=measure. You can assign specific parts of dummy variables: AntennaPower[measure_, antenna_] := Module[{x1=measure[[1]], x2=measure[[2]], sd1=measure[[3]], xa=antenna[[1]], ya=antenna[[2]]}, N[sd1*(4*Pi*((xa - x1)^2 + (ya - y1)^2)/1000)] ] or use equivalent sebhofer's ...

4

If "diagnostics" or standard errors are required you can use NonlinearModelFit with the starting values: fun = c n/(n + (c - n) Exp[-r t]); nlm = NonlinearModelFit[points, fun, {{c, 256}, {n, 9}, r}, t] Visualizing fit: Show[ListPlot[points], Plot[nlm[t], {t, 0, 90}]] You can get model: nlm//Normal yielding 3213.19/(12.3092 + 248.73 E^(-0.0877072 ...

3

A heuristic way to narrow the search range is to assume that the common remainder is not too large, and hence that the ratios will not change by much. So set up three ratios for values minus remainder, and evaluate at remainder=0. fracs = Apply[Divide, Partition[vals - k, 2, 1, {1, -2}], {1}] nfracs = N[fracs /. k -> 0] (* Out[608]= {(1716 - k)/(2154 ...

3

You can use FindInstance[1716 == a1 k + r && 2154 == a2 k + r && 4271 == a3 k + r && a1 > 0 && k > 1, {a1, a2, a3, k, r}, Integers] or Reduce[1716 == a1 k + r && 2154 == a2 k + r && 4271 == a3 k + r && a1 > 0 && k > 1, {a1, a2, a3, k, r}, Integers] The first one ...

3

Here you have a boilerplate for coding the simulation. I've filled each function with a "reasonable random" behavior for a betting game that follows your experiment description. You should customize them to fit better your simulation needs. I can't infer from your question what are the random vars for your PDF, but the outcome from the function lets you get ...

3

Here is a direct approach: digitsum = Composition[Total, IntegerDigits]; stubbornQ = PrimeQ[#] && Nor @@ PrimeQ[digitsum[#] - {1, 2, 3, 0, -1}] &; i = 1; While[! stubbornQ[++i]] i 8999 This was quite sufficient in this case. For larger search spaces see Iterate until condition is met.

3

Select is wrong in this case, you can't use it to get the n-th element of a list without using additional helper functions. You'll get the most out of this exercise by looking at Part, which is a very flexible function for extracting elements out of a list based on their position, for example x = {1,1,2,3,5,8,13,21,34,55} (* Explicit syntax. Extracts the ...

2

Also, remember you can check your results with: ysample = {0, 1, 2, 3, 4, 5, 6, 7, 8} xsample = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8}(*Some sample data*) model = a x^3 + b x^2 + c x + d; fit = FindFit[data = Transpose@{xsample, ysample}, model, {a, b, c, d}, x] modelf = Function[{x}, Evaluate[model /. fit]] Plot[modelf[x], {x, 0, 1}, Epilog -> ...

1

z02 = 50*2^.5 z01 = 50 z1 = 100 zin = z02*(z1 + \[ImaginaryJ]*z02*Tan [w])/(z02 + \[ImaginaryJ]*z1* Tan [w]) gamma = (zin - z01)/(zin + z01) f := Abs[gamma] Plot[Abs[gamma], {w, 0, 6.28}] Note, you had z1 and zl (one vs lowercase L), and two functions incorrect.

1

There are a number of syntax errors. These include: tan w should be Tan[w] abs should be Abs Just using output 124 as the basis of the desired function whose modulus you wish to plot: g[w_] := (-50 + (70.7107 (100 + (0. + 70.7107 I) Tan [w]))/(70.7107 + 100 I Tan [ w]))/(50 + (70.7107 (100 + (0. + 70.7107 I) Tan[ ...

1

Is this what you're trying to do: Edit It's possible, as I was overly focused on the slightly rambling free-form input stylized as Mathematica code, that I neglected to read the actual point of the question - namely, I guess that you're expecting an explanation from WolframAlpha as to why the identity is true. I think that the short answer is that ...

1

Asking for help completing homework assignments is a sketchy subject. I'll help with hints, however a full solutions seems to be against the purpose of this site. As others have mentioned there is a built-in method for this Tally as for your own method, you are correct in that it won't work since it's only matching adjacent objects, you can fix this by ...

1

One of the nice things about Mathematica is that it supports many different styles of programming. I think your code has the aspect of more "traditional" code that one might write in a different programming language. Perhaps your code is correct in spirit, but it seems to me overly complicated and as written obviously is not okay because it throws a ...

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