Message Boards Message Boards

Convert a Mathematica Notebook into a fully interactive web page?

Posted 6 years ago

I have a Mathematica notebook that contains some animations based on numerical solutions to differential equations, with a few input parameters (either directly typed in or using sliders). I can't find a tutorial (either online or within the Help system) on how to convert this into an online web file that my students can explore for themselves. Ideally, it should show all the same content as the nb, but also be able to actually run the animation, with students being able to change the input. I tried simpleminded commands like "Export", but although a bunch of html files were created, they don't seem to do anything in my browser (Safari). Any hints would be appreciated!

Attachments:
POSTED BY: Sebastian Kuhn
6 Replies

You can try exporting as cdf, but you had better making the panels self-contained, without relying on separate sliders:

g = 9.81;
rdot = 0.05;
theta0 = 0.2;
thetadot0 = 0;
s = ParametricNDSolveValue[{theta''[t] == 
     Sin[theta[t]]*Cos[theta[t]]*omega^2 - g/r0*Sin[theta[t]], 
    theta[0] == theta0, theta'[0] == thetadot0}, 
   theta, {t, 0, 100}, {omega, r0}];
Manipulate[
 Graphics[{Blue, Circle[{0.0, 0.0}, r0], Black, 
   Line[{{-1.2, 0}, {1.2, 0}}], Line[{{0, -1.2}, {0, 1.2}}], Black, 
   Inset[Style[NumberForm[t, {3, 2}], 20], {1.0, 1.1}], Red, 
   Disk[{r0*Sin[s[omega, r0][t]], -r0*Cos[s[omega, r0][t]]}, rdot]}],
 {t, 0, 100, 0.001, Animator, AnimationRunning -> False, 
  AnimationRepetitions -> 1, AnimationRate -> anrate},
 {anrate, 0.1, 1, 0.05},
 {omega, 0, 20, 0.5},
 {{r0, 1}, 0.01, 2, 0.1}, SaveDefinitions -> True]
POSTED BY: Gianluca Gorni

Why not just send your notebook to the students? Mathematica notebooks are the best medium of technical communication, exploration and learning there is! Much better than "outside of Mathematica documents produced with Mathematica" .

I'm sure there is a reason associated with budgetary or some other kind of restraint, but still it is a shame that teachers and professors get to use Mathematica and many students can't use it.

Posted 6 years ago

Is there more code than what you posted? It seems to be incomplete when I try and run the notebook - missing functions for theta[t]. It also seems that you could publish something similar to what you can find on the Wolfram Demonstrations Projects website and it would work just fine for this use-case. Hell - I might even put it right on the Demo Website itself.

POSTED BY: William Duhe
Posted 6 years ago

Thanks for all of your suggestions. I might try the cdf approach, but the whole point was to make a nice and simple interface for the students to change parameters and try out what happens - hence the sliders. I agree that the best thing to do would be to provide the students with the actual notebook - I will definitely do that - but I can't realistically expect those that don't already know Mathematica to climb that steep learning curve just to be able to look at a demo. (Well, I can SUGGEST it!). I'm not sure why the file didn't work for William - it works fine for me (I didn't leave anything out). Note that "theta(t)" is the solution to a differential equation which Mathematica is solving numerically. I will have to look into how to publish something on the Demo Website but it probably will require some step by step instructions, as well...

POSTED BY: Sebastian Kuhn
Posted 6 years ago

Yeah but this can get mad expensive for something not worth the cost, unless you write a dispatch API to 5000 free cloud accounts to make use of their 5000 free cloud credits.

D3 is definitely the way to go (also will probably give better performance than the cloud), but it's a non-trivial export process.

POSTED BY: b3m2a1 ​ 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract