How to handle bloat that comes with derivative ScriptableObjects?

I have ScriptableObjects with special code functions that all are slightly different in their interaction, all derived from one main ScriptableObject. This has lead to making the ScriptableObject script and then having to use the CreateAssetMenu attribute and then making the actual instance in the inspector. It creates a situation where I have two files bloating up the project, once I get many different derived ScriptableObjects it gets quite chaotic. How would I solve this?

Replace in a Symbolic Derivative doesnt work with Pi/2

I was writing some small functions for GR applications, and I was defining a Function that gives me the Geodesic equations. When testing if those worked with the Schwarzschild Metric I came upon a problem when trying to replace the angle $ \theta$ with $ \frac{\pi}{2}$ this then didn’t properly simplify it when there are derivatives of $ \theta$ .

I have made a simple example to showcase what my problem is:

Sum[D[xx[[i]][\[Tau]], \[Tau]], {i, 4}] /. t -> Pi/2 

This produces the following output:

$ \left(\frac{\pi }{2}\right)'(\tau )+x'(\tau )+y'(\tau )+z'(\tau )$

What can I do to either prevent this from happening or resolve this issue?

Rotational kinetic energy and derivative by velocity

I have some object with tensor of inertia $ I_{p_{3×3}}$ and angular velocty vector $ \omega$ .

Object’s kinetic energy find as:

$ T_p=\frac{1}{2} \omega^T I_{p} \omega$

I wand find derivative by $ \omega$ .

Is the result I am getting with this code correct?

Clear["Derivative"];  ClearAll["Global`*"];  Tp = 1/2 Transpose[\[CapitalOmega]].Ip.\[CapitalOmega];  D[Tp, \[CapitalOmega]]; 

EDIT:

Is that result correct ?

$ \frac{d}{d\omega}\frac{1}{2} \omega^T I_{p} \omega=\frac{1}{2}\omega^T(I_{p}+I_{p}^T)$

Dot product and “Encountered non-numeric value for a derivative at t == 0”

I was trying to solve a system of differential equations, and this worked:

vector = {f1[t],f2[t],f3[t]} equations = Flatten[Table[{D[vector[[i]], t] == vector[[i]]((matrix. vector)[[i]] - vector.PayoffMatrix.vector), (vector[[i]] /. t -> 0) == vectorT0[[i]]}, {i, Length[vector]}]] NDSolve[equations, vector, {t, 0, 30}] 

But if I add "." explicitly after vector[[i]]—it doesn’t:

vector = {f1[t],f2[t],f3[t]} equations = Flatten[Table[{D[vector[[i]], t] == vector[[i]].((matrix. vector)[[i]] - vector.PayoffMatrix.vector), (vector[[i]] /. t -> 0) == vectorT0[[i]]}, {i, Length[vector]}]] NDSolve[equations, vector, {t, 0, 30}] NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. 

What’s wrong here? (Mathematica 12.2)

How to calculate the derivative of the solution of ParametricNDSolveValue?

Consider the following code:

Sol = ParametricNDSolveValue[{e1'[t] == s e2[t], e2'[t] == -s e1[t],e1[0] == 1, e2[0] == 0}, {e1, e2}, {t, 0, 1}, s] fun[t_, s_] := Through[Sol[s][t]][[1]]; Plot[fun[t, 1], {t, 0, 10}] dfun[t_, s_] = Derivative[1, 0][fun][t, s] Plot[dfun[t, 10], {t, 0, 1}] 

The aim is to find and plot the derivative in t of fun, but I get the output:

s'[t] 

and a line along the x axis as a plot, which is the wrong solution.

How do I find the derivative of the solution of ParametricNDSolveValue?

EDIT To be clear: I need to keep s as a parameter, I know that if I write dfun[t_] = D[Through[Sol[1][t]][[1]], t] I can plot the deirvative, but I do not want to fix the value of s

Numerical value of Derivative of Dirichlet L function at some particular points

I want to find the numerical value for the derivative of Dirichlet L function to compare with an another formula. However I am not able to obtain any numerical values. I tried to use

f[s_]= DirichletL[5,2,s] f'[3] 

But this simply returns DirichletL^(0,0,1)[5,2,3]. If I use N[f'[3]] this gives: DirichletL:: Positive integer expected at position 1 in DirichletL[5.,2.,2.].

Can someone please help me out with this? Any help is highly appreciated.

Derivative of NDSolve output

I am trying to study the stability of a 2-dimensional discrete system (X, Y) by finding the Jacobian at the systems non-trivial equilibrium (X*, Y*). The functions that map the system from one iterate, n, to the next are given by the solutions to ordinary differential equations solved at time t = T

X(n+1) = f(x(T), y(T))

Y(n+1) = g(x(T), y(T))

where x(T) and y(T) depend on X(n) and Y(n).

Here is a MWE of the problem

sol[T_?NumericQ, a_, b_, c_, x0_?NumericQ, y0_?NumericQ] :=    NDSolve[{     x'[t] == x0 a - b *x[t]*y[t],     y'[t] == b*x[t]*y[t] - c y[t],     x[0] == 0, y[0] == y0},     {x, y}, {t, 0, T];  xmap[T_?NumericQ, a_, b_, c_, x0_?NumericQ, y0_?NumericQ] :=   x[T] /. sol[T, a, b, c, x0, y0] ymap[tt_?NumericQ, a_, b_, c_, h_, j_, x0_?NumericQ, y0_?NumericQ] :=   h (y[T] /. sol[T, a, b, c, x0, y0])/(1 +       j (y[T] /. sol[T, a, b, c, x0, y0])) 

where x0 and y0 are placeholders for X(n-1) and Y(n-1). Is it possible to take the partial derivatives of xmap and ymap w.r.t. x0 and y0? I tried this

D[xmap[5, 0.5, 0.25, 1, x0, 200], x0] /. x0 -> 100 

But it does not evaluate.

How do you get substitution to recognized a derivative?

I have a simple expression involving a derivative:

x[t_] = Q/T[t]; Simplify[Derivative[1][x][t] /. Q -> x T[t]] 

That produces:$ $ -\frac{x T'[t]}{T[t]}$ $ I have another relation: $ T=a^{-1}$ . When I make the substitution, I get this:

FullSimplify[-((x*Derivative[1][T][t])/T[t]) /. T[t] -> 1/a[t]] 

$ $ -x a[t] T'[t]$ $

But what I want is this: $ $ -\frac{x a[t]}{a'[t]}$ $ I know I can force the issue with an additional substitution of $ T'[t]=a'[t]^{-1}$ , but it seems to me that I’ve already given Mathematica everything it needs to make that substitution on it’s own. How do I force MMa to recognize this kind of substitution in the derivative?

Plot of the derivative of a function

I have a function functionSL as a function of t (t<0) where I want to find the extremum of the function and also find at which t it occurs. I took the derivative of functionSL with t which I wrote it as the function functionSLD.

d = 3; torootL[a_?NumericQ, t_?NumericQ, zl_?NumericQ, zh_?NumericQ] := a - NIntegrate[(zl y^d)/Sqrt[(1 - (zl/zh)^(d + 1) y^(d + 1)) (1 + t^2 (1 - (zl/zh)^(d + 1))^-1 - y^(2 d))], {y, 0, 1}, PrecisionGoal -> 6, Method -> "GlobalAdaptive"] zs[a_?NumericQ, t_?NumericQ, zh_?NumericQ] := zl /. FindRoot[torootL[a, t, zl, zh], {zl, 0.5, 0, 1}] intSL[a_?NumericQ, t_?NumericQ, zh_?NumericQ] := NIntegrate[With[{b = zs[a, t, zh]/zh}, (((-1)/(d - 1)) (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 zs[a, t, zh]^(2 d)) x^d ((1 - (b x)^(d + 1))/(1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 (zs[a, t, zh] x)^(2 d)))^(1/2) - ((b^(d + 1) (d + 1))/(2 (d - 1))) x ((1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 (zs[a, t, zh] x)^(2 d))/(1 - (b x)^(d + 1)))^(1/2) + (b^(d + 1)x)/((1 - (b x)^(d + 1)) (1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 (zs[a, t, zh] x)^(2 d)))^(1/2)], {x, 0, 1}, MinRecursion -> 20, MaxRecursion -> 20, AccuracyGoal -> 12, PrecisionGoal -> 10, Method -> {"GlobalAdaptive", "SingularityHandler" -> Automatic}] functionSL[a_?NumericQ, t_?NumericQ, zh_?NumericQ] := ((-((1 - (zs[a, t, zh]^(2 d) (1 + t^2 (1 - (zs[a, t, zh]/zh)^(d + 1))^-1))^-1 zs[a, t, zh]^(2 d)) (1 - (zs[a, t, zh]/zh)^(d + 1)))^(1/2)/(d - 1)) + intSL[a, t, zh] + 1)/(4 zs[a, t, zh]^(d - 1)) functionSLD[t_] := Evaluate[Derivative[0, 1, 0][functionSLL][0.01, t, 1]] 

I took some sample values of functionSLD for some t,

In[44]:= functionSLD[0]  Out[44]= -3.58024*10^-12  In[48]:= functionSLD[-10]  Out[48]= 0.15527  In[90]:= functionSLD[-15]  Out[90]= 0.0477369  In[91]:= functionSLD[-16]  Out[91]= 0.041289  In[93]:= functionSLD[-16.5]  Out[93]= 0.039934  In[59]:= functionSLD[-17] // Quiet  Out[59]= 0.0424448  In[60]:= functionSLLP[-17.5]  Power::infy: Infinite expression 1/0. encountered.  NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.  NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.  Power::infy: Infinite expression 1/0. encountered.  NIntegrate::izero: Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.  General::stop: Further output of NIntegrate::izero will be suppressed during this calculation.  Power::infy: Infinite expression 1/0. encountered.  General::stop: Further output of Power::infy will be suppressed during this calculation.  FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.  FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.  FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.  General::stop: Further output of FindRoot::lstol will be suppressed during this calculation.  FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).  FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).  FindRoot::jsing: Encountered a singular Jacobian at the point {zl} = {0.825567}. Try perturbing the initial point(s).  General::stop: Further output of FindRoot::jsing will be suppressed during this calculation.  In[61]:= functionSLD[-17.5] // Quiet  Out[61]= $  Aborted 

Image1

I expect functionSL to have an extremum for at least two values (looking only at t<0) so that functionSLD has at least two roots, I think I got one root at t=0 which is clear in the plot of $ \frac{dS}{dt}$ and it really confirms my expectations, the other is located somewhere else (it seems clear in the plot).

You can see that at t=0, functionsSLD = -3.58024*10^-12 which is essentially zero, as t goes to lower values functionSLD rises and then goes down again and it looks like it is going to be essentially zero again but as you can see at t=-17.5 I aborted the calculation (in the sample values of functionSLD) because it just takes so long and it seems like there is a problem.

In the end, what I want to see is a plot of functionSLD[t] vs. t ($ \frac{dS}{dt}$ ).

I would also like somebody to check my NIntegrate Rules if there is something wrong with it, or can it be improved. I added a singularity handler because an error occurred which I pasted in the above sample values code.

Derivative of a Definite Integral

I have two equations as follows,

$ $ a = \int_0^1 dx \frac{c z_s^{d+1} x^d}{\sqrt{(1-(z_s/z_h)^{d+1} x^{d+1})(1-c^2 z_s^{2d} x^{2d})}} \tag{1}\label{1},$ $

\begin{align} S &= \frac{1}{4 z_s^{d-1}}\Bigg(-\frac{\sqrt{(1-c^2 z_s^{2d})(1-b^{d+1})}}{d-1} – \frac{1}{d-1} c^2 z_s^{2d} \int^1_0 dx x^d \sqrt{\frac{(1-(b x)^{d+1})}{(1-c^2(z_s x)^{2d})}}\ & -\frac{b^{d+1}(d+1)}{2(d-1)} \int^1_0 dx x \sqrt{\frac{(1-c^2(z_s x)^{2d})}{(1-(b x)^{d+1})}}\ & + b^{d+1}\int^1_0 dx \frac{x}{\sqrt{(1-(b x)^{d+1})(1-c^2(z_s x)^{2d})}}\Bigg) \tag{2}\label{2} \end{align}

where $ c=c(z_s)$ is a function of $ z_s$ , while $ a$ (I can fix a value for this), $ z_h$ , $ d$ (dimension) are constants, also $ b=z_s/z_h$ .

My goal is to obtain an expression for $ S$ independent of $ c$ , the conditions that can help with this requirement are,

$ $ \frac{dS}{dz_s} = 0 \tag{3}\label{3},$ $

and $ \eqref{1}$ . From $ \eqref{1}$ and $ \eqref{2}$ , we can take the derivative with respect to $ z_s$ and impose $ \eqref{3}$ on the derivative of $ \eqref{2}$ so that we can get expressions involving $ c$ and $ \frac{dc}{dz_s}$ in both the derivatives of $ \eqref{1}$ and $ \eqref{2}$ , then eliminate both $ c$ and $ \frac{dc}{dz_s}$ .

However, I tried to do the typical way as in the documentation but it does not produce the result I want.

d = 3; Integrate[(c[zs] zs^(d + 1) x^d)/((1 - x^(d + 1) (zs/zh)^(d + 1)) (1 - c[zs]^2 (zs x)^(2 d)))^(1/2), {x, 0, 1}] D[Integrate[(c[zs] zs^(d + 1) x^d)/((1 - x^(d + 1) (zs/zh)^(d + 1)) (1 - c[zs]^2 (zs x)^(2 d)))^(1/2), {x, 0, 1}] == 0, zs]