1
$\begingroup$

The premise is that I am a new Mathematica user. I'm trying to evaluate the following

B[t_, i_, h_] = piecewise[{{(t - (i - 2)*h)^3, (i - 2)*h <= t <= (i - 1)*h}, {h^3 + 
3*h^2*(t - (i - 1)*h) + 3*h*(t - (i - 1)*h)^2 - 3*(t - (i - 1)*h)^3,
(i - 1)*h <= t <= i*h}, {h^3 + 3*h^2*((i + 1)*h - t) + 3*h*((i + 1)*h - t)^2 - 
3*((i + 1)*h - t)^3, i*h <= t <= (i + 1)*h}, {((i + 2)*h - t)^3, (i + 1)*h <= t <= (i + 2)*h}}]

B0 = B[t, 0, h] - 4*B[t, -1, h]
B0p = D[B0, t]
a00p = integrate[B0p[t, h]^2, {t, 0, 1}]

But at the end I just get 'integrate[the extended form of B0p]'. Thanks in advance for your help.

EDIT: Thanks. Using uppercase letters I get the following: enter image description here

$\endgroup$
  • 1
    $\begingroup$ Commands need to be capitalised. $\endgroup$ – b.gates.you.know.what Jun 14 '15 at 12:49
  • 1
    $\begingroup$ And probably worth avoiding single capitals for functions names to avoid clashes with built in functions. $\endgroup$ – image_doctor Jun 14 '15 at 12:56
  • 1
    $\begingroup$ To be precise, built-in function names are always capitalized. User developed function may be named with or without caps but preferably don't start with a capital letter. $\endgroup$ – Sjoerd C. de Vries Jun 14 '15 at 13:16
  • 1
    $\begingroup$ You have not defined a function B0p with two arguments, yet you call it that way. $\endgroup$ – Sjoerd C. de Vries Jun 14 '15 at 13:18
2
$\begingroup$

Correcting the syntax errors:

B[t_, i_, h_] := 
 Piecewise[{{(t - (i - 2)*h)^3, (i - 2)*h <= t <= (i - 1)*h}, {h^3 + 
     3*h^2*(t - (i - 1)*h) + 3*h*(t - (i - 1)*h)^2 - 
     3*(t - (i - 1)*h)^3, (i - 1)*h <= t <= i*h}, {h^3 + 
     3*h^2*((i + 1)*h - t) + 3*h*((i + 1)*h - t)^2 - 
     3*((i + 1)*h - t)^3, 
    i*h <= t <= (i + 1)*h}, {((i + 2)*h - t)^3, (i + 1)*h <= 
     t <= (i + 2)*h}}]

B0[t_, h_] := B[t, 0, h] - 4*B[t, -1, h]
B0p[t_, h_] := D[B0[t, h], t]
a00p = Integrate[B0p[t, h]^2, {t, 0, 1}]

yields:

enter image description here

you should check this fits your expectations. Please compare code (if my corrections are ok) to understand the syntax errors.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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