2
$\begingroup$

I'm working on an educational project and new to Mathematica Language. Can I create,like multivariance equations with different f[x] in y'[x]=f[x] by using one function? The output should be like this:

differential equations

I have problems with realization so any help is good. Thanks in advance.

Added some code:

a1 = RandomInteger[Range[-1, 1]];
a2 = RandomInteger[Range[-1, 1]];
a3 = RandomInteger[Range[-1, 1]];
d = RandomChoice[Range[1, 3]];
randtri = RandomChoice[{Sin, Cos, Exp}];

eqn := {y'[t] == RandomChoice[Range[5]] y[t] + a1*randtri[t] + a2*y[t]*randtri[t] + a3*Power[y[t], d]}
$\endgroup$
0

1 Answer 1

6
$\begingroup$

Does this answer part of what you are looking for?

We can use RandomChoice to select different components of a differential equation. (Other Random functions could also be suitable)

eqn := {y'[t] == RandomChoice[Range[7]] y[t] + RandomChoice[{Sin, Cos, Exp}][t], 
        y[0] == RandomChoice[Range[4]]}

Every time eqn is evaluated, we get a different equation

eqn
(* {Derivative[1][y][t] == Cos[t] + 6 y[t], y[0] == 2} *)

which we can solve

DSolve[%, y[t], t]
(* {{y[t] -> 1/37 (80 E^(6 t) - 6 Cos[t] + Sin[t])}} *)

Extending this to multiple variables is not too hard.

$\endgroup$
5
  • $\begingroup$ Thanks,thats's it! I suppose, after that can use TraditionalForm function to get the output like on image I posted earlier? $\endgroup$
    – Ann Fremz
    Commented Jun 4, 2021 at 21:18
  • $\begingroup$ TraditionalForm will give a (different) conventional mathematical representation of the equation, in terms of y'(t), rather than dy/dt, but presumably suitable for generating problem sheets. $\endgroup$
    – mikado
    Commented Jun 4, 2021 at 22:48
  • $\begingroup$ got it, but now I have only blank graphs like here: ibb.co/64YjMwv $\endgroup$
    – Ann Fremz
    Commented Jun 4, 2021 at 23:28
  • $\begingroup$ Your solution has an undefined constant C1. Your equation needs to specify boundary conditions $\endgroup$
    – mikado
    Commented Jun 5, 2021 at 5:27
  • $\begingroup$ So DSolve function has to get additional parameters, added y[0] == -1 in {} branches and got the graph. $\endgroup$
    – Ann Fremz
    Commented Jun 5, 2021 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.